Hi Dan.
There's a few things wrong here, and I'm struggling to work out what you're
trying to do.
Dan Muey wrote:
>
> Yet another module question.
>
> I'm so close and I've done this but I can't get it to work.
>
> I am writing a module that is an extension/sub module of an existing module.
>
> use ... MyNewSexxySubModule qw(function);
We really need to see what's inside MyNewSexxySubModule.pm. If you're
subclassing Original::Package then it should look something like:
package MyNewSexxySubModule;
require Original::Package;
our @ISA = qw(Original::Package);
is that about right?
> $obj = new->Original::Package();
So then what's this? It looks like you're trying to call the constructor
of the Original::Package class, but it compiles as
$obj = 'new'->Original::Package;
which I can't even understand to be valid syntax unless you've also got
a subroutine called 'Package' in package 'Original' :-/
my $obj = new Original::Package;
or
my $obj = Original::Package->new;
but even then you're creating an instance of your base class, not your
new subclass.
> for(Original::Package::MyNewSexxySubModule::function($obj,$arg)) { ....
Here's yet another new package name which you haven't mentioned. What's
Original::Package::MyNewSexxySubModule? You also seem to be calling it
with your Original::Package object as its first parameter as if you were
trying to emulate the object method call $obj->function but using a
different class.
> This works like a charm but what I'd really like to do is this:
I'm very surprised, but...
> Use lib '/home/me/modules/';
> use MyNewSexxySubModule qw(function); # package
> Original::Package::MyNewSexxySubModule;
>From this comment it looks like your MyNewSexxySubModule.pm file might look
like
package Original::Package::MyNewSexxySubModule;
require Original::Package;
our @ISA = qw(Original::Package);
The name of the module should always be the same as the class name.
> $obj = new->Original::Package();
> for($obj->function($arg)) { ....
I'm still struggling to see why you're not using your new subclass at all. But
assuming Original::Package::new exists and returns a blessed reference, and
Original::Package::function exists then this should all be OK.
> When I try that it says:
> Original::Package=GLOB(0x829da00) is an [unexpected] object, aborting at
> ./ModTest.pl line 21
> Line 21 is my for($obj->....
I haven't the faintest idea what that error message might mean. But it looks like
you're
way off beam :)
> Any ideas what I'm missing ??
You've missed showing us where you've screwed up!
Cheers,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]