so it seems I can only import() from MyModule at compile time ('use' or BEGIN') but not at runtime. Here's my test case:
my module (MyModule.pm):
package MyModule; use Exporter(); our @ISA = qw(Exporter); @EXPORT_OK = qw(munge frobnicate); sub frobnicate { print "frobnicated!\n"; } sub munge { print "munged!\n"; }
When I call it from a script, this works (meaning I see the output from the print statements):
use MyModule qw(frobnicate munge); frobnicate; munge;
output is:
frobnicated! munged!
and this works (same output)
BEGIN { require MyModule; MyModule->import( qw(frobnicate munge) ); } frobnicate; munge;
but this does not (no output)
require MyModule; MyModule->import( qw(frobnicate munge) ); frobnicate; munge;
This seems to me to imply that I can only import at compile time, not at run-time.
Am I missing something?In reply to import doesn't work at runtime? by gdave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |