in reply to Using a hash with the @ sigil
Why doesn't Perl have a warning for the [@hash{@array} = 'foo'] case?
I would say because an empty hash slice assignment | index list is a perfectly valid thing. It's equivalent to
$hash{$_} = 'foo' for @array;
which also does not (and should not) warn.
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my %hash = qw(a 1 b 2); my @array; @hash{@array} = 'foo'; dd \%hash; ;; $hash{$_} = 'foo' for @array; dd \%hash; " { a => 1, b => 2 } { a => 1, b => 2 }
Give a man a fish: <%-(-(-(-<
|
|---|