Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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?


Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://421632]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2018-05-25 05:24 GMT
Find Nodes?
    Voting Booth?