in reply to Value of a scalar specified by a second scalar
oruse strict; use warnings; my (%hash, $want); @hash{qw/a b c/} = (1, 2, 3); $want = 'c'; print $hash{$want};
use strict; use warnings; my (%hash, @keys, @vals, $want); @keys = qw/a b c/; @vals = (1, 2, 3); @hash{@keys} = (@vals); $want = 'c'; print $hash{$want};
|
|---|