Joshua Colson wrote:
On Thu, 2005-03-31 at 12:41 -0600, JupiterHost.Net wrote:
Hello,
I am working on a module that needs to import a function from Digest::MD5. The reasoning on this is that its a subclass so it'd be handy to be able to use() it and export functions from the parent module without having to add a
sub foo { Parent::foo(@_) }
Add the parent module/class to the perl @ISA array. Perl will search the @ISA array for any methods that aren't available in the current package. In the example of your module, it is technically a subclass of Exporter because you've added that you your @ISA array. If you simply add 'Digest::MD5' to the @ISA array you'll inherit all the methods that it provides. For you to be able to call md5_base64 from within test.pl without qualifying it (and you want it to call the FooTest.pm inherited version of it, you'll have to Export the method (perldoc Exporter) by adding it to either the @EXPORT_OK or @EXPORT array in FooTest.pm. The @EXPORT array automatically exports the methods listed while the @EXPORT_OK array only allows importing the methods by adding them after the module name on the 'use' line as shown below. Adding anything into the @EXPORT array is discouraged as that will trample someone else's namespace, i.e. test.pl in this case.
Awesome! Thats what I was missing (the @ISA) :) You're a genius, perfecto!
Joshua Colson gets genius of the day (they still do that on this list?)
Thanks a zillion! It works great!
Lee.M
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>