in reply to Re: ambiguous regex match
in thread ambiguous regex match

$data =~ /tag2=(\d+)/; $tag2 = $1 if $1;
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.

I think that you would need rather something like this:

$tag1 = $1 if $data =~ /tag1=(\d+)/; $tag2 = $1 if $data =~ /tag2=(\d+)/;

Replies are listed 'Best First'.
Re^3: ambiguous regex match
by stevieb (Canon) on Jul 24, 2015 at 17:14 UTC