So it's a matter of merging hashes? You could use an iterator, perhaps something like the following:
#! /usr/bin/perl -l my $zoo = { Mountain => { Dragon => 'Deadly', Troll => 'Deadly', Nymph => 'Oread +', Snake => 'Deadly' }, Cave => { Dragon => 'Deadly', Spider => 'Poisonous', Troll => 'Deadl +y', Ogre => 'Deadly' }, Forest => { Elf => 'Dark', Troll => 'Deadly', Nymph => 'Alseid', Spi +der => 'Hairy' }, Lake => { Nymph => 'Naiad', Snake => 'Poisonous', Serpent => 'Deadly +' }, Sea => { Kraken => 'Monstrous', Serpent => 'Monstrous' } }; sub each_uniq { my @refs = @_; my %seen = (); sub { while (@refs) { my @pair = each %{$refs[0]} or shift @refs and next; return @pair unless $seen{$pair[0]}++; } return; } } my $iter = each_uniq(values %$zoo); print join(", ", $iter->()) for 1..5;

Update. I read the previous questions monkini has asked, and it would appear the problem is largely unrelated to questions asked. From what I gather, he has a number of clusters each with a number of (labelled) points, and distances between points given. The problem apparently is to list the pairs of points in a cluster sorted by their distance, for each cluster separately. If so, the solution is to map clusters to points (HoA), iterate, slice map slice sort the HoH, print.


In reply to Re: Until loop / unique by oiskuu
in thread Until loop / unique by monkini

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.