in reply to Perl $

Is the (\d+) inside the second if $1 or $2?.

its a different regular expression, its a different m//atch operation

capture groups are numbered per match operation

so all these 4 match operations overwrite $1 /(.)/; $foo=~ /(.)/; $bar=~ /(.)/; $baz=~ /(.)/;

As do these $one = qr/(.)/ ; m{$one}; $foo=~ m{$one}; $bar =~ m{$one}; $baz =~ m{$one};

perlvar#$<_digits_> ($1, $2, ...) , perlrequick, perlretut

Replies are listed 'Best First'.
Re^2: Perl $1, $2, $3, $4
by lddzjwwy (Novice) on Jun 17, 2013 at 12:45 UTC

    Thanks dude, very clear explanation.