Re: Check if a given function returns something
- From: halfcountplus@xxxxxxxxxxxxx (Mk)
- Date: Thu, 28 Feb 2008 19:28:15 -0500
On 02/27/2008 02:59:30 AM, vijay krishna wrote:
-> Hi All,
-> 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)
->
-> sub function
-> {
-> ........
-> ......
-> ........
-> }
->
-> 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.
->
-> Can you tell me how I could accomplish this?
Well the guaranteed way to accomplish this is to just call the function AND THEN assign your variable within that function:
# do not "use strict"
function(parameter);
sub function {
.... # call as many more functions as you want
....
$str=????; # do not use "my $str"
}
A subroutine/function does not require a return statement and using one probably will not help you assign a scalar value. The purpose of return is to exit the subroutine at some arbitrary point and the return value is limited (usually to indicate "success" or "failure").
Again, i believe YOU ARE MISCONCEPTUALIZING with "$str = function(parameter);".
.
- Follow-Ups:
- Re: Check if a given function returns something
- From: Tom Phoenix
- Re: Check if a given function returns something
- From: Uri Guttman
- Re: Check if a given function returns something
- References:
- Check if a given function returns something
- From: Vijay Krishna
- Check if a given function returns something
- Prev by Date: Re: Data file from one format to another.
- Next by Date: Re: Check if a given function returns something
- Previous by thread: Re: Check if a given function returns something
- Next by thread: Re: Check if a given function returns something
- Index(es):