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.
In reply to Re: Redefined subroutines in multiple libraries
by scorpio17
in thread Redefined subroutines in multiple libraries
by James Board
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |