in reply to Re: Undefined subroutine &main::func1
in thread Undefined subroutine &main::func1 [SOLVED]
Hello Anonymous,
Thank you for your time and effort, reading and replying to my question.
I assume the same, in theory I should install the module in order to be able to use it but before I reach this point to post this question Undefined subroutine &main I was not able to execute my code. See question How to create a reusable module with Exporter SOLVED, I still can not find a way to use new modules with the name eg. Net::SNTP::Something without installing them locally. I keep getting the same error if I do not install them:
Can't locate Net/SNTP/Server.pm in @INC (you may need to install the N +et::SNTP::Server module) (@INC contains: . /etc/perl /usr/local/lib/p +erl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/per +l5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl) +at server.pl line 8. BEGIN failed--compilation aborted at server.pl line 8.
For example, I have another module that I want to use named Net::SNTP::Server.pm. For simplicity and demonstration purposes I am using the same code from Net::SNTP::Client.pm with only difference the package name. Sample of code provided bellow:
#!/usr/bin/perl use strict; use warnings; use Exporter; package Net::SNTP::Server; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(func1 func2); %EXPORT_TAGS = ( DEFAULT => [qw(&func1)], Both => [qw(&func1 &func2)] ); sub func1 { return reverse @_ } sub func2 { return map{ uc }@_ } 1;
I am calling it from the server.pl script. Sample of code provided under:
#!/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 lib '.'; # note here use Net::SNTP::Server qw(&func1); print func1(@list),"\n";
The error that I am getting is the same:
Can't locate Net/SNTP/Server.pm in @INC (you may need to install the N +et::SNTP::Server module) (@INC contains: . /etc/perl /usr/local/lib/p +erl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/per +l5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl) +at server.pl line 8. BEGIN failed--compilation aborted at server.pl line 8.
So at this point you will say that I am not using correctly the directories. I can not call a module Net::SNTP::Server.pm without installing it on the lib directory, can I?
Thank you for your time and effort.
|
|---|