in reply to Re: Multiple classes in modules
in thread Multiple classes in modules
With test code:# file: MyDir/MyTest.pm package MyDir::Foo; sub new{ my $class = shift; my $self = {}; bless $self, $class; return $self; } sub foo{ print "Foo\n"; } package MyDir::Bar; sub new{ my $class = shift; my $self = {}; bless $self, $class; return $self; } sub bar{ print "Bar\n"; } 1;
Updated. In fact, one can simply name the package as "Foo" and "Bar" instead of "MyDir::Foo" and "MyDir::Bar". In other words, "use" is tied to the directory layout, but not to the contents of the files. Am I too general here?use strict; use MyDir::MyTest; my $foo = MyDir::Foo->new(); $foo->foo(); my $bar = MyDir::Bar->new(); $bar->bar();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Multiple classes in modules
by ikegami (Patriarch) on Oct 05, 2004 at 20:16 UTC |