Listing A
#!/bin/perl use File::Find; my $ByteCount=0; # Issue the find command passing two arguments # The first argument is the subroutine that will be called for each file in the path. # The second argument is the directory to start your search in. find(\&cleanup, "c:\\"); print "Files are using $ByteCount bytes\n"; # Subroutine that determines whether we matched the file extensions. sub cleanup { if ((/\.zip$/) || (/\.tmp$/) || (/\.TMP$/) || (/^~/) || (/\.chk$/) ){ print "$File::Find::name\n"; # Only piece of information we care about is the $size, which is in bytes. my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $therest) = stat($_) or die "Unable to stat $_\n"; $ByteCount += $size; } }