InfiniteLoop has asked for the wisdom of the Perl Monks concerning the following question:
O! wise ones, I need your wisdom on the usage of "use":
I have 3 perl modules..
Foo.pm:
Bar.pm:package Foo; use strict; sub foo { print "Foo\n"; } 1;
Now in a third perl module: Something.pmpackage Bar; use strict; use Foo; sub bar { print "Bar\n"; } 1;
I expected an error in Something.pm, for calling Foo::foo, when the package "Foo" was not used in package Something. However this works perfectly. I have read the "use" inheritance thread and the perldoc use ..package Something; use strict; use Bar; .... Foo::foo; 1;
1. Is this a good practise ?
2. How does this work ?
P.S: I run perl v5.8.5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use enlightenment
by jbrugger (Parson) on Mar 08, 2005 at 10:23 UTC | |
by cog (Parson) on Mar 08, 2005 at 10:32 UTC | |
|
Re: use enlightenment
by jkva (Chaplain) on Mar 08, 2005 at 12:44 UTC | |
by cog (Parson) on Mar 08, 2005 at 13:02 UTC | |
by halley (Prior) on Mar 08, 2005 at 18:26 UTC | |
by wolfger (Deacon) on Mar 08, 2005 at 13:33 UTC | |
|
Re: use enlightenment
by cog (Parson) on Mar 08, 2005 at 13:06 UTC | |
by tall_man (Parson) on Mar 08, 2005 at 16:33 UTC | |
|
Re: use enlightenment
by RazorbladeBidet (Friar) on Mar 08, 2005 at 13:04 UTC | |
|
Re: use enlightenment
by ysth (Canon) on Mar 09, 2005 at 09:48 UTC |