Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

by choroba (Chancellor)
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015340]
[GrandFather]: It's either lines that your browser won't split (no white space) or nodes with <pre> tags which ought to be code tags
[GrandFather]: I haven't noticed the problem for a while, but it can be hard to find the nasty node. If you do find it, consider it and with luck a janitor will fix it

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2017-05-24 00:58 GMT
Find Nodes?
    Voting Booth?