If you want to loop through the list with for you'll still have to use parens around the list that qw generates.
Note that I am using ^ for the qw delimiter to disambiguate from the list parens.$ perl -wE 'for my $d qw^ 2006-10-21 15.01.2007 10/31/2005 ^ { say $d +}' syntax error at -e line 1, near "$d qw^ 2006-10-21 15.01.2007 10/31/20 +05 ^" Execution of -e aborted due to compilation errors. $ perl -wE 'for my $d (qw^ 2006-10-21 15.01.2007 10/31/2005 ^) { say $ +d } ' 2006-10-21 15.01.2007 10/31/2005
Also note that you don't need the list parens if using a postfix for:
$ perl -wE 'say $_ for qw^ 2006-10-21 15.01.2007 10/31/2005 ^' 2006-10-21 15.01.2007 10/31/2005
Hope this helps!
In reply to Re: Perl Tutorial code uses "qw" but has an error when run
by 1nickt
in thread Perl Tutorial code uses "qw" but has an error when run
by Tio Cash
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |