Consequently it shouldn't work if the import() is called in the same package, right? (Untested)
Yep, looks like it:
$ perl -wle '{ package Foo; sub import { *{caller."::readpipe"} = sub {"Foo"} } } BEGIN { Foo->import() } print `xyz`' Foo $ perl -wle 'sub import { *{caller."::readpipe"} = sub {"Foo"} } BEGIN { main->import() } print `xyz`' Can't exec "xyz": No such file or directory at -e line 2.
In reply to Re^3: Overriding built-in function works only via import()?
by haukex
in thread Overriding built-in function works only via import()?
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |