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

Hi,

Having a bit of a problem with Perl, which I have running on a server on a standalone network. Whilst installing Bugzilla, I was manually installing all the required modules and then had problems with the checksetup.pl script looking in the wrong places for *.pm files. Stupidly I copied the *.pm files and related folders to where it was looking, instead of linking it properly, and obviously this didn't work. I then deleted the folders and files I had copied and now every Perl script I try to run fails compilation (see example error message output below). It doesn't matter whether it is the checksetup.pl script, Makefile.pl scripts or even some of the cron jobs we have running on the server, they all throw up the same sort of error. I have googled this, and spent a while trawling through the results. A few people seem to have had similar problems, but not with the same reasons, but there doesn't seem to be an answer in how to fix it anywhere. Is there some some sort of library that holds all the installed modules that could have been changed? Or am I missing something really obvious?

Example error messages:

Global symbol "$VERSION" requires explicit package name at /usr/lib/pe +rl5/5.8.8/File/Spec.pm line 6. Global symbol "$VERSION" requires explicit package name at /usr/lib/pe +rl5/5.8.8/File/Spec.pm line 7. Global symbol "$VERSION" requires explicit package name at /usr/lib/pe +rl5/5.8.8/File/Spec.pm line 7. Global symbol "@ISA" requires explicit package name at /usr/lib/perl5/ +5.8.8/File/Spec.pm line 23. Compilation failed in require at /usr/lib/perl5/5.8.8/Carp.pm line 318 +. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/Carp.pm line + 318. Compilation failed in require at /usr/lib/perl5/5.8.8/warnings.pm line + 134. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/warnings.pm +line 134. Compilation failed in require at /usr/lib/perl5/5.8.8/warnings/registe +r.pm line 24. Compilation failed in require at /usr/lib/perl5/5.8.8/vars.pm line 7. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/vars.pm line + 7. Compilation failed in require at /usr/lib/perl5/5.8.8/ExtUtils/MakeMak +er/Config.pm line 9. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/ExtUtils/Mak +eMaker/Config.pm line 9. Compilation failed in require at /usr/lib/perl5/5.8.8/ExtUtils/MakeMak +er.pm line 7. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/ExtUtils/Mak +eMaker.pm line 7. Compilation failed in require at Makefile.PL line 1. BEGIN failed--compilation aborted at Makefile.PL line 1.
Use of uninitialized value in vec at /usr/lib/perl5/5.8.8/warnings/reg +ister.pm line 31. Use of uninitialized value in vec at /usr/lib/perl5/5.8.8/warnings/reg +ister.pm line 41. Use of uninitialized value in vec at /usr/lib/perl5/5.8.8/warnings/reg +ister.pm line 41. Use of uninitialized value in scalar assignment at /usr/lib/perl5/5.8. +8/warnings/register.pm line 41. Use of uninitialized value in vec at /usr/lib/perl5/5.8.8/warnings/reg +ister.pm line 47. Use of uninitialized value in scalar assignment at /usr/lib/perl5/5.8. +8/warnings/register.pm line 47. Array found where operator expected at /usr/lib/perl5/5.8.8/Carp.pm li +ne 484, at end of line (Do you need to predeclare Carp::longmess?) Array found where operator expected at /usr/lib/perl5/5.8.8/Carp.pm li +ne 485, at end of line (Do you need to predeclare Carp::shortmess?) Array found where operator expected at /usr/lib/perl5/5.8.8/Carp.pm li +ne 486, at end of line (Do you need to predeclare Carp::shortmess?) Array found where operator expected at /usr/lib/perl5/5.8.8/Carp.pm li +ne 487, at end of line (Do you need to predeclare Carp::longmess?) syntax error at /usr/lib/perl5/5.8.8/Carp.pm line 484, near "Carp::lon +gmess @_" syntax error at /usr/lib/perl5/5.8.8/Carp.pm line 485, near "Carp::sho +rtmess @_" syntax error at /usr/lib/perl5/5.8.8/Carp.pm line 486, near "Carp::sho +rtmess @_" syntax error at /usr/lib/perl5/5.8.8/Carp.pm line 487, near "Carp::lon +gmess @_" Compilation failed in require at /usr/lib/perl5/5.8.8/warnings.pm line + 134. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/warnings.pm +line 134. Compilation failed in require at /usr/lib/perl5/5.8.8/File/Basename.pm + line 52. BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/File/Basenam +e.pm line 52. Compilation failed in require at checksetup.pl line 47. BEGIN failed--compilation aborted at checksetup.pl line 47.

Thanks for any help in advance

Replies are listed 'Best First'.
Re: Every Perl Script Is Failing Compilation
by Marshall (Canon) on Sep 02, 2009 at 19:22 UTC
    Look like something has gotten botched up in @INC or %INC. In your first error message, with Spec.pm, in first few lines of that module:
    use strict; use vars qw(@ISA $VERSION); $VERSION = '3.2501'; $VERSION = eval $VERSION;
    If use vars doesn't work right, then $VERSION won't have package scope and you will get the type of message that you are seeing. vars.pm in Perl/lib does some major mojo. If this doesn't work, you are screwed! Try running the following and compare with your reference system.
    print "INC PATHs\n"; foreach (@INC) { print "$_\n"; } print "\n\n"; print "INC HASH\n"; foreach (keys %INC) { print "$_ => $INC{$_}\n"; }
    My Win XP box gives:
    INC PATHs C:/Perl/site/lib C:/Perl/lib . INC HASH warnings/register.pm => C:/Perl/lib/warnings/register.pm bytes.pm => C:/Perl/lib/bytes.pm XSLoader.pm => C:/Perl/lib/XSLoader.pm Carp.pm => C:/Perl/lib/Carp.pm C:/Perl/site/lib/sitecustomize.pl => C:/Perl/site/lib/sitecustomize.pl Exporter.pm => C:/Perl/lib/Exporter.pm strict.pm => C:/Perl/lib/strict.pm warnings.pm => C:/Perl/lib/warnings.pm overload.pm => C:/Perl/lib/overload.pm Data/Dumper.pm => C:/Perl/lib/Data/Dumper.pm

      When you run the script, do you need to include 'use ...' to include any modules to show the HASH results? When I did, I got the same compilation errors as before, without them I get this:

      $ perl test.pl INC PATHs /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 . INC HASH

      As you can see, nothing is printed out for INC HASH. Bit of a catch 22 it seems...

        When you run the script, do you need to include 'use ...' to include any modules to show the HASH results?

        No, no "use" needed. I wrote my code in a simplistic way so that it didn't "require" or "use" any other modules.

        Again, as before, I suggest you compare output with your "reference system". I suspect that something is wrong with @INC and %INC.

        I don't know how to "fix" your problem, meaning how to correct the INC paths but other Monks may know. I asked that you compare this system versus the "reference system" that is working and you haven't provided that.

        I am wondering how you are getting along with this problem.

        You seem to have a LOT of stuff in the @INC path. Probably not an issue, but sometimes multiple versions can be trouble. I was not able to see immedidate problem with your command line stuff although there may be some file permission problems.

        I can replicate your first error message in the following code. As I mentioned before, "use vars(....);" appears in File::Spec. When vars.pm can't be found or "used" $VERSION doesn't have package scope.

        Anyway, start with simple code and then work from there. You have NO chance until you get this small program working:

        #!/usr/bin/perl -w use strict; use File::Spec; use vars qw(@ISA $VERSION); $VERSION = '3.2501'; print "Im ok if no warnings"; __END_ If I comment out: use vars qw(@ISA $VERSION); I get your error mesage: Global symbol "$VERSION" requires explicit package name at C:\TEMP\simple.pl line 8.
        At this point, I don't know how to help further. I can replicate your first error code in just a few lines of test code. Get stuff working from command line with you as the user. Then working from that, work on how to get Apache CGI server able to do the same thing.

        You may find this of help: http://perl.apache.org/docs/general/perl_reference/perl_reference.html#The__INC_array as well as Unix file permission (google on chmod).

Re: Every Perl Script Is Failing Compilation
by stevieb (Canon) on Sep 02, 2009 at 14:26 UTC

    Although I don't have the slightest clue what could have caused this in your case, I am curious as to whether you could harvest and post the 'history' of your shell session.

    Perhaps someone could spot a command that could have caused such devastation.

    I have run into something relatively similar in the past, which was caused by accidentally removing the 'package' declaration from the top of one of my module files. It didn't do system-wide damage like this though.

    Steve

      This is where it all went wrong:

      ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules ./checksetup.pl --check-modules cd .. ls -l chmod +w Bugzilla/ ls -l chmod 711 Bugzilla/ ls -l chmod 644 Bugzilla/ ls -l chmod +x Bugzilla/ ls -l cd /usr/lib/perl5/5.8.8/ ls mkdir Bugzilla cp CGI.pm Bugzilla/CGI.pm cp CGI/* Bugzilla/CGI/* . cd Bugzilla/ ls mkdir CGI cp ../CGI/* CGI/* . cp ../CGI/* CGI/ . ls mv *.* CGI/*.* ls mv Apache.pm CGI/Apache.pm mv * CGI/ . ls ls CGI/ ls ../.. ls ../ cd .. rm Bugzilla/ rm -r Bugzilla/

      I know the copies don't make sense, my inability in linux forced me to do it in a File Browser when I failed to do it from the command line. Effectively I copied CGI.pm and the folder CGI into the Bugzilla foler, then deleted it. Thanks for the help.