#!/usr/local/bin/perl CLASS1.pm package CLASS1; sub new{ my $self = {}; bless($self); return $self; } sub gettext{ #this is the method I want to inherit return "I come from CLASS1.pm\n"; }; return 1; #### #!/usr/local/bin/perl #CLASS2.pm package CLASS2; #import into the current namespace the symbol table of CLASS1 use CLASS; @ISA=qw(CLASS1); #Inherit from Class1. sub new{ my $self = CLASS1->new; #call constructor method of CLASS1 return bless($self); } #### #!/usr/local/bin/perl #TryingIt.pl use CLASS2; my $object1=CLASS2->new(); print "The object says: ",$object1->gettext(),"\n"; print "The object class is ",ref $object1, "\n"; #The object says: I come from CLASS1.pm #The object class is CLASS2 ####