in reply to Re: Re(ALL): Putting it together
in thread H of A optimization

Well, in that case...

my (%edge, @seen); while (<STDIN>) { $seen[$2]++ or push @{$edge{$1}}, $2 if /(\d+)\D+(\d+)/; # push @{$edge{$1}}, $2 if /(\d+)\D+(\d+)/ and not $seen[$2]++; }

— Arien

Edit: added the commented alternative.