in reply to question about multi value hash key

Thanks everyone for the help. This is my second post and I am not familiar with the format. Please don't mind my clumsiness.

The problem that I have is to merge two files which have the same fields (time, conference, type, comment) and to sort them out. The combination of (time, conference)is unique. When I tried it, I had the problem of how to address multi value key in hash. I had a sub to read files and write contents to two hashes and return the hash reference. But that was for single value key. I don't know how to do the same thing with muti-value key and how to use key reference to access multiple values in the hash. Hope I made the problem a little bit cleare.

  • Comment on Re: question about multi value hash key

Replies are listed 'Best First'.
Re^2: question about multi value hash key
by wfsp (Abbot) on Apr 01, 2009 at 06:11 UTC
    Perhaps a HoHoH would do it.
    #!/usr/bin/perl use warnings; use strict; my %conf_table = ( 1 => { conference1 => { type => q{type1}, comment => q{comment1}, }, conference2 => { type => q{type2}, comment => q{comment2}, }, }, 2 => { conference3 => { type => q{type1}, comment => q{comment3}, }, conference4 => { type => q{type2}, comment => q{comment4}, }, }, ); for my $time (keys %conf_table){ print qq{time: $time\n}; for my $cnf (keys %{$conf_table{$time}}){ print qq{\tconference: $cnf\n}; print qq{\t\ttype: $conf_table{$time}{$cnf}{type}\n}; print qq{\t\tcomment: $conf_table{$time}{$cnf}{comment}\n}; } }
    time: 1 conference: conference1 type: type1 comment: comment1 conference: conference2 type: type2 comment: comment2 time: 2 conference: conference4 type: type2 comment: comment4 conference: conference3 type: type1 comment: comment3