Hi,
A long time ago I wrote a module which seems to work fine. It is a bit like this, but does more.
# OddEffectOfImportTest.pm v1 package OddEffectOfImportTest; use Exporter; @ISA = qw(Exporter); @EXPORT = qw($OddEffectOfImportTest); our $OddEffectOfImportTest = 6.28; 1;
... and using it like this is fine.
#!/usr/bin/perl # OddEffectOfImportTest v1 use strict; use OddEffectOfImportTest; print "$OddEffectOfImportTest\n";
the point being that $OddEffectOfImportTest doesn't have a package name.
Now I've decided it would be useful to help it initalise, so I can use it thus:
#!/usr/bin/perl # OddEffectOfImportTest v2 use strict; use OddEffectOfImportTest goreallyfast => 1; print "$OddEffectOfImportTest\n";
but when I add "sub import{}" to the module:
# OddEffectOfImportTest.pm v2 package OddEffectOfImportTest; use Exporter; @ISA = qw(Exporter); @EXPORT = qw($OddEffectOfImportTest); our $OddEffectOfImportTest = 6.28; sub import {} 1;
..., without any other changes, I now I get
Global symbol "$OddEffectOfImportTest" requires explicit package name +at ./OddEffectOfImportTest line 5. Execution of ./OddEffectOfImportTest aborted due to compilation errors +.
Lots of my scripts use this module and I rather not track down and change them all if possible.
Threads 277141 and 569862 looked related but not close enough (for me to understand, at least.
Thanks for any help.
In reply to Adding "sub import{}" to my module makes global symbols require an explicit package name by BadHarry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |