in reply to Inheritance without defining the object on inherited module

Yes, that error is occurring because you did not declare a variable. But there is a bigger issue: you are trying to execute some code that should be in your client inside your object. Do this instead:

package Person; use strict; use warnings; sub new { my $class = shift; my $self = { _firstName => shift, _lastName => shift, _ssn => shift, }; # Print all the values just for clarification. print "First Name is $self->{_firstName}\n"; print "Last Name is $self->{_lastName}\n"; print "SSN is $self->{_ssn}\n"; bless $self, $class; return $self; } sub setFirstName { my ( $self, $firstName ) = @_; $self->{_firstName} = $firstName if defined($firstName); return $self->{_firstName}; } sub getFirstName { my( $self ) = @_; return $self->{_firstName}; } package Employee; use strict; use warnings; our @ISA = qw(Person); # inherits from Person package main; use strict; use warnings; use Data::Dumper; my $object = Person->new( "Thanos", "Test", 123456); print Dumper $object; $object = Employee->new( "Janus", "Employee", 998877); print Dumper $object;

Moose and alternatives can simplify the learning curve:

package Person; use Moose; use MooseX::FollowPBP; has firstName => ( is => 'rw', isa => 'Str', required => 1 ); has lastName => ( is => 'rw', isa => 'Str', required => 1 ); has ssn => ( is => 'ro', isa => 'Str' ); sub get_Name { join ' ', $_[0]->get_firstName, $_[0]->get_lastName } package Employee; use Moose; extends 'Person'; package main; use strict; use warnings; my @objects = ( Person->new( firstName => "Thanos", lastName => "Test", ssn => 123 +456), Employee->new( firstName => "Janus", lastName => "Employee", ssn = +> 998877), ); print $_->get_Name, $/ for @objects;

Finally, i can't vouch for that tutorial you linked to. Try perlbootut instead?

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)