[Za-pm] passing HoH refs to a sub
Spike
spikeh at mweb.co.za
Tue Jul 8 08:30:43 CDT 2003
Thanks - I was getting quite frustrated trying to get that right!
At 2003/07/08 01:56 PM, Oskar Pearson wrote:
>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
>:~$
>
>_______________________________________________
>Za-pm mailing list
>Za-pm at mail.pm.org
>http://mail.pm.org/mailman/listinfo/za-pm
Spike Hodge
UNIX Programmer
M-Web Technology
021 596 8496
082 901 5265
Click here and make M-Web your homepage
http://homepage.mweb.co.za
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/za-pm/attachments/20030708/42019328/attachment.htm
More information about the Za-pm
mailing list