skazat has asked for the wisdom of the Perl Monks concerning the following question:
i'm havng trouble passing a hash to a function. i made this little script to figure it out:
<p><pre> #!/usr/bin/perl -w use CGI qw(:standard); use strict; my %yummy = ( "banana" => 'yellow', "apple" => 'green', "tangerine" => 'orange' ); print_hash(\%yummy); sub print_hash { my $food = $_[0]; my %hash = %$food; my $key; my $value; foreach $key (keys %hash) { print $value = $hash{$key}; print "fruit: $key is $value\n\n"; } }
and this is what i get back:
yellowfruit: banana is yellow
greenfruit: apple is green
orangefruit: tangerine is orange
what in the world is going on?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing hashes to a function
by chromatic (Archbishop) on May 09, 2000 at 22:26 UTC | |
|
Re: passing hashes to a function
by btrott (Parson) on May 09, 2000 at 22:31 UTC | |
|
Re: passing hashes to a function
by BBQ (Curate) on May 10, 2000 at 08:54 UTC | |
by perlmonkey (Hermit) on May 10, 2000 at 09:17 UTC | |
by btrott (Parson) on May 10, 2000 at 09:04 UTC | |
|
Re: passing hashes to a function
by skazat (Chaplain) on May 10, 2000 at 00:33 UTC |