thanos1983 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
Apologies for the second sequential question, but I keep getting stack one question after the other.
I am trying to follow the tutorial Simple Module Tutorial in order to configure the code to my needs so I can use it on my module.
The error that I am getting is very common, but I can not find a solution or at least an indication on what I am doing wrong.
I have installed my molule Net::SNTP::Client by applying the following commands:
perl Makefile.PL make make test sudo make install
After I installed the Module::Starter from CPAN.
I assume that this is the reason that I am getting this error, so I tried to reinstall the module after the modification on the module file but the error remains the same.
Undefined subroutine &main::func1 called at client.pl line 9.
Can someone help understand what I am doing wrong?
Update 1: Adding client.pl script.
#!/usr/bin/perl use strict; use warnings; my @list = qw (J u s t ~ A n o t h e r ~ P e r l ~ H a c k e r !); use Net::SNTP::Client qw(&func1); print func1(@list),"\n";
Update 2: Adding Net::SNTP::Client.pm module.
#!/usr/bin/perl use strict; use warnings; use Exporter qw(import); package Net::SNTP::Client; our $VERSION = v5.18.2; # Or higher... our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = qw(func1 func2); our %EXPORT_TAGS = ( # Mappings for :shortcuts. DEFAULT => [ qw(&func1) ], BOTH => [ qw(&func1 &func2) ] ); sub func1 { return reverse @_ } sub func2 { return map{ uc }@_ } 1;
Final Update: Apologies for confusing so many people that tried to help me, by not been able to understand my problem.
I just figure it out. Not knowing something can lead to so many mistakes and disappointment!
Everyone is absolutely right, The way that I define my folders on my module was completely wrong!!!!!!!
I named my module literally Net::SNTP::Client.pm although that I read that when the module will be installed this will mean that will be in the directory Net/SNTP/Client I completely forgot about it and proceed with naming the module like this. So when I defined package Net::SNTP::Client.pm I ignored the fact that I need to create a directory Net/SNTP/ and include my module Client.pm
Of course when I was trying to load the module it was not able to see the directory since they do not match. So I simply used the use lib '/home/username/Desktop/Test/'; before loading my module and modified also the directories accordingly. I had to rename my module to Client.pm instead of Net::SNTP::Client.pm and voilą!
Expected output:
!rekcaH~lreP~rehtonA~tsuJ
Apologies for not been able to understand and explain my problem properly. I have confused to many people that tried to help me.
Thank you again in advance for your time and effort.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefined subroutine &main::func1
by kcott (Archbishop) on Jun 28, 2015 at 02:13 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 02:20 UTC | |
by kcott (Archbishop) on Jun 28, 2015 at 02:45 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 02:53 UTC | |
by kcott (Archbishop) on Jun 28, 2015 at 03:16 UTC | |
| |
|
Re: Undefined subroutine &main::func1
by GrandFather (Saint) on Jun 28, 2015 at 02:11 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 02:22 UTC | |
|
Re: Undefined subroutine &main::func1
by Anonymous Monk on Jun 28, 2015 at 04:18 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 14:20 UTC | |
|
Re: Undefined subroutine &main::func1
by soonix (Chancellor) on Jun 28, 2015 at 13:18 UTC | |
by afoken (Chancellor) on Jun 28, 2015 at 14:29 UTC | |
by soonix (Chancellor) on Jun 28, 2015 at 15:25 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 15:35 UTC | |
by soonix (Chancellor) on Jun 28, 2015 at 16:37 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 14:28 UTC | |
by soonix (Chancellor) on Jun 28, 2015 at 15:26 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 15:58 UTC | |
|
Re: Undefined subroutine &main::func1
by stevieb (Canon) on Jun 28, 2015 at 02:27 UTC | |
by thanos1983 (Parson) on Jun 28, 2015 at 02:56 UTC |