package Foo; sub do_something { print scalar caller, "\n"; } sub import { my $target = caller; no strict 'refs'; *{"$target:\:do_something"} = \&do_something; } 1;