J9 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to get my head around creating my own module. I have got the following out of the Perl Cookbook and am having some difficulties. I have gone through SuperSearch but have not been able to find my answers
Given the following module which I called Test.pm and located in the c:/perl/site/lib dir ...I am using the following code to try and call a subroutine and pass it a string(only for this VERY BASIC test)..##Test Module package Test; use strict; use warnings; require Exporter; use vars qw(@ISA @EXPORT); my @ISA = qw(Exporter); my @EXPORT = qw( Prt Time ); sub Prt { my $string = shift; print &Time() . "- $string\n"; } sub Time { my @localdate = localtime(time); my $tme = sprintf("%02d:%02d:%02d", $localdate[2], $localdate[1], +$localdate[0]); return($tme); } 1;
This is what I get...#! /usr/bin/perl use strict; use warnings; use Test; print "About to use Module\n"; &Prt("This is a test in the Mod"); print "Finished\n";
I tried changing line 8. toAbout to use Module Undefined subroutine &main::Prt called at C:\dev\Source_Perl\MiscTests +\mod.pl line 8.
as well as&Test::Prt("This is a test in the Mod");
Test::Prt("This is a test in the Mod");
as was suggested in a previous post but still get the same output.Any help would be greatly appreciated.J9
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Undefined subroutine
by blokhead (Monsignor) on Mar 11, 2003 at 14:20 UTC | |
by J9 (Beadle) on Mar 11, 2003 at 14:33 UTC | |
Re: Undefined subroutine
by Wonko the sane (Deacon) on Mar 11, 2003 at 14:33 UTC | |
Re: Undefined subroutine
by broquaint (Abbot) on Mar 11, 2003 at 14:11 UTC | |
by J9 (Beadle) on Mar 11, 2003 at 14:35 UTC | |
by broquaint (Abbot) on Mar 11, 2003 at 14:45 UTC | |
by J9 (Beadle) on Mar 11, 2003 at 14:48 UTC | |
by broquaint (Abbot) on Mar 11, 2003 at 14:53 UTC | |
Re: Undefined subroutine
by mattriff (Chaplain) on Mar 11, 2003 at 14:11 UTC | |
by J9 (Beadle) on Mar 11, 2003 at 14:19 UTC | |
Re: Undefined subroutine
by nite_man (Deacon) on Mar 11, 2003 at 14:51 UTC | |
Re: Undefined subroutine
by J9 (Beadle) on Mar 11, 2003 at 14:45 UTC | |
Re: Undefined subroutine
by hiseldl (Priest) on Mar 11, 2003 at 14:15 UTC | |
by J9 (Beadle) on Mar 11, 2003 at 14:28 UTC | |
by zigdon (Deacon) on Mar 11, 2003 at 14:28 UTC | |
by hiseldl (Priest) on Mar 11, 2003 at 14:38 UTC |
Back to
Seekers of Perl Wisdom