pshangov has asked for the wisdom of the Perl Monks concerning the following question:
and this will work for in the following cases:sub myfunc (\[$@%]) {}
but will not work for expressions that evaluate to hasrefs/arrayrefs, such as:myfunc %hash; myfunc @array; myfunc $hashref; myfunc $arrayref;
Is there some way to have the best of both worlds and have both styles work? I was thinking about multiple dispatch or somehow wrapping myfunc in eval so that prototypes do not blow up, but I have no clear idea really how to go about it.myfunc \%hash; myfunc \@array; myfunc { key => 'value', key => 'value'}; myfunc [ 'value', 'value' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by SuicideJunkie (Vicar) on Jun 19, 2009 at 14:30 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by rovf (Priest) on Jun 19, 2009 at 14:31 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by pileofrogs (Priest) on Jun 19, 2009 at 17:01 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by dsheroh (Monsignor) on Jun 19, 2009 at 16:46 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by ikegami (Patriarch) on Jun 19, 2009 at 14:57 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by jandrew (Chaplain) on Jun 19, 2009 at 16:45 UTC | |
by Porculus (Hermit) on Jun 19, 2009 at 18:38 UTC | |
|
Re: Function that accepts both hashes/arrays and hashrefs/arreyrefs
by Zarchne (Novice) on Jun 20, 2009 at 04:56 UTC |