Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Does hash contain minimum keys?

by emshach (Initiate)
on Dec 13, 2016 at 21:46 UTC ( #1177739=note: print w/replies, xml ) Need Help??

in reply to Does hash contain minimum keys?

In this example %required doesn't need to be a hash, and since that's what you're checking against, that's what you should search. You could also use prototyping to avoid building a whole new hash each time, so we'd end up with something like:

sub test_it (\%) { my ($h) = @_; return (keys (%$h) >= @required && !grep { !defined($h->{$_}) } @required); # return true if the list of missing required keys is empty }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2019-04-21 00:55 GMT
Find Nodes?
    Voting Booth?
    I am most likely to install a new module from CPAN if:

    Results (110 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!