Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by BillKSmith (Monsignor)
on Apr 20, 2021 at 15:11 UTC ( #11131515=note: print w/replies, xml ) Need Help??


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

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-24 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?