Re: create multiple hash
- From: peng.kyo@xxxxxxxxx (J. Peng)
- Date: Fri, 21 Mar 2008 18:53:03 +0800
creating a multiple hash is the same as you create a common hash.
you can do,
my %value;
$value{'172.16.1.45'} = {'google' => 34};
$value{'172.15.2.34'} = {'yahoo' => 45};
etc.
to show the hash structure, use Data::Dumper:
use Data::Dumper;
print Dumper \%hash;
to print the hash, use a for loop:
for my $outkey (keys %hash) {
for my $inkey (keys %{$hash{$outkey}}) {
print $inkey, ": ", $hash{$outkey}->{$inkey},"\n";
}
}
Not tested it.Good luck.
Regards,
Jeff (Joy) Peng
On Fri, Mar 21, 2008 at 6:33 PM, sivasakthi <msivasakthi@xxxxxxxxx> wrote:
Hi all,.
I want to create multiple hash and retrieve the values for print like
below ,
%values= (
'172.16.1.45' => {'google.com' => 34, 'linux.com' => 45},
'172.15.2.34' => {'hp.com' => 345, 'oracle.com' => 4567},
);
how to do that?
Thanks,
- References:
- create multiple hash
- From: Sivasakthi
- create multiple hash
- Prev by Date: perl on win32
- Next by Date: Re: contributing to perl
- Previous by thread: create multiple hash
- Next by thread: perl on win32
- Index(es):