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
--- "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;
===
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:
> 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
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
: 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
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
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
>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
Hello,
Does anybody know how to call a subroutine that is in a .pm file from
another .pm file.
10 matches
Mail list logo