Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If a CORE subroutine has a prototype<code>*</code> it can be replaced. Replacing a function in the current namespace is simple enough. </p> <pre><code>#!/usr/bin/perl use strict; use warnings; use subs 'chdir'; sub chdir(;$) { my $dir = shift; $dir = $ENV{HOME} unless defined $dir; print "changing dir to $dir\n"; CORE::chdir $dir; } chdir("/tmp"); chdir; </code></pre> <p>If you want to override the function for all modules as well you can read the <a href="http://perldoc.perl.org/CORE.html#OVERRIDING-CORE-FUNCTIONS" rel="noreferrer">docs</a>.</p> <p><code>*</code> Here is code to test every function in Perl 5.10 (it will work on earlier versions as well). Note, some functions can be overridden that this program will tell you can't be, but the overridden function will not behave in the same way as the original function.</p> <p>from perldoc -f prototype</p> <blockquote> <p>If the builtin is not overridable (such as qw//) or if its arguments cannot be adequately expressed by a prototype (such as system), prototype() returns undef, because the builtin does not really behave like a Perl function</p> </blockquote> <pre><code>#!/usr/bin/perl use strict; use warnings; for my $func (map { split } &lt;DATA&gt;) { my $proto; #skip functions not in this version of Perl next unless eval { $proto = prototype "CORE::$func"; 1 }; if ($proto) { print "$func has a prototype of $proto\n"; } else { print "$func cannot be overridden\n"; } } __DATA__ abs accept alarm atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir connect continue cos crypt dbmclose defined delete die do dump each endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyhost getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt glob gmtime goto grep hex import index int ioctl join keys kill last lc lcfirst length link listen local localtime lock log lstat m map mkdir msgctl msgget msgrcv msgsnd my next no oct open opendir ord our pack package pipe pop pos print printf prototype push q qq qr quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir s say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unlink unpack unshift untie use utime values vec wait waitpid wantarray warn write y -r -w -x -o -R -W -X -O -e -z -s -f -d -l -p -S -b -c -t -u -g -k -T -B -M -A -C </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload