Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Recurse through directories for file I/O

by tinman (Curate)
on Mar 23, 2001 at 02:46 UTC ( [id://66502]=note: print w/replies, xml ) Need Help??


in reply to Recurse through directories for file I/O

I think File::Find is a module that you can use for this task..

if not you can do it the harder way, as

opendir(ROOT,'/web/web1/') or die "Can't open directory; @my_names = readdir(ROOT); # do a filetest(-d on each element of @my_names, # you can check directories thusly foreach my $elem(@my_names) { if(-d $elem) { # yup, its a directory } # push it onto a stack, for later processing else { # file, symlink.. so, check if its the file you <br>want to + process... and do stuff with it, or let it alone } }

So, have this stuff inside a subroutine.. first open the header directory, and pass a list of elements to the subroutine.. keep doing this recursively for each subdirectory you encounter..
HTH
Update: I see YoungPups has already recommended File::Find.. sound advice :o)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found