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 to find the subroutine
> that in is in file2.pm.
>
> Neither suggestion has worked so far, any other ideas out there?
Here we go:
---------- check.pl ----------
#!/usr/bin/perl -w
use strict;
use Module1;
use Module2;
&test_module1;
&Module2::test_module2;
---------- check.pl ----------
---------- Module1.pm ----------
use Module2;
sub called_from_module2 { print "Howdy, mod2\n"; }
sub test_module1 { &Module2::called_from_module1; }
1;
---------- Module1.pm ----------
---------- Module2.pm ----------
package Module2;
use Module1;
sub called_from_module1 { print "Howdy, mod1\n"; }
sub test_module2 { &main::called_from_module2; }
1;
---------- Module2.pm ----------
And here's the output.
---------- Module2.pm ----------
kanku-dai:~$ perl check.pl
Howdy, mod1
Howdy, mod2
kanku-dai:~$
---------- Module2.pm ----------
Note, that Module1, which doesn't specify a spacename, is put into the
'main' namespace by default, so in the 'Module2' namespace, you have to
address it specifically as 'main::function_name'.
--
If we fail, we will lose the war.
Michael Lamertz | [EMAIL PROTECTED] / [EMAIL PROTECTED]
Nordstr. 49 | http://www.lamertz.net
50733 Cologne | Work: +49 221 3091-121
Germany | Priv: +49 221 445420 / +49 171 6900 310