http://www.perlmonks.org?node_id=1020350

ShermW0829 has asked for the wisdom of the Perl Monks concerning the following question:

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;