A failed match doesn't reset $1 and $2. You need to guard your assignments with if statements:
my( $tag1, $tag2 ); # get tag1 value if( $data =~ m/tag1=(\d+)/) { $tag1 = $1; }; # get tag2 value if( $data =~ m/tag2=(\d+)/ ) { $tag2 = $1; };
Also note that the /g modifier doesn't make sense.
In reply to Re: ambiguous regex match
by Corion
in thread ambiguous regex match
by Hosen1989
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |