in reply to ambiguous regex match
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.
|
|---|