Scarborough has asked for the wisdom of the Perl Monks concerning the following question:
I have a sub routine which returns a HASH reference to a data structure as follows
In the calling program I can dereference the hash no problem.$myhash{$key}->($value1, $value2)
However when I pass the same $ref to a sub routineforeach $key (%$ref){ ($value1, $value2)= @$ref{$key} ##do something... }
Does not work. Where am I going wrong? Thanks.mysub($ref); sub mysub{ my $param = (@_); foreach $key (%$param){ ($value1, $value2)= @$param{$key} ##do something... } }
Updated for Tomte, yes it was a typo in the posting sorry!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A dereferencing problem
by gnork (Scribe) on Apr 29, 2004 at 09:41 UTC | |
|
Re: A dereferencing problem
by dave_the_m (Monsignor) on Apr 29, 2004 at 12:11 UTC | |
|
Re: A dereferencing problem
by Tomte (Priest) on Apr 29, 2004 at 09:24 UTC | |
by Scarborough (Hermit) on Apr 29, 2004 at 09:49 UTC | |
by Tomte (Priest) on Apr 29, 2004 at 10:09 UTC | |
|
Re: A dereferencing problem
by periapt (Hermit) on Apr 29, 2004 at 13:38 UTC | |
|
Re: A dereferencing problem
by revdiablo (Prior) on Apr 29, 2004 at 16:53 UTC | |
by periapt (Hermit) on Apr 29, 2004 at 19:03 UTC | |
by revdiablo (Prior) on Apr 29, 2004 at 23:14 UTC |