Perl Monk, Perl Meditation | |
PerlMonks |
Determining subroutine return typeby satchm0h (Beadle) |
on Feb 24, 2005 at 21:28 UTC ( [id://434264]=perlquestion: print w/replies, xml ) | Need Help?? |
satchm0h has asked for the wisdom of the Perl Monks concerning the following question:
Imagine you have a reference to a subroutine that may return a reference to a list, or a reference to a hash, or a list, or a hash.
If we were only getting references back, life would be good : What I need is some analog for non-reference return values. For instace, if the subroutine returns a list I don't want to evaluate it in scalar context and end up with the length. Can I only reflect on references and not on base types? Is there some way I can cast the return value of the subroutine to a reference on the fly; so that I may inspect it? UPDATE Thanks to all those who responded. Particularly phaylon, friedo, and ikegami. As I stated below, I'm basiclly trying to pass through the return value of the subroutine reference. Here is the "final" proof of concept. If you are interested in seeing the code I used to test this routine, drop me a line and I'll add it.
Back to
Seekers of Perl Wisdom
|
|