package Person; use strict; sub new { my $class = shift; my $self = {}; return bless($self, $class); } sub name { my $self = shift; $self->{NAME} = shift if @_; return $self->{AGE}; } sub age { my $self = shift; $self->{AGE} = shift if @_; return $self->{AGE}; } sub exclaim { my $self = shift; printf "I'm %s and i'm %d years old!\n",$self->{NAME},$self->{AGE}; } 1; # Modules need to end in a true value #### #!/usr/bin/perl use strict; use Person; my $foo = Person->new(); $foo->name("Stefan"); $foo->age(20); my $bar = Person->new(); $bar->name("Barney"); $bar->age(3); $bar->exclaim(); $foo->exclaim();