srikanthp1 has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help in accessing subroutines in perl scripts in perl modules.
by hippo (Archbishop) on Jun 16, 2016 at 12:37 UTC | |
by srikanthp1 (Initiate) on Jun 17, 2016 at 06:08 UTC | |
|
Re: Need help in accessing subroutines in perl scripts in perl modules.
by stevieb (Canon) on Jun 17, 2016 at 12:42 UTC | |
by choroba (Cardinal) on Jun 17, 2016 at 12:57 UTC | |
by stevieb (Canon) on Jun 17, 2016 at 13:00 UTC | |
by srikanthp1 (Initiate) on Jun 19, 2016 at 08:13 UTC |