#Foo.pm package Foo; sub import { *{caller().'::foo'} = \&foo } sub foo { 'bar' } 1; # $ perl -MO=Bytecode,-H,-ofoo -E 'use Foo; say foo' # -e syntax OK # $ perl foo # bar