monkini has asked for the wisdom of the Perl Monks concerning the following question:
For each of the five keys I have I'm retrieving the second key and corresponding value from a double hash - then I want to sort those according to value, and if there are any duplicates in 'second' keys, I want to retrieve another one, until all five 'second' keys are unique.
foreach my $k (keys %{$data[$i]}) { #5 keys my ($key, $val) = retrieve_kv($hash{$k}); ### CHECK IF UNIQUE - push to array and sort? ### REDO my ($key, $val) = retrieve_kv($hash{$k}) ### UNTIL ALL 5 ARE UNIQUE }
Any tips on how to structure the inner loop efficiently?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Until loop / unique
by oiskuu (Hermit) on Nov 12, 2013 at 00:42 UTC | |
|
Re: Until loop / unique
by Laurent_R (Canon) on Nov 11, 2013 at 22:58 UTC | |
by locked_user sundialsvc4 (Abbot) on Nov 12, 2013 at 02:04 UTC | |
|
Re: Until loop / unique
by LanX (Saint) on Nov 11, 2013 at 22:04 UTC | |
by monkini (Initiate) on Nov 11, 2013 at 22:14 UTC | |
by LanX (Saint) on Nov 11, 2013 at 22:17 UTC | |
by marinersk (Priest) on Nov 11, 2013 at 22:44 UTC | |
by Jim (Curate) on Nov 11, 2013 at 23:27 UTC | |
|
Re: Until loop / unique
by marinersk (Priest) on Nov 11, 2013 at 22:42 UTC |