Fixes to the Code
Fixes to the Code
- Move The substitution before the field split
- Could improve the pattern match by eliminating search for “lifee”
- Lesson learned is proper splitting (field parsing) can fail
#!/usr/local/bin/perl
$[ = 1; $, = ' ';$\ = "\n";
while (<>) {
chop; # strip record separator
$s = "[\\[\\]]", s/$s/ /g;
@Fld = split(' ', $_, 9999);
if (/^(cme|cbt|lif|smx|lifee)/) {
printf "%-18s%8d\n", $Fld[1], $Fld[2];
}
}
#Will Now Yield:
cbt0515s.par 495316
cme0515s.par 2044020
lif0515s.par 221548
lifee0515s.par 581755
smx0515s.par 276660