Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: hash with both values and keys unique to each other

by perlkhan77 (Acolyte)
on Jul 12, 2012 at 19:19 UTC ( #981479=note: print w/ replies, xml ) Need Help??


in reply to Re: hash with both values and keys unique to each other
in thread hash with both values and keys unique to each other

This is how I was able to do it. But it might not be a generalized solution

$seen{$chr1}++; $seen{$chr2}++; if (($seen{$chr1}>1)||($seen{$chr2}>1)){ next; } else{ $hash_chr{$chr1}=$chr2; }


Comment on Re^2: hash with both values and keys unique to each other
Download Code
Re^3: hash with both values and keys unique to each other
by Anonymous Monk on Jul 12, 2012 at 22:14 UTC

    Since your structure is

    loop { if (condition) { next; } # no else! other code; }

    You don't actually need the else block. Removing it will make your code look quite a bit more clean.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (17)
As of 2014-07-23 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (152 votes), past polls