Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Check if keys of hash is values of another hash!

by kennethk (Abbot)
on Jul 15, 2014 at 18:46 UTC ( [id://1093759]=note: print w/replies, xml ) Need Help??


in reply to Check if keys of hash is values of another hash!

First, please make sure posted code compiles. Ignoring your pseudocode, you are missing a sigil on line 16 and a comma on line 22 and a curly bracket on line 31. See How do I post a question effectively?.

If a defined condition is sufficient (rather than exists), then you can easily perform the check with a grep and Slices:

if(grep defined, @line{@{$new{a}}}) #need this condition
Otherwise, it's probably easiest to loop over the array ref:
my $seen = 0; for my $val ( @{$new{a}} ) { $seen++ if exists $line{$val}; } if($seen) {#need this condition do something } else { do something }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found