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

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

Thread Previous | Thread Next
Dan Book
February 19, 2020 23:23
Re: "require" change of behavior in 5.16 or slightly before?
Message ID:
On Wed, Feb 19, 2020 at 4:47 PM Philip Prindeville <> wrote:

> Hi,
> I have some build scripts that used to work in perl-5.10 and when we
> updated to perl-5.16 one in particular broke badly.
> It does a:
> require $config_file;
> and two observations: (1) if $config_file is an absolute path, it no
> longer finds the file (I can see from a security standpoint that not being
> able to include arbitrary files anywhere on the system might be good…), and
> (2) if I change that too “… || die …” then the die doesn’t happen.
> Were there changes along the way to how “require” behaves?  And what’s the
> workaround?

(1) seems like a different problem. An absolute path should always work.
However this seems more like a task for do(), which returns whatever the
specified file returns, though error checking for it is complex (see the
docs for do EXPR). require is designed to load modules (files that declare
a matching package namespace), such that calling it again on the same file
is a no-op.

(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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About