Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/perl/bin/perl use warnings; use strict; use File::Slurp::Tree; use CGI qw(:header); use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard/; # The tree datastructure is a hash of hashes. The keys of # each hash are names of directories or files. Directories # have hash references as their value, files have a scalar # which holds the contents of the file. my $dir = "c:/progra~1/apache~1/apache2/cgi-bin/test"; my %tree; my $tree = slurp_tree($dir); my $depth = 0; print header(); print_keys($tree); sub print_keys { my $href = shift; $depth++; foreach ( keys %$href ) { if(-d $_){ print "<b>Dir exists= $_</b><br>";} print '****' x $depth, "<input type=checkbox> --$_<br>\n"; print_keys( $href->{$_} ) if ref $href->{$_} eq 'HASH'; } $depth--; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Identifying Directory
by VSarkiss (Monsignor) on Jul 11, 2006 at 13:58 UTC | |
Re: Identifying Directory
by gasho (Beadle) on Jul 11, 2006 at 19:24 UTC |