Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: How do I dynamically create a hash table?

by tedv (Pilgrim)
on Oct 27, 2000 at 20:54 UTC ( #38849=categorized answer: print w/replies, xml ) Need Help??

Q&A > hashes > How do I dynamically create a hash table? - Answer contributed by tedv

use strict; my %hash = (); foreach $value (@some_list) { my $key = make_some_key($value); $hash{$key} = $value; }

In other words, just assign a new key/value pair using $hash{$key} = $value. It's the logical compliment of how you'd access a hash value: $value = $hash{$key}

-Ted

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-02-19 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (266 votes). Check out past polls.

    Notices?