package MyPackage; use strict; our $VERSION = 0; use Tie::Hash; use base qw(Tie::ExtraHash); # OO Interface sub new { my $class = ref($_[0]) || $_[0]; my $self = bless {}, $class; tie %$self, $class; } sub to_string { join ' ', %{$_[0]}; } # Tie interface sub STORE { $_[0][0]{$_[1]} = ucfirst($_[2]); } 1; #### #!/usr/bin/perl -w use strict; use MyPackage; my $p = MyPackage->new(); $$p{Hello} = "world"; print $p->to_string, "\n";