in reply to passing hashes to a function
is setting $value equal to $hash{$key}, which is probably what you want; and is then printing the value of that statement. And the value is $value.print $value = $hash{$key};
So, when $value is "green", for example, that's why you're seeing "greenfruit". "green" and "fruit" are actually coming from different print statements.
Does that make sense? Is that the problem you were having?
To fix that, of course, just take out print, leaving the
Or, of course, you could just get rid of that line altogether and put $hash{$key} into the real print statement:$value = $hash{$key};
Your choice.print "fruit: $key is $hash{$key}\n\n";
|
|---|