To get the next line after a line ending in 0.00,
if (my @lines = grep{/^\d+.*\s*0\.00\s*$/}@data)
change to:
if (my @lines = grep{/^\d+.*\s*0\.00\s*$/..././}@data)
Perl grep is a very powerful critter! What the above says is to filter lines from @data. If the condition in the grep is true, make a copy of the line in @lines. The regex in the grep means: True if we are inbetween a line starts with a digit and ends with 0.00 and another line containing any character at all. The 3 dots means that this "any character" has to be on a separate line. So this will print the line ending in 0.00 and the next line whatever it has, which from your data format happens to be this N347 stuff! Pretty cool!
As like before, I deleted some of the characters so that the output wouldn't word wrap.
NAME DOE, JOHN ..... ASG Y MOA MA01 MA18
12351141821118 ..... CO-18 31.00 0.00
N347
12351141821118 ..... CO-18 199.00 0.00
N347
12351141821118 111809 CO-18 182.00 0.00
N347
ADJ TO TOTALS: PREV PD INTEREST ... 84.25
I wish you well on your Perl learning adventure! Perl is certainly not considered a beginning language. So you are starting in a hard place. You will need a number of books, perhaps start with "Learning Perl". |