$& The string matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK). (Mnemonic: like & in some editors.) This variable is read-only and dynamically scoped to the current BLOCK.
So, since .* matched 'foo', $& is set when you use it. If you make your pattern /\d.*/ you will find you will get no output in your same test case.
(root@frodo):/tmp> # cat t.pl 'foo' =~ m/\d.*/; print eval <STDIN>; (root@frodo):/tmp> # perl t.pl $& (root@frodo):/tmp> #
Cheers,
KM
In reply to Re: Perl is psychic?!
by KM
in thread Perl is psychic?!
by MrNobo1024
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |