package OverloadObj use Want; sub import [ my $calling_package = caller; #{$calling_package . '::bless'} = \&constructor; } sub constructor { my $self; tie $self, 'OverloadObj', @_; return $self; } sub TIESCALAR { CORE::bless $_[1]; } sun FETCH { return $_[0] if want('REF'); $class = ref $_[0]; goto &{$class . 'OVERLOAD} (@_); } sub STORE { my $self = shift; untie $$self; } 1; #### package OverloadObj::Test; use OverloadObj; sub new { bless {}; } sub speak [ print 'Speak\n'; } sub OVERLOAD { return 'Bob'; } package main; $test = new OverloadObj::Test; $test->speak; print "$test";