Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: setting hash keys by array

by blssu (Pilgrim)
on Sep 09, 2002 at 18:47 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found