On Wednesday 01 December 2010 16:57:07 John W. Krahn wrote:
> Amit Saxena wrote:
> > Hi all,
> > {
> > 
> >          next if ( ( $filename eq "." ) or ( $filename eq ".." ) );
> >          
> >          push ( @files_in_directory, $filename );
> > 
> > }
> 
> Since all you are doing is populating the array you could just do it
> like this:
> 
> my @files_in_directory = grep !/\A\.\.?\z/, readdir DIR1;
> 

Better yet, use File::Spec->no_upwards() :

my @files_in_directory = File::Spec->no_upwards(readdir($dir1));

see http://perldoc.perl.org/File/Spec.html .

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

<rindolf> She's a hot chick. But she smokes.
<go|dfish> She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to