Another Matching Approach

Another Matching Approach

/^(cme|cbt|lif|smx|lifee)/ {

start_point=match($0,"\\[[0-9]+\\]")

printf "%-18s%8d\n", substr($0,1,RSTART-1),

substr($0,RSTART+1,RLENGTH-2)

}

#!/usr/local/bin/perl

$[ = 1; # set array base to 1

while (<>) {

chop; # strip record separator

if (/^(cme|cbt|lif|smx|lifee)/) {

$start_point = $_ =~ "\\[[0-9]+\\]" &&

($RLENGTH = length($&), $RSTART = length($`)+1);

printf "%-18s%8d\n", substr($_, 1, $RSTART - 1), substr($_,

$RSTART + 1, $RLENGTH - 2);

}

}

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