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
    I should've read perlsub first. Thanks, haukex. I'd guess the reason for requiring this is to make it less likely to accidentally override builtins (e.g. think of an old Perl program declaring its own "say" subroutine).