Closed stuart-little closed 3 years ago
Perl builtin functions are not actually in the main namespace. Their proper full name is e.g. CORE::print
. However, CORE
is not really a package and CORE::
is merely a syntactic hint to the compiler. Furthermore, many builtin functions are not even available as Perl functions at all. You cannot e.g. call print
with ampersand syntax: &CORE::print("Hello World")
. This will fail with Undefined subroutine &CORE::print called
while e.g. &CORE::hex("F")
works just fine.
While there would probably be some elaborate way to get at these builtin C functions, I just don't think it'd be worth to support them. After all Raku's print
function works just fine ;)
It's been a while since I dabbled in Perl, but this does seem to give something:
$ perl -E 'say \&CORE::GLOBAL::print'
CODE(0x7fb946803418)
But then, so does this:
> perl -E 'say \&CORE::NoIReallyDontExist::print'
CODE(0x561106d214d8)
Ah, indeed, I was just remembering tricks like this:
$ perl -E 'BEGIN { *CORE::GLOBAL::bless = sub { say "foo" } }; bless 42'
foo
But that doesn't work for print
.
Fair enough, but the documentation tripped me up. Have a look at the second code display here: it's the code that failed for me..
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.call('print', 'Hello World');
If this is expected to fail, then surely the documentation, at least, needs fixing?
I have the following script:
Running it errors out: