sub my_func { local *OtherPackage::routine = sub { ... } # now use OtherPackage }