There is a difference:
$\ = "\n"; my $s = 'abcdefghij'; $s =~ /def/; print $&; # def print substr($s, $-[0], $+[0] - $-[0]); # def $s = '1234567890'; print $&; # def print substr($s, $-[0], $+[0] - $-[0]); # 456
Does it matter? Maybe. Switching could break existing code.
In reply to Re: Can we make $& better?
by ikegami
in thread Can we make $& better?
by TedYoung
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |