Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 examining the Monastery: (8)
As of 2014-09-19 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (136 votes), past polls