[Za-pm] passing HoH refs to a sub
Oskar Pearson
oskar at qualica.com
Tue Jul 8 06:56:46 CDT 2003
Hi
Hope this helps.
There are various syntaxes that work, but I generally
use something like this:
#!/usr/bin/perl
my %hash;
$hash{first1}{second1} = 'hello';
$hash{first2}{second2} = 'world';
$hash{first3}{second3} = 1;
hash_display (\%hash);
sub hash_display {
my $hash = shift;
foreach my $key (keys %{ $hash }) {
foreach my $subkey (keys %{ $$hash{$key} }) {
print "key $key, subkey $subkey, " . $$hash{$key}{$subkey} . "\n";
}
}
}
:~$ perl t.pl
key first1, subkey second1, hello
key first2, subkey second2, world
key first3, subkey second3, 1
:~$
More information about the Za-pm
mailing list