Re: Check if a given function returns something
- From: pangj@xxxxxxxxxxxxx (Jeff Pang)
- Date: Wed, 27 Feb 2008 16:05:15 +0800
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);
.
- References:
- Check if a given function returns something
- From: Vijay Krishna
- Check if a given function returns something
- Prev by Date: Check if a given function returns something
- Next by Date: How to read from keyboard?
- Previous by thread: Check if a given function returns something
- Next by thread: Re: Check if a given function returns something
- Index(es):
Relevant Pages
|