jumdesumit:
Well, while you have several lines that match the pattern ([N01]{39}), none of the lines stop after the last [N01] match, they
all have a semicolon and more text after them.
Try changing the line to not require that the line end immediately after that, like this:
if ( $line =~ /([N01]{39})/ )
or alternatively, specify that the string should be followed with a semicolon:
if ( $line =~ /([N01]{39});/ )
It would be helpful if you'd re-read perldoc perlre and verify that your expressions are saying what you really mean.
When I have a problem with a pattern, I usually do something akin to putting this at the start of the file:
use strict; use warnings;
while (my $line = <DATA>) {
if ($line =~ /([N01]{39})$/) {
print "line $.: <$1>\n";
}
}
__DATA__
And then run the file as a perl script. Then you can tweak your regex until you get what you're looking for. For example, when I ran it with the above bit of code on the front, I got this:
Roboticus@Waubli ~
$ perl pm1208422.pl
Roboticus@Waubli ~
$
I then removed the '$' from your condition, re-ran it and got:
Roboticus@Waubli ~
$ perl pm1208422.pl
line 194: <NN0NNNNNNNNNNN0NNNNNNNNNNNNNNNNNNNNNNNN>
line 196: <NN0NNNNNNNNNNN1NNNNNNNNNNNNNNNNNNNNNNNN>
line 199: <NN0NNNNNNNNNNN1NNNNNNNNNNNNNNNNNNNNNNNN>
line 201: <NN0NNNNNNNNNNN0NNNNNNNNNNNNNNNNNNNNNNNN>
line 204: <NN0NNNNNNNNNNNNNNNNN0NNNNNNNNNNNNNNNNNN>
line 206: <NN0NNNNNNNNNNNNNNNNN1NNNNNNNNNNNNNNNNNN>
line 209: <NN0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0NN>
line 211: <NN00NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN1NN>
line 214: <NN0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0NNN>
line 216: <NN0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN1NNN>
. . . et cetera . . .
Update: Fixed wording and formatting (code tags so square brackets don't linkify) in first sentence.
...roboticus
When your only tool is a hammer, all problems look like your thumb. |