Hosen1989 has asked for the wisdom of the Perl Monks concerning the following question:
Dear ALL,
I was doing some parsing for log file and come to this bug (i think), I add the next simple code to show you what I face:
use strict; use warnings; my $data = 'blabla;tag1=12345;blabla;'; # my $data = 'blabla;tag1=12345;blabla;tag2=99999'; # get tag1 value $data =~ m/tag1=(\d+)/g; my $tag1 = $1; # get tag2 value $data =~ m/tag2=(\d+)/g; my $tag2 = $1; print "tag1 = $tag1\n"; print "tag2 = $tag2\n";
The output:
tag1 = 12345 tag2 = 12345
Us you can see the are only tag1 value in $data, so should be no match and the second tag $tag2 should be undefined,
but what i got is $tag1 =$tag2!!!.
So can any monk here (and pretty please) explain to my what happen here.
BR
Hosen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ambiguous regex match
by Corion (Patriarch) on Jul 24, 2015 at 16:46 UTC | |
|
Re: ambiguous regex match
by stevieb (Canon) on Jul 24, 2015 at 16:52 UTC | |
by Laurent_R (Canon) on Jul 24, 2015 at 17:07 UTC | |
by stevieb (Canon) on Jul 24, 2015 at 17:14 UTC | |
|
Re: ambiguous regex match
by Marshall (Canon) on Jul 26, 2015 at 11:50 UTC |