I am afraid this will not work correctly if the regex fails, because $1 will still be set to its previous value (previous regex match). So that rather than testing $1, we should test whether the regex matched.$data =~ /tag2=(\d+)/; $tag2 = $1 if $1;
I think that you would need rather something like this:
$tag1 = $1 if $data =~ /tag1=(\d+)/; $tag2 = $1 if $data =~ /tag2=(\d+)/;
In reply to Re^2: ambiguous regex match
by Laurent_R
in thread ambiguous regex match
by Hosen1989
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |