Inheritence question

D

Doug Nichols

I have a program where I create an class and pass a hash:

x.pm
package x;

sub new {
my $object = shift;
my $self = ((@_ == 1) ? shift(): { @_ });
return (bless $self, $object);
}
1;


I also have another class y that I would like x to inherit, but I
cannot seem to get the syntax correctly to do all things.

y.pm
package y;
sub new {
my $self = shift;
$self = { MYX => 'HELLO', MYOMY => 'GOODBYE', }
bless $self;
return $self;
}
1;

Can some one give me a hint?

Thanks
dn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Learning OOP 1
Code sharing 2
Issues with writing pytest 0
Space Invaders 0
First time question 1
constructors vs. subclasses? 4
Assistance with adding a second player to my Pygame :( 0
Building App doesnt work 1

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top