in reply to import() not getting called. Huh?

I'm not sure if this is helpful or not.

I installed the testcode on my system, ran test1.perl and the last line of the output was print "so what?\n";. If I read it right, that indicates that everything worked on my system?

I added these 3 lines to the end of test1.p(er)l

package main; use Data::Dumper; print Dumper \%INC;

and you'll see from the end of the output below that indeed, M1, M2 & M3 are all loaded.

The full output

9:27:50.65 C:\test\EVA> test1 +++ I'm here! Exporter::VA import VERSION module M1 loaded +++ I'm here! M1 --verbose_import &foo bar baz quux bazola $ztesch -- +dump (Exporter::VA) ===processing import parameter (&foo)=== Got It: *{"C1::foo"}= CODE(0x1cff884) (Exporter::VA) ===processing import parameter (bar)=== (Exporter::VA) adding leading & to (bar) entry in export definition Got It: *{"C1::bar"}= CODE(0x1cff950) (Exporter::VA) ===processing import parameter (baz)=== (Exporter::VA) adding leading & to (baz) entry in export definition Got It: *{"C1::baz"}= CODE(0x1cffa1c) (Exporter::VA) ===processing import parameter (quux)=== (Exporter::VA) adding leading & to (quux) entry in export definition Got It: *{"C1::quux"}= CODE(0x1cffae8) (Exporter::VA) ===processing import parameter (bazola)=== (Exporter::VA) adding leading & to (bazola) entry in export definition Got It: *{"C1::bazola"}= CODE(0x1cfe870) (Exporter::VA) ===processing import parameter ($ztesch)=== Got It: *{"C1::ztesch"}= SCALAR(0x1cff818) (Exporter::VA) ===processing import parameter (--dump)=== %EXPORT = bless( ( '&foo' => '&foo', '.verbose_import' => '1', '&baz' => '', '--verbose_import' => sub { "DUMMY" }, '.&unknown_type' => sub { "DUMMY" }, '.&begin' => sub { "DUMMY" }, '$ztesch' => '', '.&unknown_import' => sub { "DUMMY" }, '..worklist' => { 'C1::baz' => sub { "DUMMY" }, 'C1::ztesch' => \undef, 'C1::foo' => sub { "DUMMY" }, 'C1::bazola' => sub { "DUMMY" }, 'C1::quux' => sub { "DUMMY" }, 'C1::bar' => sub { "DUMMY" } }, '&quux' => \$EXPORT{'..worklist'}{'C1::quux'}, '..home' => 'M1', '--dump' => sub { "DUMMY" }, '.&end' => sub { "DUMMY" }, '.warnings' => 1, '..client_default_version' => { 'C1' => '☺ ' }, '&bar' => 'internal_bar', '&bazola' => sub { "DUMMY" }, '.check_user_option' => sub { "DUMMY" }, '.&unknown_feature' => sub { "DUMMY" } ), 'Exporter::VA' ); +++ I'm here! Exporter::VA :normal HASH(0x1f37bdc) module M2 loaded +++ I'm here! M2 foo baz $ztesch :tag1 called .&begin called .&end +++ I'm here! Exporter::VA :normal HASH(0x1f30744) module M3 loaded +++ I'm here! M2 foo baz --dump called .&begin %EXPORT = bless( ( ':tag1' => [], '&thud' => \sub { "DUMMY" }, '&foo' => '&foo', '&baz' => '&baz', '--verbose_import' => sub { "DUMMY" }, '.&unknown_type' => sub { "DUMMY" }, '.&begin' => sub { "DUMMY" }, '$ztesch' => '$ztesch', '&grunt' => \${$EXPORT{'&thud'}}, '.&unknown_import' => sub { "DUMMY" }, '..worklist' => { 'C4::baz' => ${$EXPORT{'&thud'}}, 'C4::foo' => sub { "DUMMY" } }, '&quux' => '&quux', '..home' => 'M2', '--dump' => sub { "DUMMY" }, '.&end' => sub { "DUMMY" }, '.warnings' => 1, '..client_default_version' => { 'C2' => '☺ ', 'C4' => '☻â +¥â™¦â™£' }, '.check_user_option' => sub { "DUMMY" }, '&bazola' => \${$EXPORT{'&thud'}}, '.&unknown_feature' => sub { "DUMMY" } ), 'Exporter::VA' ); called .&end so what? $VAR1 = { 'M3.pm' => 'M3.pm', 'Exporter.pm' => 'e:/Perl/lib/Exporter.pm', 'Carp.pm' => 'e:/Perl/lib/Carp.pm', 'XSLoader.pm' => 'e:/Perl/lib/XSLoader.pm', 'strict.pm' => 'e:/Perl/lib/strict.pm', 'vars.pm' => 'e:/Perl/lib/vars.pm', 'warnings/register.pm' => 'e:/Perl/lib/warnings/register.pm' +, 'warnings.pm' => 'e:/Perl/lib/warnings.pm', 'M1.pm' => 'M1.pm', 'overload.pm' => 'e:/Perl/lib/overload.pm', 'M2.pm' => 'M2.pm', 'Exporter/VA.pm' => 'Exporter/VA.pm', 'Data/Dumper.pm' => 'e:/Perl/lib/Data/Dumper.pm' }; 9:27:58.40 C:\test\EVA>

The difference (and hopefully a clue) is that I didn't install it using the installer provided, I installed it manually relative to '.' in my %INC. The directory structure I used is

tree . Directory PATH listing Volume serial number is 0012FC94 8C87:E163 C:\TEST\EVA └───Exporter 9:47:15.57 C:\test\EVA> dir ./s Volume in drive C has no label. Volume Serial Number is 8C87-E163 Directory of C:\test\EVA 02/12/20 09:26a <DIR> . 02/12/20 09:26a <DIR> .. 02/12/19 08:04p 139 Dummy2.pm 02/12/19 08:05p 139 Dummy3.pm 02/12/20 09:27a <DIR> Exporter 02/12/03 11:41p 990 M1.pm 02/12/06 12:12a 699 M2.pm 02/12/19 07:41p 377 M3.pm 02/12/19 08:07p 1,650 test1.pl 02/12/19 08:07p 213 test2.pl 10 File(s) 4,207 bytes Directory of C:\test\EVA\Exporter 02/12/20 09:27a <DIR> . 02/12/20 09:27a <DIR> .. 02/12/19 07:56p 47,722 VA.pm 3 File(s) 47,722 bytes Total Files Listed: 13 File(s) 51,929 bytes 182,636,544 bytes free 9:47:26.22 C:\test\EVA>

Let me know if you need any further info about my setup.


Examine what is said, not who speaks.

Replies are listed 'Best First'.
Re: Re: import() not getting called. Huh?
by John M. Dlugosz (Monsignor) on Dec 20, 2002 at 17:07 UTC
    I have a die in the M3::import, so if you got "so what?" it illustrates the problem! Sorry if I wasn't clear last night; it was late and I was frustrated.

    Comment out the last stanza (the second use of M2) and see what happens.

    How can something following me affect my call? It appears that M3::import is not being called if M2 is used both before and after it in the source file (into different packages, though).

    Your trace shows that M3 loaded (print at the end of the file before the 1;), but there is no report that import was called with its parameters. Instead, the next report is that M2 was imported again.

      Sorry. I was mis-interpreting the output, but I tried something else

      I commented out  #Err "NOT IMPLEMENTED YET."; line 183 of VA.pm and ran the following script.

      package C1; use M1 v1.0 qw/&foo bar baz quux bazola $ztesch --dump/; #package C2; use M2 v1.0 qw/ foo baz $ztesch :tag1 --dump/; package C3; use M3 v1.0 qw/foo --dump/; print "so what?\n"; package C4; use M2 v2.3.4.5 qw/foo baz --dump/;

      M3 was imported, but M2 fails with a version check failure, so I replaced the last line above with

      package C4; use M2 v1.0 qw/foo baz --dump/;

      And that gave me identical results. M3 imported, M2 fails?

      Output

      Then I moved the first M2 line below the M3 line; and again M3 imports but the M2 line--that works above it--fails when moved below it?

      Again, I don't know if this helps any, but I thought I'd pass the information along in case it does. If this is another red-herring and you'd prefer not to get any more, just say so and I'll stop:).


      Examine what is said, not who speaks.

        OK, so importing M1, M3, M2 in that order makes M2 fail with VERSION being not found, right? It's not complaining that the version number is bad, but that the VERSION function is not found at all, which is strange for a couple of reasons: (1) it works in other modules, and (2) if it was not defined it would be found in UNIVERSAL.

        But, it is calling M3::import in this case.

        I'm wondering if M3::import caused something to be changed (incorrectly) in M2, not just in C3 as intended. That "clobber the wrong thing" could explain my first observation, that a function was not being called, if the symbol table entry for that function were altered.

        What makes me suspect a compiler bug or other bizzare issue is that commenting out something that will happen later changes the behavior.

        Maybe using Dumper on the symbol table to see if/when something unexpected changes...I'm glad it's friday.

        —John