in reply to Re: symbolic reference & loading hashes
in thread symbolic reference & loading hashes
Nope, that will evaluate @keys in scalar context in order to deref the value. Perl doesn't provide any direct means of setting multiple referenced values at once, so a loop is needed.
for my $i (0..$#keys) { ${$keys[$i]} = $values[$i]; }
Alternatively,
use List::MoreUtils qw( pairwise ); pairwise { ${$a} = $b } @keys, @values;
Of course, hashes are better than symbolic references.
@hash{@keys} = @values;
|
|---|