Cleaning up grab.pl
Cleaning up grab.pl
- Modifications to the program:
- Print only the filename and filesize (byte size)
- No longer needed start_point variable
- $_ =~ was no longer needed in the pattern match
#!/usr/local/bin/perl
$[ = 1; # set array base to 1
while (<>) {
chop; # strip record separator
if (/^(cme|cbt|lif|smx|lifee)/) {
/[0-9][0-9][0-9][0-9][0-9]+/ &&
($RLENGTH = length($&), $RSTART = length($`)+1);
printf "%-18s%8d\n", substr($_, 1, $RSTART - 2),
substr($_, $RSTART, $RLENGTH);
}
Good example in Learning PERL pattern matching features