But, it only seems to happen with the # delimiters. If I use other delimiters, I get no warnings:
$ perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw{a b}}' 1,2 $ perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw/a b/}' 1,2 $ perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw(a b)}' 1,2 $ perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw#a b#}' Scalar value @foo{qw#a b#} better written as $foo{qw#a b#} at -e line +1. 1,2 $
Results are similar on v5.8.9 (using print instead of say).
Update: Here is a quote from qw -> Quote Like Operators:
A common mistake is to try to separate the words with comma or to put comments into a multi-line qw-string. For this reason, the use warnings pragma and the -w switch (that is, the $^W variable) produces warnings if the STRING contains the "," or the "#" character.
It is probably best to avoid # delimiters with qw.
In reply to Re: Incorrect warning when using hash slices?
by toolic
in thread Incorrect warning when using hash slices?
by flipper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |