in reply to Regex Not Grabbing Everything
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.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 = ""; } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Not Grabbing Everything
by JonDepp (Novice) on Sep 17, 2010 at 14:41 UTC | |
by japhy (Canon) on Sep 17, 2010 at 15:19 UTC | |
by JonDepp (Novice) on Sep 17, 2010 at 16:24 UTC | |
by japhy (Canon) on Sep 17, 2010 at 17:23 UTC |