Re: about a statement



comma operator has a higher precedence than 'or' operator,
so when require fails, eval returns undef and perl will
continue to set the status then return 0,

so your rewritten code will work exactly the same as the original code.

On Wed, Apr 16, 2008 at 9:02 PM, Jennifer G. <practicalperl@xxxxxxxxx>
wrote:

what's this statement?

eval {
require MIME::Base64;
require Authen::SASL;
} or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL
todo auth"]), return 0;

why ', return 0' can be used? I think maybe it should be ';' instead of
',' .
Can I rewrite it as below?

eval {
require MIME::Base64;
require Authen::SASL;
};

if ($@) {
$self->set_status(500, ["Need MIME::Base64 and Authen::SASL todo
auth"]);
return 0;
}

Thanks!

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