in reply to symbolic reference & loading hashes

I believe what you are looking for is:

@{@keys} = @values;

${...} is scalar, but the return you want is an array @rld is the keys in the package hash. @{...} takes keys and returns values. ${...} takes a key and returns a value.

Replies are listed 'Best First'.
Re^2: symbolic reference & loading hashes
by ikegami (Patriarch) on Jul 20, 2007 at 16:39 UTC

    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;