asokoloski has asked for the wisdom of the Perl Monks concerning the following question:
##### a.pm ##### package a; use b; sub import { print "import in $_[0] called from ". (caller(1))[3] ." \n"; } 1;
and a script:##### b.pm ##### package b; use a; sub import { print "import in $_[0] called from ". (caller(1))[3] ." \n"; } 1;
Running this script prints:### test.pl ### #!/usr/bin/perl use strict; use warnings; use a;
Whereas I would expect there to be another "import in a called from b::BEGIN" at the beginning, from the "use a;" in b.pm. I know that each module is only compiled once, but import should be called each time, and there are three "use" statements, so shouldn't there be three imports?import in b called from a::BEGIN import in a called from main::BEGIN
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Circular use doesn't call import() as expected...?
by tilly (Archbishop) on Nov 04, 2005 at 03:33 UTC | |
|
Re: Circular use doesn't call import() as expected...?
by ikegami (Patriarch) on Nov 04, 2005 at 05:27 UTC | |
|
Re: Circular use doesn't call import() as expected...?
by asokoloski (Sexton) on Nov 04, 2005 at 17:50 UTC |