Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Check for existance in a hash of hashes

by moebius (Novice)
on Mar 27, 2002 at 18:55 UTC ( [id://154763]=note: print w/replies, xml ) Need Help??


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";
    }
}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found