New(?) for qw(...) error
Rafael Garcia-Suarez
rgarciasuarez at gmail.com
Wed Mar 28 14:23:30 BST 2007
On 28/03/07, McGlinchy, Alistair
<Alistair.McGlinchy at marks-and-spencer.com> wrote:
> While verifing this little meme, I found this extra piece of magical $_
> fun. Shouldn't these all print the same thing?
Certainly they should. Apparently, for some reason, in the 2nd case
the parser is confused and think that "print" is a literal string (as
in an hashref). Adding a semicolon after print solves it. Not sure how
to fix that.
> % perl -le 'for $_ (qw(a b)) { print }'
> a
> b
> % perl -le 'for $_ qw(a b) { print }'
> %
> % perl -le 'for $_ qw(a b) { print $_ }'
> a
> b
More information about the london.pm
mailing list