Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
and I want to store this data in a data structure that I can easily browse. I cannot go with hashes, because neither ID nor NUMBER are unique, as you see.ID FIRST_NUMBER SECOND_NUMBER 1 1 1 2 1 2 3 2 3 4 2 4 5 3 5 6 3 6 7 4 7 8 4 6 9 5 8 10 5 9 11 6 10 12 6 9
The HoH works OK, but how can I search it when the only thing that I am given will be the FIRST_NUMBERS and NOT the IDs? For instance, if you take line 12(last line) my target is to be able to retrieve 9 (SECOND_NUMBER) when I am given 6 (FIRST_NUMBER) but not mistake 9 for 10 (which is in the above line).if($_=~/^(\d+)\t(.*)/) { $id=$1; $rest=$2; @split_rest = split(/\t/, $rest); $first_num=$split_rest[0]; $second_num=$split_rest[1]; $HoH{$id}{$first_num} = $second_num;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Which data structure should I use?
by ikegami (Patriarch) on Sep 06, 2009 at 23:38 UTC | |
by Anonymous Monk on Sep 06, 2009 at 23:43 UTC | |
by ikegami (Patriarch) on Sep 07, 2009 at 00:47 UTC | |
|
Re: Which data structure should I use?
by ysth (Canon) on Sep 07, 2009 at 01:53 UTC | |
|
Re: Which data structure should I use?
by ig (Vicar) on Sep 07, 2009 at 06:16 UTC | |
|
Re: Which data structure should I use?
by ikegami (Patriarch) on Sep 06, 2009 at 23:31 UTC | |
by Anonymous Monk on Sep 06, 2009 at 23:39 UTC | |
|
Re: Which data structure should I use?
by bluescreen (Friar) on Sep 07, 2009 at 03:18 UTC | |
|
Re: Which data structure should I use?
by Anonymous Monk on Sep 06, 2009 at 23:28 UTC |