Hi all,

i need help in accessing the subroutines present in the perl scripts in perl modules.

getHosts() and getIP() subroutines are present in /tmp/utils/Utili.pl (perl script).

when i compile that master.pl, iam getting Undefined subroutine &Modules::test2::getIP called at /tmp/Modules/test2.pm

getIP() subroutine was present in the /tmp/utils/Utili.pl perl script.

i cannot take risk of changing /tmp/utils/Utili.pl to perl module, since it was used in hundreds of scripts and requires lot of testing effort.

could some one help me on this.?

please find the sudo code below.

Example:

master script: master.pl

in master.pl iam calling new subroutine in perl modules "test1.pm" and "test2.pm" as below.

use strict; use warnings; use lib "/tmp"; use Modules::test1; use Modules::test2; my $installation1 = Modules::test1->new(); my $installation2 = Modules::test2->new();

test1.pm:

in "test1.pm" i have the below code,

package Modules::test1; use strict; use warnings; require "/tmp/utils/Log.pl"; require "/tmp/utils/Utili.pl"; my @Hosts=getHosts(); sub new() { print "inside new\n"; }

test2.pm

in "test2.pm" i have the below code,

package Modules::test2; use strict; use warnings; my @IP=getIP(); require "/tmp/utils/Log.pl"; require "/tmp/utils/Utili.pl"; sub new() { print "inside new\n"; }

In reply to Need help in accessing subroutines in perl scripts in perl modules. by srikanthp1

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.