If the arguments to use after the module name are function names, they will be imported.
use MyBot qw/afunc another thethird/;
The Exporter module can be used as a base class in MyBot.pm to get tagged exports and other goodies.
| [reply] [d/l] |
What about reloading the module? Do I just 'use MyModule qw/foo bar baz/;' again?
| [reply] |
use Symbol qw(delete_package);
sub re_use {
my $module = shift; # "Module::To::Reload"
my $fname = $module;
$fname =~ s#::#/#g;
$fname .= ".pm"; # "Module/To/Reload.pm"
delete_package($module); # remove the Module::To::Reload namespace
delete $INC{$fname}; # delete the filename from the
# "loaded" list
eval "use $module" or die $@;
}
| [reply] [d/l] [select] |
Do Dominus's very very short tutorial on Modules.
Download the entire thing as a zip. Do all the exercises carefully. It should take half a day or so. You should then be able to start moving stuff out of your code into modules
Then, if you want more clarification, do perlboot and perltoot. And the other perl core documentation.
But Dominus's tutorial is what got me started if you just want the basics. Good luck! | [reply] |
I think my problem is that I'm thinking in Python. I was forced to learn Python for a project I'm working on and have been using that almost exclusively for 4+ months. I've pulled out my copy of Advanced Perl Programming to get me back in the right mindset :P
| [reply] |
It sounds like you want to do the same thing that Apache::StatINC does. It's a short bit of code that should show you the way.
Good luck :)
--
brian d foy <bdfoy@cpan.org>
| [reply] |