NOTE: Author determined that this was not actually a problem. Please see this node

I'm working on a module for a project that I'm involved in - nothing big, just a few common subroutines that need to be called by a variety of applications. The problem that I'm having is that I can't seem to export the subroutines to be used by the application. In the the code 'modtest.pl' below, it picks up the version number out of the module without any problem. However, when I try to access the subroutine testMod(), I get an error message stating

Undefined subroutine &main::testMod called at C:\path\path\modtest.pl line
	17 (#1)
    (F) The subroutine indicated hasn't been defined, or if it was, it has
    since been undefined.

I've checked perlmod and a couple sites here, but with no luck. It looks like it should work, but doesn't. I've tried with and without the begin blocks - 'require Exporter' vs. 'use Exporter'... still no luck. I'm running Perl 5.6.1 on Win32. Any help, suggestions, or information would be very much appreciated.


«Rich36»
#!/usr/bin/perl # modtest.pl ####################################################### # Setup variables and packages ####################################################### use strict; use warnings; use diagnostics; use lib './lib'; use CART::Validate; ####################################################### # MAIN ####################################################### print qq(The module version is $CART::Validate::VERSION\n); my $testing = testMod(); print qq(The return value from testMod is $testing\n); exit;
# CART::Validate package CART::Validate; BEGIN { use Exporter; our( @ISA, @EXPORT, @EXPORT_OK, $VERSION ); @ISA = qw( Exporter ); @EXPORT = qw( &testMod ); @EXPORT_OK = qw(); $VERSION = 1.00; } sub testMod { return "HELLO!"; } 1;

In reply to Trouble Exporting a Function by Rich36

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.