Re: Can perl modules RECIPROCALLY 'use' one another?



On Wed, 29 Jun 2005 14:17:50 +0000, Ignoramus4093 wrote:

> Can I have a perl module
>
> package A;
> use B;
>
>
> and another module
>
> package B;
> use A;
>
>
> would they be able to call one another's subroutines?

If both export subroutines, the second module won't get the first one's
names exported because %INC has already been set when the first one was
loaded. This is a known problem. It's not hard to write an example.

> And if that's not the case, how would I implement a similar pattern?

The general consensus is to not do cyclic dependencies between
exporting modules. If you must, call the other module's routines
with package-qualified names.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

.



Relevant Pages

  • Re: First attempt at writing simple Module
    ... I'm trying to factor out the declaration and setting of a bunch of variables ... that a suite of programs will need, as well as defining some subroutines ... Package manage to become visible to main (although that's exactly what I ... No. "my $foo" does create a brand new scalar variable named ...
    (perl.beginners)
  • Re: modules - lost again
    ... > What I am currently doing is automatically exporting ALL these subroutines ... use Bar; ... package Foo; ... > see a single usage of Autoloader in a non-OO envirnoment which leads me ...
    (perl.beginners)
  • Re: bessel J in Fortran
    ... A Portable Package for Bessel Functions of a Complex Argument ... This algorithm is a package of subroutines for computing Bessel ... versions of those routines found in TOMS algorithm 644. ...
    (sci.math.num-analysis)
  • Re: bessel J in Fortran
    ... A Portable Package for Bessel Functions of a Complex Argument ... This algorithm is a package of subroutines for computing Bessel ... versions of those routines found in TOMS algorithm 644. ...
    (sci.math.num-analysis)
  • Re: How do I keep subroutines Local to the libraries I am calling?
    ... make it so that only the code in this block is in this package. ... Neither of these subroutines are in the package my_library, ... Now I have a simple script: ... certain subroutines local to my libraries and until recently I thought ...
    (comp.lang.perl.modules)