in reply to Re: Which data structure should I use?
in thread Which data structure should I use?

So, in the code you suggest, ID won't be used at all? I don't need to use ID after all, I just want to store the pairs SECOND_NUMBER<->FIRST_NUMBER, so It suits me better...
However, how would you use the code you provide in order to get the pair 9<->6 in line 12? If I gave you $wanted_second_number=9, how would you print $first_number=6?

Replies are listed 'Best First'.
Re^3: Which data structure should I use?
by ikegami (Patriarch) on Sep 07, 2009 at 00:47 UTC

    So, in the code you suggest, ID won't be used at all

    It's there, just not used as the index.

    However, how would you use the code you provide

    The output of Data::Dumper illustrates that quite well.

    If I gave you $wanted_second_number=9, how would you print $first_number=6?

    No really, look at the structure yourself before continuing.

    my @matching_recs = $grouped_by_num2{$wanted_second_number}; for my $rec (@matching_recs) { my $first_number = $rec->{FIRST_NUMBER}; print("$first_numner\n"); # 5, 6 }