Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
There's more than one way to do things

Comment on


Keys in hashes are unique. The only way for a key to have multiple values is if the "value" is a reference to some container (an anonymous hash, anonymous array, or some object). Let's say your hash holds references to arrays. You might do this:

my %hash = ( unwanted => [1], wanted => [2, 3, 4] ); my $target_key = 'wanted'; if( exists $hash{ $target_key } && ref $hash{ $target_key } eq 'ARRAY' && @{ $hash{ $target_key } } > 1 ) { print "The element associated with $target_key holds a reference t +o an array of @{$hash{$target_key}} values.\n"; }


In reply to Re: Check if hash key value pair is defined by davido
in thread Check if hash key value pair is defined by reaper9187

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    As of 2014-03-14 03:27 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (297 votes), past polls