>>>>> "AW" == Alex Wang02 <alex_wan...@infosys.com> writes:
AW> Terry, AW> Here is my understanding: AW> You can try defined function to verify the return value in List AW> context, you can find the return value is (undef) instead of undef AW> once the condition is false. Because you are using AW> @result=&yoursubName instead of $result=&yoursubName. that is wrong. a plain return in list context returns an empty list. calling defined on that makes no sense. you test that by checking the length of the returned list (put the array in scalar context). look at this example closely: sub foo { return } sub bar { return undef } my $has_foo = foo() ; my @has_foos = foo() ; my $has_bar = bar() ; my @has_bars = bar() ; my ( $foo ) = foo() ; my ( $bar ) = bar() ; my ( $foo2 ) = bar() ; my ( $bar2 ) = foo() ; now tell me what values will be in each of the vars? use Data::Dumper to verify your answers. the final question is can you tell what kind of return was executed in the last four cases? note that i swapped the calls in the last two. this is tricky and subtle and very important to know. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/