Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

blogical's scratchpad

by blogical (Pilgrim)
on Mar 13, 2006 at 16:44 UTC ( #536303=scratchpad: print w/replies, xml ) Need Help??

Context

MyModule.pm
#!/usr/bin/perl -w use strict; package MyModule; use Exporter; our @ISA = qw( Exporter ); our @EXPORT = qw( MyFunc ); # ... some other subs go here ... [1] sub MyFunc { return 'Oh yeah!'; } # ... some other subs go here ... [2] 1; }
SomeOOModule.pm
#!/usr/bin/perl -w use strict; use MyModule; # try 1 { package SomeOOModule; use MyModule; # try 2 # ... some other subs go here ... [3] sub GetFuncy { warn '------ ' . __PACKAGE__ . " ------\n"; #warns "------ SomeOOModule ------" use MyModule; # try 3 return MyFunc; } # ... some other subs go here ... [4] }
MyProgram.pl
#!/usr/bin/perl -w use strict; print SomeOOModule::GetFuncy();

Question

When might this `use MyModule;` not import MyFunc into SomeOOModule::?

Answers

  • When MyModule.pm isn't found in @INC. Fix: Add it.
  • When the namespace has been switched with another package declaration somewhere in 3. Fix:
  • When the modules are recursive. Fix: Fix the recursion, or put the Export code into a BEGIN block.
  • YOUR ANSWER TO BE ADDED HERE

Extra Credit

Point out where a deviation from the code given might create a different reason for this problem to occur.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Tabish]: Hi to everyone :). Can i use cgi table in package index.pm to return data in test.pl?
[Tabish]: return data in table

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2017-12-13 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (350 votes). Check out past polls.

    Notices?