http://www.perlmonks.org?node_id=978097


in reply to Re^2: can't import using exporter
in thread can't import using exporter

Actually, it needs to be
package FOO::BAR; BEGIN {::$INC{FOO/BAR.pm}=1};
You can't use __PACKAGE__ because it would be FOO::BAR -- not a pathname, and there is no file, so '1' (true) is fine.

looks all better if you turn it into a 'use mem' statement' by adding a dummy package 'mem' first:

{package mem; [#1] BEGIN{$::INC{'mem.pm'}=1} #1: '#' present if in separate file 1}
After that's defined, then you can simply:
{ package Dbg; use mem &{sub(){$::INC{'Dbg.pm'}=1}}; use warnings; use strict; our @EXPORT; our $FRE; use mem &{sub(){$FRE = qr{:([^:]+)$} } }; use mem &{sub(){our @EXPORT = qw(Tracing Dumping Trackback DDump TPe +) } };
Note the '@EXPORT line -- this is required to make EXPORT work in 5.14 as one would expect. I don't remember this being the case at some previous point in time. But this is what was wrong with the original program. @EXPORTS in the original and 'Exporter' (maybe Exporter was changed), don't work at 'BEGIN/start' time, so if you use strict; nothing you export will be considered "legal"...

my 'use mem' module (all 2-3 lines of it!), is short for memorize this NOW for use in following code, or for the INC statements, use the memory cache for this routine and don't go to disk unnecessarily.

FWIW -- the original prog mentioned here, now works (though it looks quite different).

The single ~1600 line program has 17 classes and included 3 packages that can easily be re-integrated to run as 1 prog/file.