I'm maintaining a few Perl scripts and recently I noticed that many of them output Subroutine ... redefined warnings from some "system" stuff, that is not from any code we've written.
A stripped down example I could come up now is:
#!perl -W
use strict;
use warnings;
use 5.14.0;
# These work without warnings:
use Carp;
use URI;
use POSIX;
# Any of these will generate warnings:
# use LWP; # Subroutine Config::STORE redefined at C:/local/Perl-5.32.1-64bit-portable/perl/vendor/lib/Portable/Config.pm line 68.
# use XML::LibXML; # Subroutine Config::STORE redefined at C:/local/Perl-5.32.1-64bit-portable/perl/vendor/lib/Portable/Config.pm line 68.
# use Win32::Service; # Subroutine Win32::GetCwd redefined at C:/local/Perl-5.32.1-64bit-portable/perl/lib/DynaLoader.pm line 210. (and 20!! more)
# ...
say "Hello world.";
Using Strawberry Perl 5.32.1 x64 ZIP/Portable on Windows 10. Also tested with Strawberry 5.14.
Run via portableshell.bat -> perl testscript.pl
I find it strange that so many "system" modules should generate these warnings, especially since I can't recall seeing these a few months back when I last did some maintenance work.
- Should I just suppress these warning?
- Is there anything else I can check?
C:\local\Perl-5.32.1-64bit-portable>perl -V
Summary of my perl5 (revision 5 version 32 subversion 1) configuration:
Platform:
osname=MSWin32
osvers=10.0.19042.746
archname=MSWin32-x64-multi-thread
uname='Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 15:00:15 2021 x64'
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
Compiler:
cc='gcc'
ccflags =' -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
optimize='-s -O2'
cppflags='-DWIN32'
ccversion=''
gccversion='8.3.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='long long'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='g++.exe'
ldflags ='-s -L"C:\local\Perl-5.32.1-64bit-portable\perl\lib\CORE" -L"C:\local\Perl-5.32.1-64bit-portable\c\lib"'
libpth=C:\local\Perl-5.32.1-64bit-portable\c\lib C:\local\Perl-5.32.1-64bit-portable\c\x86_64-w64-mingw32\lib C:\local\Perl-5.32.1-64bit-portable\c\lib\gcc\x86_64-w64-mingw32\8.3.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
libc=
so=dll
useshrplib=true
libperl=libperl532.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=xs.dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-mdll -s -L"C:\local\Perl-5.32.1-64bit-portable\perl\lib\CORE" -L"C:\local\Perl-5.32.1-64bit-portable\c\lib"'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
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
Built under MSWin32
Compiled at Jan 24 2021 15:05:42
@INC:
C:/local/Perl-5.32.1-64bit-portable/perl/site/lib
C:/local/Perl-5.32.1-64bit-portable/perl/vendor/lib
C:/local/Perl-5.32.1-64bit-portable/perl/lib
While trying to further narrow down my example script I finally figured this out:
Contrary to what I always believed, the shebang line in that specific form at the start of the script
#!perl -Wis interpreted even when running viaperl script.plfrom a Windows command prompt.And there we have:
If I remove the line (not needed in our Windows environment) or change it to
-w(lower case) then these warnings disappear.