On 02-04-08 11:40:52 CEST, Michael Bell wrote:
> Marcel Juffermans schrieb:
> > 
> > In OpenSSL.pm there is a code snippet:
> > 
> > if( not(defined($outfile)) || $outfile eq "" ) {
> >   <snip/>
> > } else {
> >   <snip/>
> > }
> > 
> > This doesn't seem to work as expected - if $outfile is undefined, then the
> > else clause is taken.
> > 
> > It works as expected if the condition is changed to use 'or' instead of
> > '||':
> > 
> > if( not(defined($outfile)) or $outfile eq "" )
> > 
> > or even just:
> > 
> > if( !$outfile )
> > 
> > I'm not a Perl expert, but this seems weird behaviour to me. We're using
> > Perl version 5.005_03 on Linux and Solaris, but I've also reproduced this
> > behaviour on 5.001. I first thought it might be operator precedence, but eq
> > has higher precedence than ||, so that can't be it.
> 
> This is a mistake related to the very high precedence of ||. || and "or"

no, it is not.
both "or" and "||" have lower precedence than "eq".
perl's behaviour has changed.
with 5.6.1 the if block is executed, with 5.005_03 the else block.

my guess is that the opening parenthesis after the "not" (which is a
quite new operator) is not detected properly in older perls, so that it
effectively becomes

if( not((defined($outfile)) || $outfile eq "")) {

(i've never noticed that before, but i wouldn't mix and/or/not with
&&/||/! anyway...)

rj

_______________________________________________
OpenCA-Devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/openca-devel

Reply via email to