in reply to Check for existance in a hash of hashes

Not sure exactly what wasn't working for you, but the following edit works per your specification.

#!/usr/bin/perl

my $skip_users = &get_data;
&print_data;

sub get_data
{
    my %skip_users;
    my $skip_id = 'fred';
    my $value = 'ethel';
    #build a hoh with userid and value.
    $skip_users{$skip_id}{$value}++;

    return(\%skip_users);
}

sub print_data
{
    my %hoh = %$skip_users;
    my $user = 'fred';
    my $command = 'thel';
    if ((exists $hoh{$user}) && (exists $hoh{$user}{$command})) {
        print "yep\n";
    } else {
        print "nope\n";
    }
}
  • Comment on Re: Check for existance in a hash of hashes