A hash key ($nas) is nothing more than a key and it has a corresponding value in the hash. That value may be a reference to another data structure (an anonymous hash). That anonymous hash may have one or more keys ($response_status). Your confusion is in thinking that there is only one possible value in the anonymous hash. In reality, it may have one or more keys. I would suggest the following code instead:
You may need to modify it a little if it is possible for a MAC to have more than one status and request date. If that is the case then you need to take some time in figuring out how to ask a question.#!/usr/bin/perl use strict; use warnings; use constant STATUS => 0; use constant REQUEST => 1; # Some code that initializes %list # In the form # $list{ $nas }[STATUS] = $response_status; # $list{ $nas }[REQUEST] = $request_date_time # Later on you can retrieve the status and request like my $mac = ''; # actual code to get MAC from log my $status = $list{ $mac }[STATUS]; my $request = $list{ $mac }[REQUEST];
List of links added after initial post
Cheers - L~R
In reply to Re: How do I load a hash table?
by Limbic~Region
in thread How do I load a hash table?
by rjsaulakh
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |