I'm having a bit of trouble writing a module. My module has a function call "guid()". When I attempt to call it from my program, I get the following error:
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?

In reply to Exporting Module Functions by qazwart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.