joybee has asked for the wisdom of the Perl Monks concerning the following question:
Hello! I am new to perl. And now I need monks' help with a problem related to hash.
I am trying to merge two hashes. I have fields of time, conference, type, comment. I have no problem with time as hash key.
while (<FILE>)
{
my %hash = ();
$hash{$time}{'conference'} = $value1;
$hash{$ime}{'type'} = $value2;
$hash{$time}{'comment'} = $value3;
}
for my $time (sort keys %hash)
{
print .... #element
}
But how do I do the same thing (add element and access later) if I use time and conference as multi value key in the hash. I could add time and conference to the key using push, but how to refer to it to add $type, $comment and later to print all four fields?
Thanks for help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: question about multi value hash key
by kyle (Abbot) on Mar 31, 2009 at 22:06 UTC | |
|
Re: question about multi value hash key
by moritz (Cardinal) on Mar 31, 2009 at 21:25 UTC | |
|
Re: question about multi value hash key
by codeacrobat (Chaplain) on Mar 31, 2009 at 22:24 UTC | |
|
Re: question about multi value hash key
by locked_user sundialsvc4 (Abbot) on Mar 31, 2009 at 22:51 UTC | |
by Anonymous Monk on Apr 01, 2009 at 04:53 UTC | |
|
Re: question about multi value hash key
by Ish (Acolyte) on Mar 31, 2009 at 22:14 UTC | |
|
Re: question about multi value hash key
by joybee (Initiate) on Apr 01, 2009 at 03:23 UTC | |
by wfsp (Abbot) on Apr 01, 2009 at 06:11 UTC | |
|
Re: question about multi value hash key
by ambrus (Abbot) on Apr 01, 2009 at 10:43 UTC |