Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779846]
[panwarsagar]: I have started learning Perl and my moto is to process a text file and storing the contents in a Data Base
[erix]: perhaps try: Databases made easy

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2017-03-28 12:29 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (330 votes). Check out past polls.