Does Perl provide any way to programmatically list the "names" of all the Perl built-in functions? By "name" I mean the string, e.g. "y", that when appended to the string "CORE::" can be given to CORE::prototype as its argument to obtain the prototype of the corresponding Perl built-in.
Some Perl built-ins are overridable, others aren't. What is the best way to find out which are the ones that cannot be overridden?
For all non-overridable built-ins CORE::foo, the expression CORE::prototype('CORE::foo') returns undef, but the converse is not true. For example, CORE::prototype('CORE::system') returns undef, but CORE::system is overridable, as shown by the following snippet:
For other built-ins with a CORE::prototype return value of undef, however, the above trick won't work. Either the overriding function will be silently ignored (as happens if one tries to override CORE::print), or Perl will react more spectacularly, such as seg-faulting if one tries to override CORE::require.use strict; use warnings; use subs 'system'; sub system { warn "this is not the real system\n" } warn "about to test system\n"; system 'date'; warn "done testing system\n"; __END__ about to test system this is not the real system done testing system
So, is there a way to determine which built-ins are overridable, other than trial and error?
(Both questions prompted only by curiosity.)
the lowliest monk
In reply to 2 Qs: introspection & overriding built-ins by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |