>Does anybody know how to call a subroutine that is in a .pm file from
>another .pm file.
Welp, if &subroutine_1 is in Library1.pm,
then within Library2.pm, you could do something like:
sub subroutine_2 {
require "/path/to/Library1.pm";
&subroutine_1;
}
Morbus Iff
.sig on other
Morse, Loretta ([EMAIL PROTECTED]) wrote:
>
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
That depends:
First you have to load the file via 'require' or 'use' - perldoc them.
If your other .pm creates its own namespace, you need to addre
is in file2.pm.
Neither suggestion has worked so far, any other ideas out there?
Thanks.
-Original Message-
From: Michael Lamertz [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 4:06 PM
To: Morse, Loretta
Cc: '[EMAIL PROTECTED]'
Subject: Re: subroutines in .pm
Morse, Loretta
: I am using a WinNT system and I'm running a script that calls
: a subroutine in file1.pm. Then file1.pm calls a subroutine
: from file2.pm. The script can't seem to find the subroutine
: that in is in file2.pm.
Does your file1.pm have "use file2" in it?
-- tdk
seem to find the subroutine
> that in is in file2.pm.
>
> Neither suggestion has worked so far, any other ideas out there?
>
> Thanks.
>
> -Original Message-
> From: Michael Lamertz [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 27, 2001 4:06 PM
> To: M
Morse, Loretta ([EMAIL PROTECTED]) wrote:
> Thanks for the suggestions however I think I need to clarify
> what I'm trying to do.
>
> I am using a WinNT system and I'm running a script that calls
> a subroutine in file1.pm. Then file1.pm calls a subroutine
> from file2.pm. The script can't seem
Try throwing this into file2.pm:
sub AUTOLOAD {
print "What hath god wrought?\n"
}
And then call:
file2->any_function_name;
That is if you have a:
use file2;
AUTOLOAD is a catch all function, method really, but this should work
considering how Perl blurs the line b
--- "Morse, Loretta" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
Given A.pm
===
package A;
sub a { return "a!\n"; }
1;
===
and B.pm
===
package B;
use A;
sub b { print A::a(); }
1;
===
PM
To: Morse, Loretta; '[EMAIL PROTECTED]'
Cc: [EMAIL PROTECTED]
Subject: Re: subroutines in .pm
--- "Morse, Loretta" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Does anybody know how to call a subroutine that is in a .pm file from
> another .pm file.
Given A.pm