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.
In reply to Undefined subroutine &main::func1 [SOLVED] by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |