I am trying to get a perl script to run my own installed module. I am getting the below message.
Undefined subroutine &testdir::testsub called at call_module line 11.
I installed the module using the following code
module-starter --module=testdir::moduletest --author="Sherman Willden" --email=PedalSteel.E9B6@gmail.com --license=perl --verbose
The install directory is /home/sherman/module_test/share/perl/5.14.2/testdir/moduletest.pm. I am including the .pm code and the .pl code. The perl file calling the .pm file works when I use require.
#! /usr/bin/perl
#
# moduletest.pm
package testdir::moduletest;
use Exporter(); # Why is Exporter white while other use
# statements are colored
$VERSION = '0.00.01';
@ISA = qw(Exporter);
@EXPORT = qw(testsub);
@EXPORT_OK = qw($string);
sub testsub {
=head1 SUBROUTINE
The testsub subroutine is just a test
function that determines that four variables
are seen with the testsub function and returns
a string created within the testsub function.
=cut
print "In my testsub function\n";
print "\$_[0]: \"$_[0]\"\n";
print "\$_[1]: \"$_[1]\"\n";
print "\$_[2]: \"$_[2]\"\n";
print "\$_[3]: \"$_[3]\"\n";
my $string = "My string\n";
return("$string");
}
1;
__END__
=head1 NAME
testdir::moduletest
=head1 SYNOPSIS
Provides one called function, testsub
=head1 DESCRIPTION
This is a test module with provides valued passed
in, print statements that show the variables passed
in, a string created and returned from with testsub
=head1 AUTHOR
Sherman L. Willden
=head1 COPYRIGHT
Copyright 2013, Sherman L. Willden. All Rights Reserved
This program is free software. You may copy or
redistribute it under the same terms as Perl itself.
=cut
Here is the callin perl file's code:
#! /usr/bin/perl -w
# module_test.pl
use V5.14.2;
use lib '/home/sherman/module_test/share/perl/5.14.2';
# Since this didn't work I am checking for my path within
# the perl path
print qq(@INC);
# require '/home/sherman/build_dir/testdir/moduletest.pm';
my $moduletest = testdir::testsub(0,2,0,2);
chomp($moduletest);
print "moduletest: \"$moduletest\"\n";
1;
-
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.