Reputation: 304
Given the following:
package My::Pack;
use Exporter::Easy (
OK => [ qw(pack_func) ],
);
sub pack_func {
...
}
package main;
<script here that uses pack_func>
How do I import the symbol I want?
use
doesn't work since it's looking for another file to open.
require
doesn't support the syntax that use
does for specifying the symbols you want.
Are my only choices to say My::Pac::pack_func()
in the script or import the symbol manually through typeglob assignmnet?
Upvotes: 1
Views: 51
Reputation: 50328
The statement:
use Some::Module qw(foo bar);
BEGIN {
require Some::Module;
Some::Module->import( qw(foo bar) );
}
in your case, the code for the My::Pack
module has already been loaded, so you don't need to require
it. Thus, you can just do:
BEGIN { My::Pack->import( qw(pack_func) ) }
Upvotes: 1