Cleaning up grab.pl

Cleaning up grab.pl

#!/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

Previous slide Next slide Back to the first slide View Graphic Version