http://qs1969.pair.com?node_id=860532


in reply to Re^4: Regex Not Grabbing Everything
in thread Regex Not Grabbing Everything

If changing the 5 to 4 yields '0.0', then I think it's actually yielding ' 0.0' (that's space-zero-dot-zero), which means your offset of 118 might be wrong.

The reason your code is failing, in general, is because your logic is faulty. You think your code is saying "print the contents of the array if there's a line with '0.00' at offset 118", but your code is NOT saying that.

Your code is saying:

for each line in between 'NAME' and 'ADJ TO TOTALS:', do this { add this line to the @data array now go through each element of the @data array, and do this { # <-- + WHY?! if this line has 1235114182 in it, do this { put this line at the end of $lines if $lines has '0.00' at offset 118, do this { print the @data array } empty the @data array, $lines, etc. } } }
Your code is faulty because it won't print any line that DOESN'T have '0.00' in it.

I suggest you try my sample solution and plug in the values for $target, $pos, 'START', and 'END'.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
Nos autem praedicamus Christum crucifixum (1 Cor. 1:23) - The Cross Reference (My Blog)