Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
(tye)Re: How do I get a reference to a subroutine return value?by tye (Sage) |
on Mar 03, 2001 at 11:48 UTC ( [id://61993]=note: print w/replies, xml ) | Need Help?? |
If $query is a CGI.pm object, then the best way is probably:
(with many more parameters) Oh, well, then you probably want this instead:
For the more general problem of "How do I get a reference to a subroutine return value?" (which I thought was an interesting question so I did some investigating), the answer is "you can't". You can get a reference to copies of subroutine return values via:
So if you follow the advice of those who answered before me but part of your unstated goal was to allow the subroutine to modify the parameters such that $query would notice the modifications, then you will fail because those array references will only allow you to modify copies of those values. The methods I suggested will allow myfunc to modify the CGI parameters directly. This can certainly be a disadvantage if you wanted myfunc to be able to futz with those arrays without affecting the CGI $query object. - tye (but my friends call me "Tye")
In Section
Seekers of Perl Wisdom
|
|