"Wiggins d'Anconia" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Todd W wrote: > > [snip] > > > you could do something like this: > > > > $ cat TestMod.pm > > use warnings; > > use strict; > > > > package TestMod; > > > > use Exporter; > > > > sub import { > > my $class = shift; > > foreach my $module ( @_ ) { > > require $module; > > } > > } > >
<snip /> > > Just for your info, the call to 'import' has nothing to do with the use > of Exporter. Exporter actually provides a special 'import' method that > does fancy stuff, but the actual calling of 'import' happens *everytime* > you do a 'use' (assuming the module 'can', aka has a sub named 'import') > regardless of whether Exporter has been loaded. And to have this > actually work you would have to inherit from Exporter so that 'import' > can be found in the sub lookup. Though as you have shown you can also > write your own import sub, which can be quite handy. > > perldoc -f use > perldoc Exporter > > for more info. > Yep, the use() mechanics is what calls your import function, and in the program I posted the "use Exporter;" statement does nothing. Thanks for clarifying my rudimentary knowledge on the subject. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>