oaklander has asked for the wisdom of the Perl Monks concerning the following question:
use File::Find qw(finddepth); #finddepth is a perl reserved word die "GIVE DIRECTORY NAME AS AN ARGUMENT\n" unless @ARGV; *name = *File::Find::name; finddepth \&list, @ARGV; sub print2 { $LINEMAX=2; #SETS HOW MANY LINES OF OUTPUT PER C/R if(++$line > $LINEMAX) { $line=0; getc; } print @_; } if ( !-d ) { print "DIRECTORY NOT FOUND!\n"; exit(0); } else { sub list { if (!-l && -d _) { print2; $i++; print "$name is a DIRECTORY\n"; } else { $j++; print2; print "$name\n"; } } $x=$i+$j; print "\nDIRECTORY COUNT = $i\n"; print "FILE COUNT = $j\n"; print "TOTAL RECORD COUNT = $x\n"; }
/Perl/bin/newr/hh.txt.bak /Perl/bin/newr/scr.pl /Perl/bin/newr/scr.txt /Perl/bin/newr/scr.txt.bak /Perl/bin/newr is a DIRECTORY /Perl/bin is a DIRECTORY DIRECTORY COUNT = 3 FILE COUNT = 209 TOTAL RECORD COUNT = 212
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Find
by strat (Canon) on Mar 13, 2002 at 11:59 UTC | |
by oaklander (Acolyte) on Mar 13, 2002 at 14:45 UTC | |
by mull (Monk) on Mar 13, 2002 at 15:04 UTC | |
|
Re: File Find
by Juerd (Abbot) on Mar 13, 2002 at 11:49 UTC | |
|
Re: File Find
by strat (Canon) on Mar 13, 2002 at 15:36 UTC |