[Chicago-talk] Inheritance

Don Drake don at drakeconsult.com
Sat Jan 10 13:41:34 CST 2004

This is not an inheritance problem, rather you have "use strict;" in your
code and you
don't declare $theDoer with my.

Change the line to this:
my  $theDoer = BaseClass->new();

And you're in business!


-----Original Message-----
From: chicago-talk-bounces at mail.pm.org
[mailto:chicago-talk-bounces at mail.pm.org]On Behalf Of petemar1
Sent: Saturday, January 10, 2004 1:35 PM
To: Chicago.pm chatter
Subject: [Chicago-talk] Inheritance

Given the following 2 separate files:

#!/usr/local/bin/perl -w
# BaseClass.pm

package BaseClass;

require BaseClass;

use strict;
use warnings;


    sub new {
        # my ($classname, @args) = @_;

        # my ($classname, @args) = shift;

        my $classname = shift;

        my $self = bless{}, $classname;

        return $self;

    sub doTheThing() {
        print"\n yes \n";

#!/usr/local/bin/perl -w
# DerivedClass.pl

package DerivedClass;

use strict;
use warnings;
# use base qw( BaseClass );
use lib qw( /home/petemar1/my_code/my_perl/ooperl/ooptest/BaseClass );

@MyApp::ISA = qw( BaseClass );

    $theDoer = BaseClass->new();

    # $theDoer = new BaseClass;

    # $theDoer->doTheThing();

What does the following error mean?

% perl DerivedClass.pl
Global symbol "$theDoer" requires explicit package name at DerivedClass.pl
line 14.
Execution of DerivedClass.pl aborted due to compilation errors.

Chicago-talk mailing list
Chicago-talk at mail.pm.org

More information about the Chicago-talk mailing list