Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

core(3pm) [osx man page]

CORE(3pm)						 Perl Programmers Reference Guide						 CORE(3pm)

NAME
CORE - Namespace for Perl's core routines SYNOPSIS
BEGIN { *CORE::GLOBAL::hex = sub { 1; }; } print hex("0x50")," "; # prints 1 print CORE::hex("0x50")," "; # prints 80 CORE::say "yes"; # prints yes BEGIN { *shove = &CORE::push; } shove @array, 1,2,3; # pushes on to @array DESCRIPTION
The "CORE" namespace gives access to the original built-in functions of Perl. The "CORE" package is built into Perl, and therefore you do not need to use or require a hypothetical "CORE" module prior to accessing routines in this namespace. A list of the built-in functions in Perl can be found in perlfunc. For all Perl keywords, a "CORE::" prefix will force the built-in function to be used, even if it has been overridden or would normally require the feature pragma. Despite appearances, this has nothing to do with the CORE package, but is part of Perl's syntax. For many Perl functions, the CORE package contains real subroutines. This feature is new in Perl 5.16. You can take references to these and make aliases. However, some can only be called as barewords; i.e., you cannot use ampersand syntax (&foo) or call them through references. See the "shove" example above. These subroutines exist for all overridable keywords, except for "dump" and the infix operators. Calling with ampersand syntax and through references does not work for the following functions, as they have special syntax that cannot always be translated into a simple list (e.g., "eof" vs "eof()"): "chdir", "chomp", "chop", "each", "eof", "exec", "keys", "lstat", "pop", "push", "shift", "splice", "stat", "system", "truncate", "unlink", "unshift", "values" OVERRIDING CORE FUNCTIONS
To override a Perl built-in routine with your own version, you need to import it at compile-time. This can be conveniently achieved with the "subs" pragma. This will affect only the package in which you've imported the said subroutine: use subs 'chdir'; sub chdir { ... } chdir $somewhere; To override a built-in globally (that is, in all namespaces), you need to import your function into the "CORE::GLOBAL" pseudo-namespace at compile time: BEGIN { *CORE::GLOBAL::hex = sub { # ... your code here }; } The new routine will be called whenever a built-in function is called without a qualifying package: print hex("0x50")," "; # prints 1 In both cases, if you want access to the original, unaltered routine, use the "CORE::" prefix: print CORE::hex("0x50")," "; # prints 80 AUTHOR
This documentation provided by Tels <nospam-abuse@bloodgate.com> 2007. SEE ALSO
perlsub, perlfunc. perl v5.16.2 2012-10-25 CORE(3pm)

Check Out this Related Man Page

File::stat(3pm) 					 Perl Programmers Reference Guide					   File::stat(3pm)

NAME
File::stat - by-name interface to Perl's built-in stat() functions SYNOPSIS
use File::stat; $st = stat($file) or die "No $file: $!"; if ( ($st->mode & 0111) && $st->nlink > 1) ) { print "$file is executable with lotsa links "; } if ( -x $st ) { print "$file is executable "; } use Fcntl "S_IRUSR"; if ( $st->cando(S_IRUSR, 1) ) { print "My effective uid can read $file "; } use File::stat qw(:FIELDS); stat($file) or die "No $file: $!"; if ( ($st_mode & 0111) && ($st_nlink > 1) ) { print "$file is executable with lotsa links "; } DESCRIPTION
This module's default exports override the core stat() and lstat() functions, replacing them with versions that return "File::stat" objects. This object has methods that return the similarly named structure field name from the stat(2) function; namely, dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks. As of version 1.02 (provided with perl 5.12) the object provides "-X" overloading, so you can call filetest operators ("-f", "-x", and so on) on it. It also provides a "->cando" method, called like $st->cando( ACCESS, EFFECTIVE ) where ACCESS is one of "S_IRUSR", "S_IWUSR" or "S_IXUSR" from the Fcntl module, and EFFECTIVE indicates whether to use effective (true) or real (false) ids. The method interprets the "mode", "uid" and "gid" fields, and returns whether or not the current process would be allowed the specified access. If you don't want to use the objects, you may import the "->cando" method into your namespace as a regular function called "stat_cando". This takes an arrayref containing the return values of "stat" or "lstat" as its first argument, and interprets it for you. You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that this still overrides your stat() and lstat() functions.) Access these fields as variables named with a preceding "st_" in front their method names. Thus, "$stat_obj->dev()" corresponds to $st_dev if you import the fields. To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package. BUGS
As of Perl 5.8.0 after using this module you cannot use the implicit $_ or the special filehandle "_" with stat() or lstat(), trying to do so leads into strange errors. The workaround is for $_ to be explicit my $stat_obj = stat $_; and for "_" to explicitly populate the object using the unexported and undocumented populate() function with CORE::stat(): my $stat_obj = File::stat::populate(CORE::stat(_)); ERRORS
-%s is not implemented on a File::stat object The filetest operators "-t", "-T" and "-B" are not implemented, as they require more information than just a stat buffer. WARNINGS
These can all be disabled with no warnings "File::stat"; File::stat ignores use filetest 'access' You have tried to use one of the "-rwxRWX" filetests with "use filetest 'access'" in effect. "File::stat" will ignore the pragma, and just use the information in the "mode" member as usual. File::stat ignores VMS ACLs VMS systems have a permissions structure that cannot be completely represented in a stat buffer, and unlike on other systems the builtin filetest operators respect this. The "File::stat" overloads, however, do not, since the information required is not available. NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. AUTHOR
Tom Christiansen perl v5.12.1 2010-04-26 File::stat(3pm)
Man Page