Dabuel has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my ($file, $prefix); walk("C:\\"); sub walk { $file = shift; $prefix = shift; #($file, $prefix) = @_; # You can also use shift. my $file = + shift; my $prefix = shift; $prefix ||= ""; # Set $prefix to "" if undefined ( +first case) #print "$file\n"; if ("$file"=~m/.nsf$/){ print "Prefix: $prefix\nFile:$file\n"; # print current + file. } if(-d $file) { # is this a directory? chdir $file; opendir(DIR, "."); my @files = grep {$_ !~ /^\.\.?$/} readdir(DIR); # Ignore + . and .. closedir DIR; walk($_, "$prefix$file\\") foreach @files; # recur +sive call chdir ".."; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching a file system
by sflitman (Hermit) on Dec 22, 2010 at 05:28 UTC | |
|
Re: Searching a file system
by toolic (Bishop) on Dec 22, 2010 at 13:36 UTC | |
|
Re: Searching a file system
by eff_i_g (Curate) on Dec 22, 2010 at 15:10 UTC | |
|
Re: Searching a file system
by fisher (Priest) on Dec 22, 2010 at 13:33 UTC |