Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: setting hash keys by array

by blssu (Pilgrim)
on Sep 09, 2002 at 18:47 UTC ( #196389=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @array = qw(red green brown);
    use vars qw(%hash);
    foreach (reverse @array) {
        *hash = { $_ => (%hash) ? \%hash : 1 }
    }
    
  2. or download this
    my @array = qw(red green brown);
    my %hash;
    foreach (reverse @array) {
        %hash = ( $_ => (%hash) ? { %hash } : 1 )
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-05-23 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?