I wrote the following script as a windows tail + count function,
but it's too slow if the input is huge, how can it be improved?
if (!$ARGV[0]){
die("you've forgotten to enter the file name\n");
}
if (!$ARGV[1]) {
$n = 9; # output 10 rows by default
}
else {
$n = $ARGV[1]-1;
}
open IN, "$ARGV[0]" or die;
@_ = <IN>;
foreach my $i(($#_-$n)..$#_){
print $_[$i];
}
close IN;
$i = $#_+1;
printf "-------\nTotal # of rows: $i\n";
Thanks,
Stan L
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]