use warnings; use strict; use Data::Dumper; my $urlbase = 'http://proxy/cgi-bin/getobj.pl?'; sub recurse { my ($basedir, $dir) = @_; $dir = $basedir unless (defined($dir)); $dir = "$dir/" unless ($dir =~ m#/$#); my $base = substr($dir, length($basedir)); my %tree; opendir(DIR , $dir); foreach my $path (readdir(DIR)) { next if ($path =~ /^\.\.?/); # . & .. my $dirpath = "$dir$path"; if (-f $dirpath) { $tree{$path} = "$urlbase$base$path"; } elsif (-d $dirpath && !-l $dirpath) { $tree{$path} = recurse($basedir, $dirpath); } } closedir(DIR); return \%tree; } my ($path) = @ARGV; unless (defined($path)) { print "Usage: $0 path\n"; exit(0); } print Dumper recurse ($path);
In reply to Re: Everybody loves not using File::Find
by tadman
in thread Everybody loves not using File::Find
by submersible_toaster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |