Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: recurse directories?

by Benedictine Monk (Novice)
on Mar 12, 2000 at 10:33 UTC ( [id://5252]=note: print w/replies, xml ) Need Help??


in reply to recurse directories?

You can roll your own recursive function to do this:
sub parse_file ($) { #Do something with the file here. } sub traverse (@) { my @files = @_; local *DIRH; #If @files is empty, why bother? return unless @files; foreach my $file (@files) { #Skip unreadable files. next unless -r $file; if (-d $file) { #If it's a directory ... chomp(my $cwd = system('/bin/pwd')); #save current directory, .. +. chdir($file) || next; #change to the new director +y, ... opendir(DIRH,$file) || next; #open it... traverse((readdir(DIRH)); #and recursively parse it. closedir(DIRH); #Close the directory. chdir($cwd); #Change directories back to + where we were. } else { #If it's not a directory, then parse it. parse_file($file); #This is where the actual +work is done. } } } traverse(@ARGV);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-24 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found