I need to copy the (single-level) hash to a new one, with all the values below.
Do you know a smart method (just to avoid the ugly foreach ... ;-)
In a fun spirit, here's a solution using a somewhat obscure feature each. (Do not believe that I have ever used it before.)
each
$new{$key} = lc $val while ($key,$val) = each %old;
my %new = map { $_ => lc $old{$_} } keys %old;
map:
map
my %newHash = map { $_ => lc $existingHash{$_} } keys %existingHash;
, :
my %new_hash; @new_hash{keys %old_hash} = map lc, values %old_hash;
, keys values , , , .
keys
values
( , , ).
my %new = %old; $_ = lc for values %new;