Terry,

Here is my understanding:

You can try defined function to verify the return value in List context, you 
can find the return value is (undef) instead of undef once the condition is 
false. Because you are using @result=&yoursubName instead of 
$result=&yoursubName.

Please correct me if I were wrong.

Just refer to chapter 3.7 in "Learning Perl" 4th Edition.

Thanks & Regards,

Alex Wang



-----Original Message-----
From: terry peng [mailto:terry.p...@mail.ru] 
Sent: Thursday, February 10, 2011 3:14 PM
To: beginners
Subject: Re[2]: about return




Wed, 9 Feb 2011 22:44:10 -0800 (PST) письмо от "C.DeRykus" <dery...@gmail.com>:

> On Feb 9, 10:07 pm, terry.p...@mail.ru (terry peng) wrote:
> > hello,
> >
> > when in the case "return undef" I prefer just "return" coz in list context
> it will return an empty list.
> >
> > my $exist = ...
> > if ($exist) {
> >     return 1;
> >
> > } else {
> >     return;
> > }
> >
> > the code above can work, but having many lines.
> > So I want:
> >
> > return $exist ? 1 : (...);
> >
> > what should be put in (...) to get the same effect as just "return" (not
> return undef)?
> >
> 
> return $exist ? 1 : ();
> 

Does return () in the caller's list context will return an undef?

regards.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to