Mail Archives: cygwin/2007/09/25/20:06:26
- The problem
- When I run some scripts, I get errors like the following from Perl
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 173.
- This did not happen before yesterday (September 24, 2007)
afternoon.
- Perl version
---
This is perl, v5.8.8 built for cygwin-thread-multi-64int
(with 8 registered patches, see perl -V for more detail)
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License 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 found 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.
---
- Immediate Cause (my theory)
- The problem stems from a failure to use the 'our' operator when
exporting global symbols in a Perl module (Perl .pm) file. For
example, the Perl module Cwd.pm about has a variable named
$VERSION which is not scoped in any way.
- The complaints from Perl arise when the user includes these
modules in a Perl program with "use strict" specified.
- Immediate Fix (fix if my theory is accurate)
- Here are the files that I had a problem with. Note that c:/cygroot
is mapped to / in my Cygwin installation.
- c:/cygroot/lib/perl5/5.8/cygwin/Cwd.pm
- c:/cygroot/lib/perl5/5.8/File/Spec.pm
- c:/cygroot/lib/perl5/5.8/File/Spec/Cygwin.pm
- c:/cygroot/lib/perl5/5.8/File/Spec/Unix.pm
- The files affected all appear to the Cygwin-specific .pm files.
- The variables in these files SHOULD be explicitly scoped.
- The scope should probably me 'our'
- The error messages and fixes
- c:/cygroot/lib/perl5/5.8/cygwin/Cwd.pm
- Errors
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 173.
Global symbol "@ISA" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 175.
Global symbol "@EXPORT" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 176.
Global symbol "@EXPORT" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 177.
Global symbol "@EXPORT_OK" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 178.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 206.
Global symbol "@ISA" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 209.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 210.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 215.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 215.
BEGIN not safe after errors--compilation aborted at
/usr/lib/perl5/5.8/cygwin/Cwd.pm line 698.
Compilation failed in require at /usr/lib/perl5/5.8/File/Find.pm line 8.
Compilation failed in require at /cygdrive/c/home/naju/.user_env/bin/unify
line 37.
BEGIN failed--compilation aborted at
/cygdrive/c/home/naju/.user_env/bin/unify line 37.
- Added 'our' to $VERSION, @ISA, @EXPORT, @EXPORT_OK
- c:/cygroot/lib/perl5/5.8/File/Spec.pm
- Errors
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec.pm line 6.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec.pm line 7.
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec.pm line 7.
Global symbol "@ISA" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec.pm line 23.
Compilation failed in require at /usr/lib/perl5/5.8/File/Find.pm line 423.
Compilation failed in require at /cygdrive/c/home/naju/.user_env/bin/unify
line 37.
BEGIN failed--compilation aborted at
/cygdrive/c/home/naju/.user_env/bin/unify line 37.
- Added 'our' to $VERSION, @ISA
- c:/cygroot/lib/perl5/5.8/File/Spec/Cygwin.pm
- Errors
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec/Cygwin.pm line 7.
Global symbol "@ISA" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec/Cygwin.pm line 9.
Compilation failed in require at /usr/lib/perl5/5.8/File/Spec.pm line 22.
Compilation failed in require at /usr/lib/perl5/5.8/File/Find.pm line 423.
Compilation failed in require at /cygdrive/c/home/naju/.user_env/bin/unify
line 37.
BEGIN failed--compilation aborted at
/cygdrive/c/home/naju/.user_env/bin/unify line 37.
- Added 'our' to $VERSION, @ISA
- c:/cygroot/lib/perl5/5.8/File/Spec/Unix.pm
- Errors
Global symbol "$VERSION" requires explicit package name at
/usr/lib/perl5/5.8/File/Spec/Unix.pm line 6.
BEGIN not safe after errors--compilation aborted at
/usr/lib/perl5/5.8/File/Spec/Unix.pm line 144.
Compilation failed in require at /usr/lib/perl5/5.8/File/Spec/Cygwin.pm
line 5.
Compilation failed in require at /usr/lib/perl5/5.8/File/Spec.pm line 22.
Compilation failed in require at /usr/lib/perl5/5.8/File/Find.pm line 423.
Compilation failed in require at /cygdrive/c/home/naju/.user_env/bin/unify
line 37.
BEGIN failed--compilation aborted at
/cygdrive/c/home/naju/.user_env/bin/unify line 37.
- Added 'our' to $VERSION
- The deeper mystery
- Why did this problem decide to rear its ugly head yesterday?
- I don't know.
- I am new to Cygwin. I don't know if my system silently upgraded
my Perl package in the background while I was working
yesterday.
- I also noticed that the problem arose in one of my own .pm Perl
modules, EVEN THOUGH I was "exporting" my module globals using the
vars pragma
- Here is a sample:
use vars qw($TARBALL_FILENAME
$HOME_DIR
$CONFIG_DIR
$MASTER_SCP_HOST
$MASTER_SCP_USER
$MASTER_AFS_USER
$MASTER_AFS_CELL
$MASTER_AFS_DIR);
- The Perl interpreter complained about this until I was forced to
export these variables the Perl 5.6+ way:
use vars qw($TARBALL_FILENAME
$HOME_DIR
$CONFIG_DIR
$MASTER_SCP_HOST
$MASTER_SCP_USER
$MASTER_AFS_USER
$MASTER_AFS_CELL
$MASTER_AFS_DIR);
our $TARBALL_FILENAME;
our $HOME_DIR;
our $CONFIG_DIR;
our $MASTER_SCP_HOST;
our $MASTER_SCP_USER
our $MASTER_AFS_USER;
our $MASTER_AFS_CELL;
our $MASTER_AFS_DIR;
- Note that since 'our' is not supported on version of Perl older
than 5.6, this probably won't compile on older versions of
Perl.
- I thought my original code (using vars) was the portable,
backward-compatible way to export globals.
- My Linux box (running Perl 5.8.7) still supports the vars
pragma.
- I don't know if the Perl guys have changed their minds on
this with 5.8.8.
- I don't know if there is an "even more backward compatible"
way to write this code so that it runs on by versions older
than 5.6 and newer versions.
- If you guys don't care about support ancient versions of Perl,
then my suggested modifications should work fine.
Please let me know if I can provide more details that would be
helpful.
Thanks,
Naju
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -