[Bi-]Weekly Perl Script
Bill Jones
bill at fccj.org
Sat May 8 09:49:00 CDT 1999
On the Jax.PM jacksonville-pm-list 1.94.4;
"Bill Jones" <bill at fccj.org> wrote -
Hi All :] (We are now 6 members strong!)
Welcome!
Here is the latest installment of what was supposed
to be the Weekly Perl Script, but appears to be
bi-weekly now.
#!/usr/local/bin/perl
use Cwd;
use File::Find;
# Do NOT run as root!
($> > 0)
or die("\n\nWARNING: Do NOT run as root! Goodbye...\n\n");
unless (@ARGV && (@ARGV > 1)) {
print "Usage: $0 number directory [Enter]\n\n";
exit;
}
my $directory = pop(@ARGV);
my $number = pop(@ARGV);
unless ($number > 0 && $number < 100) {
print "Number entered $number: Not numeric or not
between 1 thru 99...\n\n";
exit;
}
unless (-d $directory) {
print "Directory specified does not exist...\n\n";
exit;
}
if (($directory eq "/") || (getcwd eq "/")) {
print "Will not run from ROOT Directory, sorry...\n\n";
exit;
}
find (sub {
$size{$File::Find::name} =
-s if -f;
}, $directory);
@sorted = sort {
$size{$b} <=> $size{$a}
} keys %size;
splice @sorted, $number if @sorted > $number;
foreach (@sorted) {
printf "%10d %s\n", $size{$_}, $_;
}
#
# Some related ideas -
#
# $Example =~ /^((?:\d+\.??){$addrClass})/;
# $two == (() = /\d+/g); # ?Huh?
#
# ...end of script...
As always, please e-mail this list if
you have any questions, etc.
Enjoy,
-Sneex- :]
_________________________________________________________________________
Bill Jones | Data Security Specialist | http://www.fccj.org/cgi/mail?dss
FCCJ | 501 W State St | Jacksonville, FL 32202 | 1 (904) 632-3089
Trust the computer industry to shorten "Year 2000"
to "Y2k". It was this kind of thinking that caused
the problem in the first place.
-- Tony Poldrugovac
The Jacksonville Perl Monger's Group is operated by -
Bill -Sneex- Jones ( sneex at usa.net ),
to whom send all praises, complaints, or comments...
More information about the Jacksonville-pm
mailing list