in reply to Simple Hash problem
If there are no 0 values:$new{$_}=defined$old{$_}?$old{$_}:999 for@mips
The first, but perl6 (I think):$new{$_}=$old{$_}||999 for@mips
$new{$_}=$old{$_}//999 for@mips
for (@mips) { $new{$_} = defined($old{$_}) ? $old{$_} : 999; }
If 0 may be 999:%new=map{($_,defined$old{$_}?$old{$_}:999}@mips
Another perl6 try:%new=map{($_,$old{$_}||999)}@mips
%new=map{($_,$old{$_}//999)}@mips
%new = map { ($_ => defined($old{$_}) ? $old{$_} : 999) } @mips;
|
|---|