Re: Check if a given function returns something



"M" == Mk <halfcountplus@xxxxxxxxxxxxx> writes:

M> On 02/27/2008 02:59:30 AM, vijay krishna wrote:
-> I want to check if a sub routine that I am calling
-> returns a value or not.
-> This is how my code is
-> $str = function(parameter)
->
-> the sub routine function in turn uses many other function. Some of
-> these functions have a return statement and some do not.
->
-> So, when i invoke the sub routine "function" and i pass the returned
-> value into $str, I need to check if $str has any value assigned or
-> not.

M> Well the guaranteed way to accomplish this is to just call the function
M> AND THEN assign your variable within that function:

M> # do not "use strict"

what the hell does strict have to do with anything in that request?

M> function(parameter);

M> sub function {
M> .... # call as many more functions as you want
M> ....
M> $str=????; # do not use "my $str"

where is that supposed to be declared? your comment above is wrong and
this comment is confusing.

M> }

M> A subroutine/function does not require a return statement and using one
M> probably will not help you assign a scalar value. The purpose of
M> return is to exit the subroutine at some arbitrary point and the return
M> value is limited (usually to indicate "success" or "failure").

huh??? i can return a list or a reference to an entire freshly allocated
tree. who only returns boolean results??


M> Again, i believe YOU ARE MISCONCEPTUALIZING with "$str =
M> function(parameter);".

and YOU ARE VERY CONFUSED about what and how you use return.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Architecture, Development, Training, Support, Code Review ------
----------- Search or Offer Perl Jobs ----- http://jobs.perl.org ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.