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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.