William Goedicke ([EMAIL PROTECTED]) said something to this effect on 06/12/2001:
> I'm a new lurker on the list and I have a question.
>
> Although I'm a veteran (though by no means expert) perl coder I've
> just started using perl's object oriented syntax. I would like to use
> a single module file (i.e. objects.pm) to hold all the code for the
> six objects I'm creating.
>
*snip*
>
> The problem (as you've probably already guessed) is that my scripts
> don't find CCertS::objects::test and so on. I'll bet there's some
> combination of "use Exporter" or something that will allow multiple
> class definitions in a single module. Can someone give me some simple
> guidance?
>
> Thanks in advanve - Yours Billy
You are starting with the right idea. Do something like
# File: /usr/local/lib/perl5/site_perl/5.6.1/CCertS/object.pm
package CCertS::test;
# CCertS::test code
sub new {
# implementation...
}
sub store {
# implementation...
}
package CCertS::user;
# CCertS::user code
sub new {
# implementation...
}
# Other packages, like above
1;
And in your script, use something like this:
#!/usr/bin/perl
use CCertS::objects;
my $test = CCertS::test->new;
my $user = CCertS::user->new;
$test->store($user); # or whatever
And so on.
The module you 'use' needs to exist in the file system, but it can
swicth packages all over the place. The file CCertS/object.pm
will be 'require'ed and compiled, and then all the packages defined
within it will be available from the calling script.
Object-oriented modules shouldn't normally need to inherit from
Exporter. Defining a class and a constructor, and then 'use'ing
the file, is enough.
Hope that was helpful.
(darren)
--
The kind of thinking we do sets the stage for the action we are likely
to take. Because of this, a man who refuses to develop his thinking
is likely to act on the impressions made upon him by others.
-- Dr. Claude R. Baker, "Coin In The Air"