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);".

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to