use Foo::Bar @stuff; means exactly the following:
BEGIN {
require 'Foo/Bar.pm';
Foo::Bar->import( @stuff );
}
where @stuff is if you do something like use Foo::Bar baz => 1;
Nowhere in Perl are the packages Foo and Foo::Bar related, except by convention.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] [d/l] [select] |
If this is not the case what are intra-file sub-packages good for?
Dividing programs up into separate namespaces. You don't always need it, but sometimes it comes in handy.
| [reply] |
The only other benefit I can think of is syntactic sugar. But, that sugar is better solved using factories. *shrugs*
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] |
package Foo::Bar;
BEGIN {
$INC{"Foo/Bar.pm"} = $0;
use base "Exporter";
@EXPORT = "hi";
}
sub hi {
print "Hi from Foo::Bar"
}
package main;
use Foo::Bar;
hi();
antirice The first rule of Perl club is - use Perl The ith rule of Perl club is - follow rule i - 1 for i > 1
| [reply] [d/l] |