1 # Syntax: perl getFileSizeInDirectoryTree.pl [-d] [directory [pathname_regex]]
7 my $pathnameMustMatchRegex;
9 # Subroutine called by File::Find.
12 print STDERR
"testing [$File::Find::name]..." if $debug;
14 if (!defined($pathnameMustMatchRegex) || $File::Find
::name
=~ m/$pathnameMustMatchRegex/)
16 print STDERR
"matched, printing.\n" if $debug;
19 my $formattedName = $File::Find
::name
;
20 $formattedName =~ s!\\!/!g;
21 print "$fileStat[7] $formattedName\n";
25 print STDERR
"no match, skipping.\n" if $debug;
30 if (defined($ARGV[0]) && $ARGV[0] =~ m/-h/)
32 print "Syntax: getFileSizeInDirectoryTree.pl [directory [pathname_regex]]\n";
33 print "\tpathname_regex is a Perl-compatible regular expression, matches all if not specified.\n";
38 if (defined($ARGV[0]) && $ARGV[0] =~ m/-d/)
41 print STDERR
"\$debug = 1\n";
46 my @directories = ($ARGV[0]);
47 $directories[0] = '.' if !defined($directories[0]);
48 print STDERR
"directories = [@directories]\n" if $debug;
51 $pathnameMustMatchRegex = $ARGV[1] if defined($ARGV[1]);
52 $pathnameMustMatchRegex =~ s/[\'\"]//g if defined($pathnameMustMatchRegex);
53 print STDERR
"pathnameMustMatchRegex = [$pathnameMustMatchRegex]\n" if ($debug && defined($pathnameMustMatchRegex));
56 File
::Find
::find
(\
&processFile
, @directories);