Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-18 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found