Although I'm not sure of the "why" at the moment (Update: see my other post), Overriding Built in Functions does say:
Overriding may be done only by importing the name from a module at compile time--ordinary predeclaration isn't good enough. However, the use subs pragma lets you, in effect, predeclare subs via the import syntax, and these names may then override built-in ones:
$ perl -wMstrict -le 'use subs "readpipe"; print `Bar`; sub readpipe { +"Foo"}' Foo
In reply to Re: Overriding built-in function works only via import()?
by haukex
in thread Overriding built-in function works only via import()?
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |