http://www.codeproject.com/perl/camel_poop.asp #### #class Person package Person; use strict; use Address; #Person class will contain an Address #constructor sub new { my ($class) = @_; my $self = { _firstName => undef, _lastName => undef, _ssn => undef, _address => undef }; bless $self, $class; return $self; } #accessor method for Person first name sub firstName { my ( $self, $firstName ) = @_; $self->{_firstName} = $firstName if defined($firstName); return $self->{_firstName}; } #accessor method for Person last name sub lastName { my ( $self, $lastName ) = @_; $self->{_lastName} = $lastName if defined($lastName); return $self->{_lastName}; } #accessor method for Person address sub address { my ( $self, $address ) = @_; $self->{_address} = $address if defined($address); return $self->{_address}; } #accessor method for Person social security number sub ssn { my ( $self, $ssn ) = @_; $self->{_ssn} = $ssn if defined($ssn); return $self->{_ssn}; } sub print { my ($self) = @_; #print Person info printf( "Name:%s %s\n\n", $self->firstName, $self->lastName ); } 1; #### # class Employee package Employee; use Person; use strict; our @ISA = qw(Person); # inherits from Person #constructor sub new { my ($class) = @_; #call the constructor of the parent class, Person. my $self = $class->SUPER::new(); $self->{_id} = undef; $self->{_title} = undef; bless $self, $class; return $self; } #accessor method for id sub id { my ( $self, $id ) = @_; $self->{_id} = $id if defined($id); return ( $self->{_id} ); } #accessor method for title sub title { my ( $self, $title ) = @_; $self->{_title} = $title if defined($title); return ( $self->{_title} ); } sub print { my ($self) = @_; # we will call the print method of the parent class $self->SUPER::print; $self->address->print; } 1; #### use strict; use warnings; use diagnostics; use Employee; #create Employee class instance my $khurt = eval { new Employee(); } or die ($@); #set object attributes $khurt->firstName('Khurt'); $khurt->lastName('Williams'); $khurt->id(1001); $khurt->title('Executive Director'); $khurt->address( new Address() ); $khurt->address->street('10 Anywhere Lane'); $khurt->address->city('Anytown'); $khurt->address->state('NJ'); $khurt->address->zip('12345'); #diplay Employee info $khurt->print(); #### Can't locate Address.pm in @INC (@INC contains: /script/perl/test2/modules /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /script/perl/test2/modules/Person.pm line 4. BEGIN failed--compilation aborted at /script/perl/test2/modules/Person.pm line 4. Compilation failed in require at /script/perl/test2/modules/Employee.pm line 3. BEGIN failed--compilation aborted at /script/perl/test2/modules/Employee.pm line 3. Compilation failed in require at ./first.obj line 6. BEGIN failed--compilation aborted at ./first.obj line 6 (#1) (F) You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in @INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to @INC. Or maybe you just misspelled the name of the file. See perlfunc/require and lib. Uncaught exception from user code: Can't locate Address.pm in @INC (@INC contains: /script/perl/test2/modules /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /script/perl/test2/modules/Person.pm line 4. BEGIN failed--compilation aborted at /script/perl/test2/modules/Person.pm line 4. Compilation failed in require at /script/perl/test2/modules/Employee.pm line 3. BEGIN failed--compilation aborted at /script/perl/test2/modules/Employee.pm line 3. Compilation failed in require at ./first.obj line 6. BEGIN failed--compilation aborted at ./first.obj line 6. at ./first.obj line 6