in reply to Re: Reference to functions in CORE:: pseudo package?
in thread Reference to functions in CORE:: pseudo package?

AFAIK, it only works to override keywords at compile time (i.e. in BEGIN or with use). That kinda ruins it for scoped override like you have. (Though you may be able to use a named sub and temporarily replace the sub with local).

Update: Zaxo's code does work, though I don't understand why. Perhaps something special about glob? Trying to override a different function works the way I recall:

$ # override in BEGIN block works $ perl -e'BEGIN { *CORE::GLOBAL::sin = sub { "a" } } print sin(0)' a $ # override at runtime doesn't have any effect $ perl -e'*CORE::GLOBAL::sin = sub { "a" }; print sin(0)' 0 $ # using local, still no effect $ perl -e'{ local *CORE::GLOBAL::sin = sub { "a" }; print sin(0) } pri +nt sin(0) ' 00