package ForeignModule; sub NEXT { print scalar caller } 1; #### package Foo; # there is no do_something sub import { my $target = caller; no strict 'refs'; *{"$target:\:do_something"} = \&ForeignModule::NEXT; } 1; #### package main; use strict; use warnings; use Foo; do_something();