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


in reply to Regex Not Grabbing Everything

Update: I need to take a closer look at your code.

Could you explain, a bit more abstractly, what it is you are attempting to do? You want the lines which have ' 0.00' at column 118, correct?
First, your bracing and indenting style leaves something to be desired. Here's how I'd write your code:
while (<TEST>) { if (/NAME /../ADJ TO TOTALS:/) { push @data, $_; foreach my $data (@data) { if ($data =~ /1235114182/) { $lines .= $_; my $zero = substr $lines, 118, 5; # <-- 5? or 4? # you had '==', you want 'eq' if ($zero eq "0.00") { print OUTPUT "@data \n"; } @data = (); $zero = $lines = ""; } } } }
You were using == which is for strictly numeric data, but you want to use eq because you're looking specifically for the characters '0.00'. You either want to change your substr() to 4 characters, or else look for ' 0.00', I think.

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)