Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I load a hash table?

by edan (Curate)
on Jan 12, 2005 at 15:22 UTC ( #421632=note: print w/ replies, xml ) Need Help??


in reply to How do I load a hash table?

Maybe I'm totally misunderstanding you, but I'm envisioning that you have a HoH structure like this:

my %macs = ( '00:11:22:33:44:55' => { 'response_status' => 12, 'response_date' => 'yesterday', }, 'AA:BB:66:12:13:14' => { 'response_status' => 0, 'response_date' => '2004-12-31', }, # ... and so on );

And you get some user input, then you look up the data you want:

my $mac = <STDIN>; chomp $mac; if ( exists $macs{$mac} ) { print "Okay, found mac $mac:\n"; print "response_status: $macs{$mac}{response_status}\n"; print "response_date: $macs{$mac}{response_date}\n"; } else { print "Sorry, don't recognize that mac\n"; }

Is that what you meant?

--
edan


Comment on Re: How do I load a hash table?
Select or Download Code
Re^2: How do I load a hash table?
by rjsaulakh (Beadle) on Jan 12, 2005 at 15:35 UTC
    yes edan i think ur an excellent guy that is what iwant store the mac address , it corresponding staus n response date. then take input from user check the mac id see if it is there , if it there then compare it status with "0" if successful i then want to print the mac , its status n date .. guide me

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2014-08-01 15:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (25 votes), past polls