To unambiguously refer to the built-in form, precede the built-in name with the special package qualifier CORE::. For example, saying CORE::open() always refers to the built-in open(), even if the current package has imported some other subroutine called &open() from elsewhere. Even though it looks like a regular function call, it isn't: you can't take a reference to it, such as the incorrect \&CORE::open might appear to produce.I think there's nothing wrong with wrapping print in a sub like you have. The only inelegant thing is that you are creating a new named sub. Why not use an anonymous sub like this?
Or even make myprint anonymous as well:sub myprint { print "MYPRINT: ", @_; } my $printfunc = $condition ? sub { print @_; } : \&myprint; $printfunc->("hello world\n");
my $printfunc = $condition ? sub { print @_; } : sub { print "MYPRINT: ", @_; }
blokhead
In reply to Re: Reference to functions in CORE:: pseudo package?
by blokhead
in thread Reference to functions in CORE:: pseudo package?
by saintmike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |