Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 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: (7)
As of 2018-08-16 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (167 votes). Check out past polls.

    Notices?