Hi all,
I have a problem with a snippet of code. I'm trying to pass a hash as an
argument to a function. Below is some test code:
--- snip snip
use strict;
my %map = {
1 => 'one',
2 => 'two',
3 => 'three',
};
sub fun {
my $what = shift;
my %hash = @_;
print ("$what: ");
foreach my $k (keys (%hash)) {
print (" [$k]=[$hash{$k}]");
}
print ("\n");
}
# Why won't this work..
fun ("whatever", %map);
# But this will ?!
fun ("again",
'a' => 'first char', 'b' => 'second');
--- snip snip
What am I doing wrong (obviously near the comment mark "why won't this
work")? Any and all help will be appreciated!
Thanks in advance,
--
Karel Kubat <ka***@e-tunity.com, ka***@qbat.org>
Phone: mobile (+31) 6 2956 4861, office (+31) (0)38 46 06 125
PGP fingerprint: D76E 86EC B457 627A 0A87 0B8D DB71 6BCD 1CF2 6CD5
From the duffynitions collection:
Mistress: Something between a mister and a mattress.