Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Getting files in a directory tree

by esskar (Deacon)
on Mar 04, 2004 at 05:38 UTC ( [id://333793]=note: print w/replies, xml ) Need Help??


in reply to Re: Getting files in a directory tree
in thread Getting files in a directory tree

1. do not forget to close the directory using closedir
2. using recursion and D as the directory handle can be danagerous; better
sub recurse { my $folder = shift; my $dir; if(opendir($dir, $folder)) # who needs error checking anyways? me! { while(defined(my $entry = readdir($dir))) { next if $entry =~ /^\.\.?$/; # avoiding endless loop :) if( -d "$folder/$entry" ){ recurse("$folder/$entry"); } else { #regular file } } closedir($dir); } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found