Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: traverse DIR checking each level exists

by TJPride (Pilgrim)
on Mar 11, 2012 at 06:48 UTC ( [id://958914]=note: print w/replies, xml ) Need Help??


in reply to traverse DIR checking each level exists

use strict; use warnings; my @dirs = '/'; ### Starting directory my ($dir, $file, $path); while ($dir = shift(@dirs)) { opendir(DIR, $dir); while ($file = readdir(DIR)) { next if $file =~ /^\./; next if $file eq 'dir.pl'; ### Name of your script $path = $dir . $file; if (-d $path) { push (@dirs, "$path/"); next; } ### Do something with file path } }

Log In?
Username:
Password:

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

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

    No recent polls found