Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Hashes & Arrays

by ikegami (Patriarch)
on Aug 29, 2005 at 19:58 UTC ( [id://487531]=note: print w/replies, xml ) Need Help??


in reply to Hashes & Arrays

I think you mean $email = $hash{key}[0]{email}; At least, that's what your steps describe.

my %hash; # Inputed data: my $email = 'email@example.com'; my $timestamp = time; # Adding a record: my $record = { email => $email, timtstamp => timestamp, }; push(@{$hash{key}}, $record); # Example of getting a value: print("email for first record: ", $hash{key}[0]{email}, "\n");

"@{ $hash{key} }" means "the array at key 'key' in the hash '%hash'". Auto-vivification will create the array for us if it doesn't already exist.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found