Skip Menu |

This queue is for tickets about the Perl-Builtins CPAN distribution.

Report information
The Basics
Id: 99845
Status: resolved
Priority: 0/
Queue: Perl-Builtins

People
Owner: Nobody in particular
Requestors: JNBEK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.03



Subject: A better more portable way to acquire the list of builtins
I notice you're hardcoding the function list, instead it'd be better to grok the list out of Pod::Functions demostrated with the following one-liner: % perl -MPod::Functions -MData::Dumper -e'print Dumper(\%Kinds);' # See attached for full output You can iterate the hash keys and then the resulting hashref: use Pod::Functions; my @list = (); foreach my $key (keys %Kinds) { map { push @list, $_ } @{%Kinds{$key}}; } # Optionally sort the functions: @list = sort @list; This will also be portable back to Perl 5.8 and will just always work regardless of the Perl version. -- John D Jones III
Subject: builtins.txt
$VAR1 = { 'HASH' => [ 'delete', 'each', 'exists', 'keys', 'values' ], 'Namespace' => [ 'caller', 'import', 'local', 'my', 'our', 'package', 'state', 'use' ], 'SysV' => [ 'msgctl', 'msgget', 'msgrcv', 'msgsnd', 'semctl', 'semget', 'semop', 'shmctl', 'shmget', 'shmread', 'shmwrite' ], 'LIST' => [ 'grep', 'join', 'map', 'qw/STRING/', 'reverse', 'sort', 'unpack' ], 'ARRAY' => [ 'each', 'keys', 'pop', 'push', 'shift', 'splice', 'unshift', 'values' ], 'String' => [ 'chomp', 'chop', 'chr', 'crypt', 'fc', 'hex', 'index', 'lc', 'lcfirst', 'length', 'oct', 'ord', 'pack', 'q/STRING/', 'qq/STRING/', 'reverse', 'rindex', 'sprintf', 'substr', 'tr///', 'uc', 'ucfirst', 'y///' ], 'Regexp' => [ 'm//', 'pos', 'qr/STRING/', 'quotemeta', 's///', 'split', 'study' ], 'Math' => [ 'abs', 'atan2', 'cos', 'exp', 'hex', 'int', 'log', 'oct', 'rand', 'sin', 'sqrt', 'srand' ], 'Time' => [ 'gmtime', 'localtime', 'time', 'times' ], 'File' => [ '-X', 'chdir', 'chmod', 'chown', 'chroot', 'fcntl', 'glob', 'ioctl', 'link', 'lstat', 'mkdir', 'open', 'opendir', 'readlink', 'rename', 'rmdir', 'stat', 'symlink', 'sysopen', 'umask', 'unlink', 'utime' ], 'Network' => [ 'endprotoent', 'endservent', 'gethostbyaddr', 'gethostbyname', 'gethostent', 'getnetbyaddr', 'getnetbyname', 'getnetent', 'getprotobyname', 'getprotobynumber', 'getprotoent', 'getservbyname', 'getservbyport', 'getservent', 'sethostent', 'setnetent', 'setprotoent', 'setservent' ], 'I/O' => [ 'binmode', 'close', 'closedir', 'dbmclose', 'dbmopen', 'die', 'eof', 'fileno', 'flock', 'format', 'getc', 'print', 'printf', 'read', 'readdir', 'readline', 'rewinddir', 'say', 'seek', 'seekdir', 'select', 'syscall', 'sysread', 'sysseek', 'syswrite', 'tell', 'telldir', 'truncate', 'warn', 'write' ], 'Misc' => [ 'defined', 'formline', 'lock', 'prototype', 'reset', 'scalar', 'undef' ], 'Flow' => [ 'break', 'caller', 'continue', 'die', 'do', 'dump', 'eval', 'evalbytes', 'exit', '__FILE__', 'goto', 'last', '__LINE__', 'next', '__PACKAGE__', 'redo', 'return', 'sub', '__SUB__', 'wantarray' ], 'Objects' => [ 'bless', 'dbmclose', 'dbmopen', 'package', 'ref', 'tie', 'tied', 'untie', 'use' ], 'Socket' => [ 'accept', 'bind', 'connect', 'getpeername', 'getsockname', 'getsockopt', 'listen', 'recv', 'send', 'setsockopt', 'shutdown', 'socket', 'socketpair' ], 'Process' => [ 'alarm', 'exec', 'fork', 'getpgrp', 'getppid', 'getpriority', 'kill', 'pipe', 'qx/STRING/', 'readpipe', 'setpgrp', 'setpriority', 'sleep', 'system', 'times', 'wait', 'waitpid' ], 'Binary' => [ 'pack', 'read', 'syscall', 'sysread', 'sysseek', 'syswrite', 'unpack', 'vec' ], 'User' => [ 'endgrent', 'endhostent', 'endnetent', 'endpwent', 'getgrent', 'getgrgid', 'getgrnam', 'getlogin', 'getpwent', 'getpwnam', 'getpwuid', 'setgrent', 'setpwent' ], 'Modules' => [ 'do', 'import', 'no', 'package', 'require', 'use' ] };
On Mon Oct 27 18:35:02 2014, JNBEK wrote: Show quoted text
> > This will also be portable back to Perl 5.8 and will just always work > regardless of the Perl version. > > -- John D Jones III
Sorry to clarify, the Pod::Functions module is part of CORE Perl since 5.8 and remains there still.
On Mon Oct 27 18:35:02 2014, JNBEK wrote: Show quoted text
> I notice you're hardcoding the function list, instead it'd be better
Show quoted text
> map { push @list, $_ } @{%Kinds{$key}}; > }
BAHH!!! A Syntax error!! That line should read: map { push @list, $_ } @{$Kinds{$key}}; Guess I need to put my fingers on a diet...