in reply to localizing __PACKAGE__?

No, doing it in foo is too late, and short of actually overriding main::hello, you cannot do what you want. The code to hello() is resolved inside the anon sub, not inside foo(). Said sub is compiled inside the package main, so a call to an unqualified sub will be resolved in the package.

You may want to do something like:

foo(sub {package other; hello()}); # Always calls other::hello
or
sub foo {package other; $_[0]->()} foo(sub {no strict 'refs'; &{(caller)[0] . "::hello"}()}); # Always ca +ll hello in callers namespace.