http://qs1969.pair.com?node_id=549425


in reply to The value of pattern match variable $&

I don't have my copy handy, but I'm almost certain that PBP recommends against using $`, $' and $&. Mainly because of the fact that they are global, and if you have several pattern matches in your code you can never be sure which variable was set by which match.

Much better instead to use explicit locally-scoped variables, and capturing parentheses, eg:

my ($prematch, $match, $postmatch) =~ /^(foo)(bar)(baz)$/;

Cheers,
Darren :)