Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Undiagnosable Problem

by dhannotte (Acolyte)
on Jan 14, 2017 at 15:37 UTC ( [id://1179566]=perlquestion: print w/replies, xml ) Need Help??

dhannotte has asked for the wisdom of the Perl Monks concerning the following question:

Last week my Perl interpreter suddenly started issuing a bizarre cascade of warnings every time I tried to run my 'sitegen.pl' script. These warnings claimed that every variable exported from my 'Plx.pm' library had already been defined. It then aborted the interpretation of 'sitegen.pl' entirely at the first invocation of one of these "multiply defined" functions.

My 'sitegen.pl' script begins with the following 4 "use" statements:

use Plx; # Programming Language Extensions use PlxHml; # HTML Macro Languages use PlxLang; # Language Services use strict 'vars';

'Plx.pm' exports 23 functions and begins:

package PLX; use attributes; use diagnostics; use strict 'vars'; use warnings; use Date::Calc; use Math::BigFloat; use Carp; $SIG{__WARN__} = \&carp; $SIG{__DIE__} = \&confess;

'PlxHml.pm' exports 1 function and begins:

package PLXHML; use PLX; use Carp; $SIG{__WARN__} = \&carp; $SIG{__DIE__} = \&confess;

'PlxLang.pm' exports 3 functions and begins:

package PLXLANG; use PLX; use Carp; $SIG{__WARN__} = \&carp; $SIG{__DIE__} = \&confess;

Each of the exported functions is unique. This structure has worked for years without error.

My Perl site lib contains the following files:

-------------------------------------------------------------------- c:\Perl64\site\lib()dir Volume in drive C is C-DRIVE Volume Serial Number is E812-30A4 Directory of c:\Perl64\site\lib 01/13/2017 07:34 AM <DIR> . 01/13/2017 07:34 AM <DIR> .. 09/02/2010 02:49 PM <DIR> auto 09/02/2010 02:49 PM <DIR> Image 01/13/2017 07:34 AM 161,042 Plx.pm 01/09/2017 04:33 PM 10,113 PlxHml.pm 01/11/2017 10:28 AM 15,241 PlxLang.pm 01/11/2017 10:27 AM 61,873 PlxSync.pm 01/27/2010 01:36 PM 31 sitecustomize.pl 12/26/2010 01:13 AM 106 test.pm 6 File(s) 248,406 bytes 4 Dir(s) 651,360,083,968 bytes free --------------------------------------------------------------------

The command I use to interpret sitegen.pl, and the first few and last few of the spurious errors, are:

-------------------------------------------------------------------- c:\!dh\dh\web\PRC\1()sitegen.pl Subroutine TRUE redefined at C:/Perl64/site/lib/PLX.pm line 280 (#1) (W redefine) You redefined a subroutine. To suppress this warning +, say { no warnings 'redefine'; eval "sub name { ... }"; } Subroutine TRUE redefined at C:/Perl64/site/lib/PLX.pm line 280. at C:/Perl64/site/lib/PlxHml.pm line 13 (#1) Subroutine TRUE redefined at C:/Perl64/site/lib/PLX.pm line 280. at C:/Perl64/site/lib/PlxHml.pm line 13 at C:/Perl64/site/lib/PlxHml.pm line 13 Subroutine FALSE redefined at C:/Perl64/site/lib/PLX.pm line 281 (#1) Subroutine FALSE redefined at C:/Perl64/site/lib/PLX.pm line 281. . . . Subroutine x_yyyy_mm_dd_hh_mm_ss redefined at (#2) line 3990 (#1) Subroutine x_yyyy_mm_dd_hh_mm_ss redefined at (#2) line 3990. at C:/Perl64/site/lib/PlxHml.pm line 13 Undefined subroutine &main::x_hh_mm_ss called at C:\!dh\dh\web\PRC\1\s +itegen.pl line 347. at C:\!dh\dh\web\PRC\1\sitegen.pl line 347 --------------------------------------------------------------------

Line 280 of Plx.pm is:

  sub TRUE      {1}

Line 13 of PlxHml.pm is:

  use PLX;

I suspect that there's a simple explanation for all this, but even after a decade of using Perl, I am unable to imagine what it is. Do these spurious errors ring a bell with anyone? The version of Perl I use is described by the following output from the 'perl -v' and 'perl -V' commands:

------------------- Output from perl -v ------------------- This is perl, v5.10.1 built for MSWin32-x64-multi-thread (with 2 registered patches, see perl -V for more detail) Copyright 1987-2009, Larry Wall Binary build 1007 [291969] provided by ActiveState http://www.Active +State.com Built Jan 27 2010 14:12:21 Perl may be copied only under the terms of either the Artistic Licen +se or the GNU General Public License, which may be found in the Perl 5 source +kit. Complete documentation for Perl, including FAQ lists, should be foun +d on this system using "man perl" or "perldoc perl". If you have access +to the Internet, point your browser at http://www.perl.org/, the Perl Home +Page. ------------------- Output from perl -V ------------------- Summary of my perl5 (revision 5 version 10 subversion 1) configurati +on: Platform: osname=MSWin32, osvers=5.2, archname=MSWin32-x64-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=u +ndef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -Ox -GL -Wp6 +4 -fp:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DWIN6 +4 -DCONSERVATIVE -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMP +LICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX' +, optimize='-MD -Zi -DNDEBUG -Ox -GL -Wp64 -fp:precise', cppflags='-DWIN32' ccversion='14.00.40310.41', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=123456 +78 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize= +8 ivtype='__int64', ivsize=8, nvtype='double', nvsize=8, Off_t='__ +int64', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf - +ltcg -libpath:"C:\Perl64\lib\CORE" -machine:AMD64' libpth=\lib libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.l +ib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib net +api32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.l +ib odbccp32.lib comctl32.lib bufferoverflowU.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspo +ol.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib + netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc +32.lib odbccp32.lib comctl32.lib bufferoverflowU.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -op +t:ref,icf -ltcg -libpath:"C:\Perl64\lib\CORE" -machine:AMD64' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_64_BIT +_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_SITECUSTOMIZE Locally applied patches: ActivePerl Build 1007 [291969] 0abd0d disable non-unicode case insensitive trie matching Built under MSWin32 Compiled at Jan 27 2010 14:12:21 @INC: C:/Perl64/site/lib C:/Perl64/lib . --------------------------------------------------------------------

I suppose I could reinstall ActivePerl, but they're no longer friendly to freeloaders like me and this might not succeed. I could try Strawberry Perl, but I don't have LINUX and managing it might be difficult. Before I descend into these circles of hell, I really hope that one of the wise elders here can offer me even a glimmer -- even just a smudgeon -- of insight. Thanks in advance.

Replies are listed 'Best First'.
Re: Undiagnosable Problem
by Athanasius (Archbishop) on Jan 14, 2017 at 16:09 UTC

    Hello dhannotte,

    I notice that you have use Plx in one place, use PLX in another and package PLX in a file named Plx.pm. I don’t know whether this is the problem, but it’s certainly bad practice: a module should have the same name as the package it contains, and these names are case sensitive (so it may be that the modules you’re actually loading are not the ones you think you’re loading).

    But I really wanted to comment on this statement:

    I could try Strawberry Perl, but I don't have LINUX and managing it might be difficult.

    Strawberry Perl is for Windows, it has nothing to do with Linux. And you can install a “portable zip” version of Strawberry Perl and run it independently of your other Perl distribution(s). BTW, why are you still using v5.10? The latest Strawberry Perl release is v5.24!

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: Undiagnosable Problem
by Corion (Patriarch) on Jan 14, 2017 at 16:16 UTC

    You say you have Plx.pm, but it states package PLX;.

    Most likely, you have PLX.pm and you have two use statements, one for use Plx; and one for use PLX;. You should only use the latter because Perl will happily redefine the names within the package PLX if you load a file "twice". Since Perl assumes that filenames are case-sensitive, it makes a difference between PLX.pm and Plx.pm even though your file system happily serves up the same file under these two names.

Re: Undiagnosable Problem
by 1nickt (Canon) on Jan 14, 2017 at 15:57 UTC

    Last week my Perl interpreter suddenly started issuing a bizarre cascade of warnings every time I tried to run my 'sitegen.pl' script

    This structure has worked for years without error.

    What change(s) did you make/did your system make last week?


    The way forward always starts with a minimal test.
Re: Undiagnosable Problem
by Anonymous Monk on Jan 14, 2017 at 17:08 UTC

    I think previous posters have hit the nail on the head: the name of the file, the name of the package that file declares, and the name specified in the use statement must agree in case, and you have several violations of this.

    I have found the Devel::TraceUse module useful in tracking down where modules are loaded, in case you have trouble finding them all.

      No, they aren't required to agree in case1, and that's precisely the most likely cause of the OP's problem. Because Windows filenames are case-insensitive, use PLX and use PLx both load the same source file, but the contents of that file are, of course, the same both times, leading to all of its contents being re-defined.

      1 The name of the file and the name of the package it contains aren't even required to be vaguely similar. Making them identical is just a convention to help preserve any sanity we programmers might possess, not an actual requirement.

        Thanks so much to all of you! I've learned a lot, even where there was disagreement about package and module naming rules.

        I'm definitely going to install portable Strawberry, but before I do I want to understand why Perl is barfing. All package and module name references are now in CamelCase (Plx, PlxHml and PlxLang), and all modules export their unique variable and subroutine names into main. None of the modules issue "use" statements, leaving that responsibility to the calling scripts that need the exported resources. I no longer get any "duplicate definition" warnings.

        BUT: Even though (thanks to "$Exporter::Verbose=1;"), I know that the x_log subroutine is being exported into main, I still get the following fatal error when I run a script that uses Plx, PlxHml and PlxLang:

        c:\()hml.pl Carp::EXPORT_FAIL cached: verbose &verbose at C:/Perl64/lib/Exporter/H +eavy.pm line 173. Importing into Carp from Carp: carp, confess, croak at C:/Perl64/lib/E +xporter/Heavy.pm line 192. Importing into main from Plx: $PLX_DIAGS, $PM_PLX, &FALSE, &LINE_LEN, +&MAX_SIGNED, &MAX_UNSIGNED, &MIN_SIGNED, &MIN_UNSIGNED, &NO, &NUMBER, + &STRING, &TRUE, &UND EFINED, &YES, &x_abort_retry_ignore, &x_as_dos_operand, &x_as_integer, + &x_as_power_of_1024, &x_as_string, &x_beep, &x_bytes, &x_bytes_free, + &x_caption_2_html, & x_caption_2_text, &x_cardinal, &x_cgi, &x_change_all, &x_con_exp, &x_c +onsole, &x_cookies, &x_current_dir, &x_current_drive, &x_decompile, & +x_dump, &x_dump_calle rs, &x_dump_diags, &x_dump_env, &x_dump_params, &x_elapsed_time, &x_em +ail_address_in_words, &x_env, &x_eta, &x_exp, &x_expand_filespec, &x_ +explore, &x_file, &x_ file_yyyymmdd, &x_file_yyyymmdd_hhmmss, &x_filetest, &x_flowerbox, &x_ +folder_is_an_archive, &x_format_date_and_time, &x_format_filetest_tim +e, &x_format_filetime , &x_format_rfc_822_date_and_time, &x_gallery, &x_get_parm, &x_get_str +ing, &x_goto, &x_hh_mm, &x_hh_mm_ss, &x_hhmm, &x_hhmmss, &x_in_bytes, + &x_in_gigabytes, &x_ in_kilobytes, &x_in_megabytes, &x_in_petabytes, &x_in_terabytes, &x_in +terpolate, &x_is_a_dir, &x_is_a_file, &x_is_drive_offline, &x_is_driv +e_online, &x_log, &x_ log_cgi, &x_log_cookies, &x_log_dir, &x_log_env, &x_log_error, &x_log_ +exp, &x_log_file, &x_log_prefix, &x_log_running, &x_logging_to_browse +r, &x_logging_to_cons ole, &x_logging_to_disk, &x_matches, &x_mm_dd_yyyy, &x_monitor, &x_not +ify, &x_option_list, &x_ordinal, &x_package_variables_in_javascript, +&x_parse_filespec, &x _parse_imgsrc, &x_pause, &x_percent, &x_prog_spec, &x_running, &x_sani +ty, &x_save, &x_seconds_have_elapsed, &x_signal, &x_sing_plur, &x_sof +t_breaks, &x_squeeze, &x_started_ended_taking, &x_status, &x_string_2_symbol, &x_system, &x +_time, &x_type, &x_user, &x_val, &x_val_style, &x_val_tab, &x_val_tru +nc, &x_with_commas, & x_words, &x_work_dir, &x_yes_or_no, &x_yyyy, &x_yyyy_mm_dd_hh_mm_ss, & +x_yyyymm, &x_yyyymmdd at C:\!dh\DH\COM\SRC\hml.pl line 206 main::BEGIN() called at (#2) line 206 eval {...} called at (#2) line 206 Undefined subroutine &PlxHml::x_log called at C:/Perl64/site/lib/PlxHm +l.pm line 47. Compilation failed in require at C:\!dh\DH\COM\SRC\hml.pl line 207. BEGIN failed--compilation aborted at C:\!dh\DH\COM\SRC\hml.pl line 207 +.

        What should I try now?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1179566]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found