Undefined subroutine &main::guid called at H:\bin\foo.pl line 11.However, if I call my function as Guid::guid(), it works. Here's the calling program that doesn't work:
use Guid; print "Guid = " . guid() . "\n";Nor does this work:
use Guid qw(guid); print "Guid = " . guid() . "\n";But, this does work:
use Guid; print "Guid = " . Guid::guid() . "\n";Here's my module's header (from Guid.pm):
package Guid;
use strict;
use warnings;
use Math::BigInt;
use Net::Address::Ethernet qw(get_address);
BEGIN {
use Exporter ();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.00;
@EXPORT = qw(guid);
%EXPORT_TAGS = ();
}
sub guid {
my ($clockId, $netId) = $_;
my $maxClockId = 2**14;
my $clockIdOffset = 2**15; #Turn on Clock High bit
my $timeOffset = "122192928000000000";
[...And On...]
I've written Perl modules before and have successfully exported the various functions in them. I know the problem is probably something very simple, but I can't figure out what I am doing wrong.
So, why can't I seem to export guid() to my main namespace? What stupid detail am I leaving out?
You forgot to add Exporter to the @ISA of the package.
see base
also I don't see the need for a begin block here.
I've sat there for days trying to figure this out and comparing my header of this module to headers of other modules. For some reason, I didn't notice this one missing line.
Thanks.
perlmonks.org content © perlmonks.org and ambrus, Fletch, qazwart, tinita
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03