in reply to Access the Keys of a Hash Reference Without a For Loop

exists $ipsAll->{$key} will return 1 (true) if the key exists. If you need to get a list of the keys, umasuresh's answer is what you want. Also, be careful about using exists on nested hash references, since the -> operator will create intervening values.
my %hash = ('foo' => 'foo'); my $ref = \%hash; print exists $ref->{'foo'}; #Prints 1 (true) print exists $ref->{'bar'}->{'baz'}; #Prints nothing (false) print exists $ref->{'bar'}; #Prints 1 (true)

Replies are listed 'Best First'.
Re^2: Access the Keys of a Hash Reference Without a For Loop
by Dru (Hermit) on Nov 01, 2010 at 18:44 UTC
    Thanks wink, I was just about to post to say I realized my code was actually correct and it will print out 1 (meaning it's true) if there was a match, basically what you said.

    Thanks,
    Dru

    Perl, the Leatherman of Programming languages. - qazwart