I'm trying to write a perl module, and cannot export my subs.
I'm on Ubuntu 12.04 LTS, using Perl v5.14.2
Here's my module,
/home/steve/scripts/lib/STEVE/Test.pm:
package Test;
use strict;
use warnings;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = ();
@EXPORT_OK = qw(test);
sub test
{
print "This is only a drill\n";
}
1;
(yes, now the world knows my file structure).
I constructed it according to
this post:
http://www.perlmonks.org/?node_id=102347
My driver program,
/home/steve/scripts/test.pl,
looks like:
#!/usr/bin/perl
use lib '/home/steve/scripts/lib';
use STEVE::Test qw(&test);
test();
As stated, this fails, with error:
Undefined subroutine &main::test called at ./test.pl line 6.
Why? I used to write modules all the time (on the same OS, but maybe not the same perl version). Did perl change its export/import/package method?
Thanks
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.