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/





Relevant Pages

  • Re: Perl if statements evaluates wrongly if we use => as operator
    ... as the comma operator does not do comparisons... ... Perl is not doing anything "wrongly" here... ... Perl should throw proper compilation error ... You have valid syntax. ...
    (comp.lang.perl.misc)
  • Re: While query
    ... > always compiles the comma operator into the same ops: ... > two operators described in perlop will always produce the same results ... the Perl compiler is implemented and looking only at the observable ...
    (comp.lang.perl.misc)
  • Re: Parentheses in function calls
    ... although it's sometimes difficult to tell whether a particular comma is the comma operator or a list argument separator. ... array or associative array; ... This all works mostly because Perl functions don't really have multiple parameters - they have just one parameter of list type, so there's really no difference between ... (that is, unless xyzzy is prototyped such that the first argument is evaluated in scalar context, or (in the last case) ...
    (comp.lang.c)
  • Re: comma operator
    ... I'm reading up on perl today and find this in perldoc perlop: ... Binary "," is the comma operator. ...
    (comp.lang.perl.misc)