sub printkey { my ($self,$key) = @_; print "$key : ", $self->{my_hash}->{$key},"}\n"; }; # Now set up the faked object. The real one would be # with more meat and a constructor I guess. $self = {}; # $self is an anonymous hash (reference) $self->{my_hash} = {}; # so is $self->{my_hash} $self->{my_hash}->{Hello} = "World"; printkey( $self, "Hello" );