📄 core.pod
字号:
=head1 NAMECORE - Pseudo-namespace for Perl's core routines=head1 SYNOPSIS BEGIN { *CORE::GLOBAL::hex = sub { 1; }; } print hex("0x50"),"\n"; # prints 1 print CORE::hex("0x50"),"\n"; # prints 80=head1 DESCRIPTIONThe C<CORE> namespace gives access to the original built-in functions ofPerl. There is no C<CORE> package, and therefore you do not need to use orrequire an hypothetical "CORE" module prior to accessing routines in thisnamespace.A list of the built-in functions in Perl can be found in L<perlfunc>.=head1 OVERRIDING CORE FUNCTIONSTo override a Perl built-in routine with your own version, you need toimport it at compile-time. This can be conveniently achieved with theC<subs> pragma. This will affect only the package in which you've importedthe said subroutine: use subs 'chdir'; sub chdir { ... } chdir $somewhere;To override a built-in globally (that is, in all namespaces), you need toimport your function into the C<CORE::GLOBAL> pseudo-namespace at compiletime: BEGIN { *CORE::GLOBAL::hex = sub { # ... your code here }; }The new routine will be called whenever a built-in function is calledwithout a qualifying package: print hex("0x50"),"\n"; # prints 1In both cases, if you want access to the original, unaltered routine, usethe C<CORE::> prefix: print CORE::hex("0x50"),"\n"; # prints 80=head1 AUTHORThis documentation provided by Tels <nospam-abuse@bloodgate.com> 2007.=head1 SEE ALSOL<perlsub>, L<perlfunc>.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -