Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: extracting only those keys with uniq values in array list

by v15 (Sexton)
on Apr 20, 2021 at 14:08 UTC ( #11131513=note: print w/replies, xml ) Need Help??


in reply to Re: extracting only those keys with uniq values in array list
in thread extracting only those keys with uniq values in array list

I agree with you. I edited the question so hopefully it makes more sense. Thanks
  • Comment on Re^2: extracting only those keys with uniq values in array list

Replies are listed 'Best First'.
Re^3: extracting only those keys with uniq values in array list
by BillKSmith (Prior) on Apr 20, 2021 at 15:11 UTC
    Thanks for the clarification. Build the hash exactly as you show. Process the keys with grep
    use strict; use warnings; my %r_name = ( a => [ 1, 2 ], b => [ 3, 3 ], c => [ 1, 6 ], ); my @result = grep {$r_name{$_}[0] eq $r_name{$_}[1]} keys %r_name; print @result, "\n";

    Result

    b

    Note for next time: It is considered impolite to edit your post in a way that invalidates existing replies. Leave the existing text. Add a clearly marked UPDATE section.

    Bill
Re^3: extracting only those keys with uniq values in array list
by AnomalousMonk (Bishop) on Apr 20, 2021 at 21:34 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2021-06-21 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (98 votes). Check out past polls.

    Notices?