Skip to content

Instantly share code, notes, and snippets.

@belden
Created May 9, 2012 17:20
Show Gist options
  • Save belden/2646897 to your computer and use it in GitHub Desktop.
Save belden/2646897 to your computer and use it in GitHub Desktop.
Perl functions by prototype
#!/usr/bin/env perl
use strict;
use warnings;
open my $fh, 'perldoc perlfunc |' or die "perldoc: $!\n";
my %functions_by_prototype;
my %seen;
while (<$fh>) {
if (/Perl Functions by Category/ ... /Portability/) {
/",/ or next;
chomp;
s/"//g;
s/ *//g;
s/\*//g;
my @funcs = split /,/, $_;
foreach (@funcs) {
next if $seen{$_}++;
my $proto;
local $@;
eval "\$proto = prototype('CORE::$_')";
if ($@) {
$proto = 'nothing available';
} elsif (! defined $proto) {
$proto = 'none';
} else {
$proto = "($proto)";
}
push @{$functions_by_prototype{$proto}}, $_;
}
}
}
foreach my $proto (sort { $a cmp $b } keys %functions_by_prototype) {
print join "\n", $proto, map { "\t$_" } sort { $a cmp $b } @{$functions_by_prototype{$proto}};
print "\n\n";
}
# this is for Perl v5.10.1
#
($$$$$)
msgrcv
($$$$)
semctl
shmread
shmwrite
($$$)
msgctl
msgsnd
semget
setpriority
shmctl
shmget
vec
($$)
atan2
crypt
gethostbyaddr
getnetbyaddr
getpriority
getservbyname
getservbyport
link
msgget
rename
semop
symlink
truncate
waitpid
($$;$$)
substr
($$;$)
index
rindex
($)
getgrgid
getgrnam
gethostbyname
getnetbyname
getprotobyname
getprotobynumber
getpwnam
getpwuid
sethostent
setnetent
setprotoent
setservent
($;$)
bless
unpack
($@)
formline
join
pack
sprintf
syscall
()
break
continue
dump
endgrent
endhostent
endnetent
endprotoent
endpwent
endservent
fork
getgrent
gethostent
getlogin
getnetent
getppid
getprotoent
getpwent
getservent
setgrent
setpwent
time
times
wait
wantarray
(*$$$)
setsockopt
socket
(*$$)
fcntl
getsockopt
ioctl
seek
sysseek
(*$$;$)
send
sysopen
(*$)
bind
connect
flock
listen
opendir
seekdir
shutdown
(*$;$$)
syswrite
(*)
closedir
fileno
getpeername
getsockname
lstat
readdir
rewinddir
stat
telldir
(**$$$)
socketpair
(**)
accept
pipe
(*;$)
binmode
(*;$@)
open
(*\$$$)
recv
(*\$$;$)
read
sysread
(;$$)
setpgrp
(;$)
caller
chdir
exit
getpgrp
gmtime
localtime
rand
reset
sleep
srand
umask
(;*)
close
eof
getc
readline
select
tell
write
(;\@)
pop
shift
(@)
chmod
chown
die
kill
reverse
unlink
warn
(\$)
lock
(\%$$)
dbmopen
(\%)
dbmclose
each
keys
values
(\@;$$@)
splice
(\@@)
push
unshift
(_)
abs
alarm
chr
chroot
cos
exp
hex
int
lc
lcfirst
length
log
oct
ord
quotemeta
readlink
readpipe
ref
rmdir
sin
sqrt
uc
ucfirst
(_;$)
mkdir
none
chomp
chop
default
defined
delete
do
eval
exec
exists
format
given
glob
goto
grep
last
local
map
my
next
no
our
package
pos
print
printf
prototype
redo
require
return
say
scalar
sort
split
state
study
sub
system
tie
tied
undef
untie
use
when
nothing available
-X
import
m//
q//
qq//
qr//
qw//
qx//
s///
tr///
y///
@belden
Copy link
Author

belden commented May 9, 2012

Functions listed as 'none' or 'nothing available' can't be overridden using the techniques laid out in 'perldoc CORE' (http://search.cpan.org/perldoc?CORE). Functions with an actual prototype can be overridden.

If you don't provide a matching prototype on your overridden function, Perl will toss a variety of errors at you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment