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.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^2: Undefined subroutine &main::func1 by thanos1983
in thread Undefined subroutine &main::func1 [SOLVED] by thanos1983

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.