package Bar; use strict; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(the_mascot); my $value = "camel"; my $data = \$value; sub the_mascot { print<<"END"; Hey, did you know that Perl's mascot is a: $$data END } sub new { my $class = shift; my $self = {}; $self->{ANIMAL} = $data; bless($self, $class); return $self; } sub animal { my $self = shift; ${$self->{ANIMAL}} = $_[0]; } sub mascot { the_mascot(); } 1; #### use strict; use Bar qw(the_mascot); my $a = new Bar; $a->animal("parrot"); $a->mascot; the_mascot(); $a->animal("firebird"); $a->mascot(); #output __END__ Hey, did you know that Perl's mascot is a: parrot Hey, did you know that Perl's mascot is a: parrot Hey, did you know that Perl's mascot is a: firebird