Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Answer: How do I make an array of hashes?

by chromatic (Archbishop)
on Mar 31, 2000 at 00:42 UTC ( #6552=categorized answer: print w/replies, xml ) Need Help??

Q&A > Data Structures > How do I make an array of hashes? - Answer contributed by chromatic

my @array = ( { 'name' => 'Chuck', 'job' => 'roustabout', }, { 'name' => 'CowboyNeal', 'job' => 'code monkey', }, );
You can also use normal array operations (such as push) to modify an array:
push @array, { 'name' => 'vroom', 'job' => 'stacking blocks' }; print $array[0]->{name};
See perlman:perldsc for more information.

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: (2)
As of 2021-03-08 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (123 votes). Check out past polls.

    Notices?