Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Reading Directory

by tokpela (Chaplain)
on Jul 14, 2009 at 09:25 UTC ( #779846=note: print w/ replies, xml ) Need Help??


in reply to Reading Directory

I would also add that for scalability you should always iterate over a directory as opposed to pushing all of the filenames into an array.

I would also use a lexical directory handle.

my $dir = "/and/evel/aap/list/60"; opendir(my $d, $dir) || die "Unable to open $dir "; while (my $filename = readdir($d)) { # removes . and .. next if ($filename =~ /^\.+$/); my $filepath = "$dir/$filename"; ..... } closedir($d);


Comment on Re: Reading Directory
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-12-23 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (134 votes), past polls