in reply to Tk helps another package to export?

Here's a clue
E:\new>perl -MConstants -wle"print for keys %Constants::;;print XX+YY" Name "main::XX" used only once: possible typo at -e line 1. import YY EXPORT XX BEGIN print() on unopened filehandle XX at -e line 1. E:\new>perl -MUNIVERSAL -MConstants -wle"print for keys %Constants::;; +print XX+YY" import YY EXPORT EXPORT_FAIL EXPORT_OK XX BEGIN 1
Smells like a bug to me.

In my activeperl5.6.1/5.8.0, UNIVERSAL.pm consists of

require Exporter; *import = \&Exporter::import; @EXPORT_OK = qw(isa can);
I don't know when that happened/changed, but perl is supposed to load UNIVERSAL AUTOMAGICALLY, so you shouldn't need to say use UNIVERSAL;

I wanna hear what tye, merlyn and other people in the know have to say.

update: more clues

E:\new>perl -MConstants -wle"print for keys %UNIVERSAL::;;print XX+YY" Name "main::XX" used only once: possible typo at -e line 1. import can isa VERSION print() on unopened filehandle XX at -e line 1.
In Universally unimportant and overused tye says
(currently, Exporter::import() is called whenever you use a module that doesn't define any import method at all, even it that module doesn't even mention Exporter -- this will probably be "fixed" at some point but with this you can "fix" it now and see if you are using any modules that depend on this "bug").
I think it's fairly obvious that you should avoid using the package variables @EXPORT unless you also push @ISA, 'Exporter'; cause you'll have unexpected results (and what's the point of an @EXPORT if you don't wanna export anything).


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Tk helps another package to export?
by tye (Sage) on Jan 30, 2003 at 15:52 UTC

    Quoting PodMaster quoting me:

    (currently, Exporter::import() is called whenever you use a module that doesn't define any import method at all, even it that module doesn't even mention Exporter -- this will probably be "fixed" at some point but with this you can "fix" it now and see if you are using any modules that depend on this "bug").

    I was a bit inaccurate there. That is only true if you have already required UNIVERSAL.pm because that file contains:

    require Exporter; *import = \&Exporter::import;
    which is what causes this surprising behavior.

    I really think UNIVERSAL::import needs to be made smarter so that it only calls Exporter::import if called as UNIVERSAL->import( ... ). It is nice that you can do use UNIVERSAL qw( isa can ); but it is not nice to have every package suddenly "inherit" Exporter::import whether it wants to or not just because UNIVERSAL.pm has been required by some other part of the script.

    The only other piece of the mystery is that Tk::Widget does require UNIVERSAL; (and probably isn't the only place where UNIVERSAL.pm gets requested as a result of use Tk, but that is where the debugger found it being loaded).

                    - tye