in reply to Redefined subroutines in multiple libraries
If you don't want to make your libraries into modules (which tends to imply object oriented methodology, etc.) you might instead put them into packages. If your familiar with C++, this is the same idea as putting them into a unique namespace.
Here's a real simple example:
This is file MySub1.pm:
package MySub1; use MySub2; sub AAA { my $x = MySub2::DDD(); return "AAA : $x"; } sub BBB { return "BBB"; } 1;
This is file MySub2.pm:
package MySub2; use MySub1; sub CCC { my $x = MySub1::BBB(); return "CCC : $x"; } sub DDD { return "DDD"; } 1;
This is file mytest.pl:
use strict; use MySub1; use MySub2; print MySub1::AAA(), "\n"; print MySub1::BBB(), "\n"; print MySub2::CCC(), "\n"; print MySub2::DDD(), "\n";
Summary: so you have MySub1, a package that contains subroutines, some of which call other subroutines in MySub2; and MySub2 contains subroutines that call subroutines in MySub1. The actual perl script uses subroutines from each of these packages.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Redefined subroutines in multiple libraries
by chromatic (Archbishop) on Jan 09, 2009 at 22:03 UTC | |
|
Re^2: Redefined subroutines in multiple libraries
by James Board (Beadle) on Jan 09, 2009 at 22:57 UTC | |
by ikegami (Patriarch) on Jan 09, 2009 at 23:44 UTC | |
by tilly (Archbishop) on Jan 10, 2009 at 00:02 UTC |