Sprad has asked for the wisdom of the Perl Monks concerning the following question:
The main script:
And two secondary scripts:# main.pl use Bar; use Foo; Bar("Called from main"); &Foo();
If I run them, I get this output:# Foo.pm package Foo; use Exporter; @ISA = 'Exporter'; @EXPORT = qw(Foo); use strict; sub Foo { Bar("Called from Foo"); } 1; # Bar.pm package Bar; use Exporter; @ISA = 'Exporter'; @EXPORT = qw(Bar); use strict; sub Bar { print "$_[0]\n"; } 1;
Inserting a use Bar; within Foo clears up the problem. But since main already uses Bar, shouldn't Foo pick that up as well? What am I missing?Called from main Undefined subroutine &Foo::Bar called at Foo.pm line 7
---
A fair fight is a sign of poor planning.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "use" inheritance
by bart (Canon) on Nov 18, 2003 at 23:42 UTC | |
|
Re: "use" inheritance
by castaway (Parson) on Nov 18, 2003 at 23:38 UTC |