Re: Can perl modules RECIPROCALLY 'use' one another?
- From: Brian McCauley <nobull@xxxxxxxx>
- Date: Wed, 29 Jun 2005 21:11:18 +0100
Peter Scott wrote:
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.
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.
Whilst I agree that cyclic dependancies are best avoided, it is not necessary to fully qualify names. It is sufficient to assign @EXPORT inside a BEGIN block.
BEGIN { our @EXPORT = qw( all those functions ) }.
- References:
- Re: Can perl modules RECIPROCALLY 'use' one another?
- From: Peter Scott
- Re: Can perl modules RECIPROCALLY 'use' one another?
- Prev by Date: Re: RFC: Net::IP::Correct
- Next by Date: Re: Installing a CPAN Module online
- Previous by thread: Re: Can perl modules RECIPROCALLY 'use' one another?
- Next by thread: Google API using SOAP Lite doesn't like '&' in query
- Index(es):
Relevant Pages
|