in reply to Overriding built-in function works only via import()?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Overriding built-in function works only via import()?
by perlancar (Hermit) on Feb 01, 2018 at 10:07 UTC |