Re: Check if a given function returns something



On Wed, Feb 27, 2008 at 3:59 PM, vijay krishna <vijaygos@xxxxxxxxx> wrote:

the sub routine function in turn uses many other function. Some of these functions have a return statement and some do not.


The caller doesn't care about what were enclosed in that function.
I need only the last returned value from the called function.

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.


my $str = myFunction(parameter);

if (defined $str) {
...
} else {
...
}

Also you need to take care if the function returns a list or a scalar.
for a list returned value you need to say:

my @str = myFunction(parameter);
.



Relevant Pages

  • Re: {OT:} Glenn Beck REALLY loses it
    ... the caller was pretty much correct on that one. ... care she needed and France footed the bill. ... We will have high costs and poor service. ...
    (alt.autos.toyota)
  • Re: [PATCH 09/22] Calculate the alloc_flags for allocation only once
    ... Without care, this would allow recursion into the allocator via direct ... +static inline int ... Only because it was known there was only one caller. ... Uninline gfp_to_alloc_flagsin the page allocator slow path ...
    (Linux-Kernel)
  • Re: [PATCH] leds: Further document parameters for blink_set()
    ... It was done so the caller could find out what timings the underlying ... hardware decided to chose if it couldn't match the timings specified ... This should be better documented and I'll take care of that. ...
    (Linux-Kernel)
  • Re: do visiting children ever answer your phone?
    ... With the advent of caller ID, call blocking and other great new ... from people I know -- and that means if you have your outgoing number ... Children won't care how much you know until they know how much you care ...
    (misc.kids)
  • Re: [PATCH 2.6.20] kobject net ifindex + rename
    ... And it will need fixing in probably ... somebody with a better knowledge of this place could verify ... So, I guess, a caller ... that the caller does not care. ...
    (Linux-Kernel)