develooper Front page | perl.perl5.porters | Postings from April 2010

Re: RFC: Perl manual pages -- update to follow the perlstyle.pod guidelines

Thread Previous | Thread Next
From:
Eric Brine
Date:
April 2, 2010 14:46
Subject:
Re: RFC: Perl manual pages -- update to follow the perlstyle.pod guidelines
Message ID:
t2uf86994701004021446s35fd6373ld27dc82af1c5c1a6@mail.gmail.com
On Fri, Apr 2, 2010 at 3:57 PM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:

> As Tom said, and and or are no safer than && and ||, they just have a
> different precedence. The `safer' part is when parens are left out
>
>  open (FOO, "foo.txt") || die $!;      OK
>  open  FOO, "foo.txt"  || die $!;      Wrong
>  open (FOO, "foo.txt") or die $!;      OK
>  open  FOO, "foo.txt"  or die $!;      OK
>

And neither is overall safer. One is safer is some circumstances, and the
other is safer in other circumstances. You demonstrated when "or" and "and"
are safer. Here's one where "&&" and "||" is safer:

my $both_successful = ( f() && g() );    OK
my $both_successful = f() && g();        OK
my $both_successful = ( f() and g() );   OK
my $both_successful = f() and g();       Wrong

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About