develooper Front page | perl.perl5.porters | Postings from February 2020

Re: "require" change of behavior in 5.16 or slightly before?

Thread Previous
From:
Dan Book
Date:
February 19, 2020 23:45
Subject:
Re: "require" change of behavior in 5.16 or slightly before?
Message ID:
CABMkAVUBkNrjb1VhrG0ffEyOX2hmS03s9AWT9wXQyw_fL9H7kA@mail.gmail.com
On Wed, Feb 19, 2020 at 6:33 PM Tony Cook <tony@develop-help.com> wrote:

> On Wed, Feb 19, 2020 at 06:23:32PM -0500, Dan Book wrote:
> > (2) The die will never happen for two reasons. || has higher precedence
> > than require, so it will be parsed as "require($config_file || die)" and
> > hopefully your $config_file is not "0". Also, require only ever returns
> > true or dies.
>
> tony@mars:.../git/perl$ perl -MO=Deparse,-p -e 'require $foo || die'
> ((require $foo) or die);
> -e syntax OK
>

I stand corrected, I would use the lower precedence 'or' for clarity in any
case (though as mentioned, the check is superfluous here).

-Dan

Thread Previous


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