package Foo; sub new { my $class = shift; my %self = @_; return bless \%self, $class; } sub do_something { my $self = shift; print "msg is: ", $self->{msg}, "\n"; } ## Meanwhile, back on the ranch . . . erm, in the main package package main; my $foo = Foo->new( msg => "WUBBA WUBBA" ); $foo->do-something;