Created
May 9, 2012 17:20
-
-
Save belden/2646897 to your computer and use it in GitHub Desktop.
Perl functions by prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
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/// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.