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(@_) }
line or similar (IE using GLOBs)


Below is a basic sample of what I am wanting to do:

in this case make 'use FooTest;' act as if you had also
 use Digest::MD5 qw(md5_base64);

the Exporter docs and perldoc perlmod didn't seem to touch on it and I couldn't get variations of it to work how I'd like either.

Any ideas would be most appreciated!

TIA

file test.pl:
#!/usr/bin/perl

use strict;
use warnings;
use FooTest;

print FooTest::funk();
print Digest::MD5::md5_base64('howdy'),"\n";
print md5_base64('howdy'),"\n";

file FooTest.pm:
package FooTest;

use strict;
use warnings;
use Digest::MD5;

require Exporter;
our @ISA = qw(Exporter);

sub import {
   $_[0]->export_to_level(2, grep(!/^-/, @_));
   shift;
   Digest::MD5->import('md5_base64')
}

sub funk { md5_base64('howdy'),"\n" }

Output is:
B4Lv1ht6awLmAsxqEWc+yQ
B4Lv1ht6awLmAsxqEWc+yQ
Undefined subroutine &main::md5_base64 called at test line 9.

Ouput Should be:
B4Lv1ht6awLmAsxqEWc+yQ
B4Lv1ht6awLmAsxqEWc+yQ
B4Lv1ht6awLmAsxqEWc+yQ

i know Digest::MD5->import() is being called becasue if you add something that it does not export you get teh error about it not being exported by that module.

it just importing it to FooTest (IE see funk()) but I need it imported to the where ever it was use()ed from.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to