in reply to Re^5: Perl Idioms Explained - keys %{{map{$_=>1}@list}}
in thread Perl Idioms Explained - keys %{{map{$_=>1}@list}}
The former interprets the slice as a scalar list, and undefs the last element only. The reason all the keys get defined is that it puts the slice in lvalue context, and autovivification occurs. The latter is equivalent to assigning a list to a list.I think I see your point. Would you then have expected, in nature, the following to be equivalent:
with no. 3 taking the hash slice as a plain list, and that in a scalar context?$h{c} = undef; # 1 undef $h{c}; # 2 undef @h{qw|a b c|}; # 3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Perl Idioms Explained - keys %{{map{$_=>1}@list}}
by Roy Johnson (Monsignor) on Mar 02, 2005 at 16:11 UTC |
In Section
Meditations