Description
Setting ${^HOOK}{require__before} to any coderef (even just sub{}), then calling require(some_non_constant_function()), produces a Use of uninitialized value in require warning.
Steps to Reproduce
Two files:
One.pm:
package One;
use v5.42;
sub path_for($f) { $f =~ s{::}{/}g; "${f}.pm" }
sub import {
my ($class,$name)=@_;
require(path_for($name));
}
then:
perl -I . -E '${^HOOK}{require__before} = sub {}; require One;One->import(shift)' Carp
will print:
Use of uninitialized value in require at One.pm line 8.
Furthermore:
- not all package names produce the warning (I can't find a pattern)
- these warn: Carp, Cwd, open, Test, Test2
- these don't: FindBin, charnames, Data::Dumper
- a non-existed package will cause the "uninitialized" warning to be printed before the
Can't locate … error
- replacing the
require line with require(my $p=path_for($name)) makes the warning go away (this is why I mentioned mortals in the title)
Expected behavior
No warnings.
Perl configuration
Summary of my perl5 (revision 5 version 42 subversion 1) configuration:
Platform:
osname=linux
osvers=6.18.12-gentoo-x86_64
archname=x86_64-linux-thread-multi
uname='linux exelion 6.18.12-gentoo-x86_64 #6 smp preempt_dynamic tue mar 10 14:00:33 gmt 2026 x86_64 11th gen intel(r) core(tm) i7-1185g7 @ 3.00ghz genuineintel gnulinux '
config_args='-de -Dprefix=/home/dakkar/perl5/perlbrew/perls/perl-5.42.1 -Dusethreads -Aeval:scriptdir=/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/bin'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
optimize='-O2'
cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
ccversion=''
gccversion='15.2.1 20260214'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib /lib64 /usr/lib64 /lib /usr/local/lib64
libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=/lib/../lib64/libc.so.6
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.42'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_STRTOLD
HAS_TIMES
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_REENTRANT_API
USE_THREAD_SAFE_LOCALE
Built under linux
Compiled at Mar 19 2026 13:59:22
%ENV:
PERLBREW_HOME="/home/dakkar/.perlbrew"
PERLBREW_MANPATH="/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/man"
PERLBREW_PATH="/home/dakkar/perl5/perlbrew/bin:/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/bin"
PERLBREW_PERL="perl-5.42.1"
PERLBREW_ROOT="/home/dakkar/perl5/perlbrew"
PERLBREW_SHELLRC_VERSION="0.88"
PERLBREW_VERSION="1.02"
PERLDOC="-MPod::Text::Color::Delight"
@INC:
/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/lib/site_perl/5.42.1/x86_64-linux-thread-multi
/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/lib/site_perl/5.42.1
/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/lib/5.42.1/x86_64-linux-thread-multi
/home/dakkar/perl5/perlbrew/perls/perl-5.42.1/lib/5.42.1
Description
Setting
${^HOOK}{require__before}to any coderef (even justsub{}), then callingrequire(some_non_constant_function()), produces aUse of uninitialized value in requirewarning.Steps to Reproduce
Two files:
One.pm:then:
will print:
Furthermore:
Can't locate …errorrequireline withrequire(my $p=path_for($name))makes the warning go away (this is why I mentioned mortals in the title)Expected behavior
No warnings.
Perl configuration