Not usually. use XXX qw(a b c) is short for BEGIN { require XXX; XXX->import('a','b','c'); } Most modules that allow importing inherit from Exporter and use the default definition provided by that module. Exporter::import(...) simply imports the symbols "a", "b", "c" into the current package's namespace. It does not have any provision to for calling the functions after importing them. For more information, see use, import and Exporter.
If you want to call a function after importing it, you have two options. If the module you want to "use" is your own module, you could give that module a custom import(...) function.
For third party modules, you can't change the import function, but you can use a begin block to add additional behavior. Instead of use XXX, you would write something like this:
BEGIN {
require XXX;
XXX->import('MyFunction');
MyFunction('Hello World');
}
In either case your code will run in a BEGIN block, during the compilation phase. For more information on BEGIN blocks, see perlmod.
Best, beth
|