Hi,
I've got a file with a bunch of subroutines, wrapped up in a package. I can load up
the package from my main program (using lib), and access the subs in a foo::bar() kind
of way. But I'd like to access them just as bar(), i.e. import the symbols or
whatever. Problem is that the usual Exporter way doesn't seem to work for me? It
always says can't recognise &main::bar, despite the Exporter gubbins. I've checked out
the source for a few modules, read a lot of man pages, and I'm still at a loss... it
seems right to me?
Here's the (simple test) code:
############################################
package TestUtil;
use warnings;
use strict;
BEGIN {
use Exporter();
our(@ISA, @EXPORT_OK, $VERSION);
$VERSION = 1.00;
@ISA = ('Exporter');
@EXPORT_OK = qw(&test_msg);
}
our @EXPORT_OK;
sub test_msg($) {
return "Hello $_[0]";
}
############################################
and then the main script is:
############################################
#!/usr/bin/perl -wT
use strict;
use warnings;
use lib '../cgi-lib';
use wcppe::TestUtil('test_msg');
print test_msg('John'); #doesnt work, causes error
print TestUtil::test_msg('John'); #works just fine
############################################
I've tried all sorts of permutations (the Exporter bit started out as only three
lines) but none seem to work. Is it glaringly obvious, or have I gone completely crazy?
Help most appreciated!
Thanks,
Tristan
p.s. I'm using Perl 5.6 on Red Hat Linux, if that makes any odds
_______________________________________________________
sent via the murky.net webmail hegemony
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]