Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Can I create hash dynamically by looping through an array? The hash name should be the array element

by choroba (Canon)
on Jan 25, 2013 at 12:51 UTC ( #1015340=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    for my $element (qw/var1 var2 var3/) {
        %$element = ( a => 'b');
    }
    print $var1{a};
    
  2. or download this
    my @array = qw(var1 var2 var3);
    my %hash;
    undef @hash{@array};
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015340]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-07-03 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls