in reply to Can I create hash dynamically by looping through an array? The hash name should be the array element
The common practice, though, is to use one hash instead, making the elements of the list the keys. You can then shorten the creation tofor my $element (qw/var1 var2 var3/) { %$element = ( a => 'b'); } print $var1{a};
my @array = qw(var1 var2 var3); my %hash; undef @hash{@array};
|
|---|