Hello Monks,

I am trying to create my first module for CPAN and I got stack to a very minor problem, that I can not figure out how to proceed.

I have a module with name Net::SNTP::Client, sample provided bellow:

#!/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;

I can not figure out how to call the module from a script, sample provided bellow:

#!/usr/bin/perl use strict; use warnings; BEGIN { push @INC, '/home/username/Desktop/' } use Net::SNTP::Client; my @list = qw (J u s t ~ A n o t h e r ~ P e r l ~ H a c k e r !); # case 1 # use Net::SNTP::Client; # print func1(@list),"\n"; # print func2(@list),"\n"; # case 2 # use Net::SNTP::Client qw(&func1); # print func1(@list),"\n"; # print MyModule::func2(@list),"\n"; # case 3 # use Net::SNTP::Client qw(:DEFAULT); # print func1(@list),"\n"; # print func2(@list),"\n"; # case 4 # use Net::SNTP::Client qw(:Both); # print func1(@list),"\n"; # print func2(@list),"\n";

I keep getting the error:

an't locate Net/SNTP/Client.pm in @INC (you may need to install the Ne +t::SNTP::Client module) (@INC contains: /etc/perl /usr/local/lib/perl +/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 +/usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl . /h +ome/username/Desktop/) at client.pl line 8. BEGIN failed--compilation aborted at client.pl line 8.

I am following Simple Module Tutorial and trying to convert my module with defined classes to a reusable module and I can not figure it out where I am going wrong. I have spend 3 hours reading online and trying I still nothing. I know it is something so small but I can not understand why it can not work.

Update: I found how to install the module on my pc based on the instructions from Create a CPAN-style Perl module.

Thank you in advance for your time and effort.

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

In reply to How to create a reusable module with Exporter [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.