New(?) for qw(...) error

Joel Bernstein joel at fysh.org
Tue Mar 27 11:58:40 BST 2007


On Tue, Mar 27, 2007 at 11:10:57AM +0100, Paul Makepeace wrote:
> I've just had one of my dodgier scripts start bailing on this construction,
> 
> $ perl -le 'for $a qw(a b) { print $a }'
> a
> b
> $ perl -le 'for qw(a b) { print }'
> Missing $ on loop variable at -e line 1.
> 
> This is on 5.8.8; not sure when this kicked in.

So put the brackets back!
jbernstein at bandicoot 11:57 ~ $ perl -le 'for (qw(a b)) { print }'
a
b
jbernstein at bandicoot 11:57 ~ $ perl -le 'for qw(a b) { print }' 
Missing $ on loop variable at -e line 1.
zsh: exit 255   /usr/bin/perl -le 'for qw(a b) { print }'
jbernstein at bandicoot 11:57 ~ $ perl -v
This is perl, v5.8.6 built for darwin-thread-multi-2level

HTH,

/joel


More information about the london.pm mailing list