This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Teach Pod::Functions that each, keys and values also operate on arrays.
[perl5.git] / lib / Pod / Functions.pm
CommitLineData
d93fce09 1package Pod::Functions;
66c981cf 2use strict;
cb1a09d0 3
66c981cf 4=head1 NAME
cb1a09d0 5
66c981cf
AT
6Pod::Functions - Group Perl's functions a la perlfunc.pod
7
8=head1 SYNOPSIS
9
0791bc7e 10 use Pod::Functions;
66c981cf
AT
11
12 my @misc_ops = @{ $Kinds{ 'Misc' } };
13 my $misc_dsc = $Type_Description{ 'Misc' };
14
15or
16
17 perl /path/to/lib/Pod/Functions.pm
18
19This will print a grouped list of Perl's functions, like the
20L<perlfunc/"Perl Functions by Category"> section.
21
22=head1 DESCRIPTION
23
24It exports the following variables:
25
26=over 4
27
28=item %Kinds
29
3c4b39be 30This holds a hash-of-lists. Each list contains the functions in the category
66c981cf
AT
31the key denotes.
32
33=item %Type
34
3c4b39be
PF
35In this hash each key represents a function and the value is the category.
36The category can be a comma separated list.
66c981cf
AT
37
38=item %Flavor
39
40In this hash each key represents a function and the value is a short
41description of that function.
42
43=item %Type_Description
44
3c4b39be
PF
45In this hash each key represents a category of functions and the value is
46a short description of that category.
66c981cf
AT
47
48=item @Type_Order
49
3c4b39be 50This list of categories is used to produce the same order as the
66c981cf
AT
51L<perlfunc/"Perl Functions by Category"> section.
52
53=back
54
66c981cf
AT
55=cut
56
3017d6ff 57our $VERSION = '1.05';
b75c8c73 58
cb1a09d0
AD
59require Exporter;
60
66c981cf
AT
61our @ISA = qw(Exporter);
62our @EXPORT = qw(%Kinds %Type %Flavor %Type_Description @Type_Order);
cb1a09d0 63
b75c8c73
MS
64our(%Kinds, %Type, %Flavor);
65
66our %Type_Description = (
cb1a09d0 67 'ARRAY' => 'Functions for real @ARRAYs',
3017d6ff 68 'Binary' => 'Functions for fixed-length data or records',
cb1a09d0 69 'File' => 'Functions for filehandles, files, or directories',
3017d6ff 70 'Flow' => 'Keywords related to the control flow of your Perl program',
cb1a09d0
AD
71 'HASH' => 'Functions for real %HASHes',
72 'I/O' => 'Input and output functions',
73 'LIST' => 'Functions for list data',
74 'Math' => 'Numeric functions',
75 'Misc' => 'Miscellaneous functions',
3017d6ff 76 'Modules' => 'Keywords related to Perl modules',
cb1a09d0 77 'Network' => 'Fetching network info',
3017d6ff 78 'Objects' => 'Keywords related to classes and object-orientation',
cb1a09d0
AD
79 'Process' => 'Functions for processes and process groups',
80 'Regexp' => 'Regular expressions and pattern matching',
81 'Socket' => 'Low-level socket functions',
82 'String' => 'Functions for SCALARs or strings',
8d9a4276 83 'Switch' => 'Keywords related to the switch feature',
cb1a09d0
AD
84 'SysV' => 'System V interprocess communication functions',
85 'Time' => 'Time-related functions',
86 'User' => 'Fetching user and group info',
3017d6ff 87 'Namespace' => 'Keywords related to scoping',
cb1a09d0
AD
88);
89
b75c8c73 90our @Type_Order = qw{
cb1a09d0
AD
91 String
92 Regexp
93 Math
94 ARRAY
95 LIST
96 HASH
97 I/O
98 Binary
99 File
100 Flow
8d9a4276 101 Switch
cb1a09d0
AD
102 Namespace
103 Misc
104 Process
105 Modules
106 Objects
107 Socket
108 SysV
109 User
110 Network
111 Time
112};
113
114while (<DATA>) {
115 chomp;
116 s/#.*//;
117 next unless $_;
b75c8c73 118 my($name, $type, $text) = split " ", $_, 3;
cb1a09d0
AD
119 $Type{$name} = $type;
120 $Flavor{$name} = $text;
b75c8c73 121 for my $t ( split /[,\s]+/, $type ) {
66c981cf 122 push @{$Kinds{$t}}, $name;
cb1a09d0 123 }
66c981cf 124}
cb1a09d0 125
3e92a254
GS
126close DATA;
127
66c981cf 128my( $typedesc, $list );
cb1a09d0 129unless (caller) {
b75c8c73 130 foreach my $type ( @Type_Order ) {
66c981cf
AT
131 $list = join(", ", sort @{$Kinds{$type}});
132 $typedesc = $Type_Description{$type} . ":";
cb1a09d0
AD
133 write;
134 }
135}
136
137format =
138
139^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
140 $typedesc
141~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
142 $typedesc
143 ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
144 $list
145.
146
66c981cf 1471;
cb1a09d0
AD
148
149__DATA__
150-X File a file test (-r, -x, etc)
151abs Math absolute value function
152accept Socket accept an incoming socket connect
153alarm Process schedule a SIGALRM
19799a22 154atan2 Math arctangent of Y/X in the range -PI to PI
cb1a09d0 155bind Socket binds an address to a socket
19799a22 156binmode I/O prepare binary files for I/O
cb1a09d0 157bless Objects create an object
9e5f1ef1 158break Switch Break out of a C<given()> block
cb1a09d0
AD
159caller Flow,Namespace get context of the current subroutine call
160chdir File change your current working directory
161chmod File changes the permissions on a list of files
162chomp String remove a trailing record separator from a string
163chop String remove the last character from a string
b23d1689 164chown File change the ownership on a list of files
cb1a09d0
AD
165chr String get character this number represents
166chroot File make directory new root for path lookups
167close I/O close file (or pipe or socket) handle
168closedir I/O close directory handle
19799a22 169connect Socket connect to a remote socket
8d9a4276 170continue Flow,Switch optional trailing block in a while or foreach
cb1a09d0
AD
171cos Math cosine function
172crypt String one-way passwd-style encryption
173dbmclose Objects,I/O breaks binding on a tied dbm file
174dbmopen Objects,I/O create binding on a tied dbm file
9e5f1ef1 175default Switch XXX RT #108848
cb1a09d0
AD
176defined Misc test whether a value, variable, or function is defined
177delete HASH deletes a value from a hash
178die I/O,Flow raise an exception or bail out
179do Flow,Modules turn a BLOCK into a TERM
180dump Misc,Flow create an immediate core dump
49a1179c 181each ARRAY,HASH retrieve the next key/value pair from a hash
cb1a09d0
AD
182endgrent User be done using group file
183endhostent User be done using hosts file
184endnetent User be done using networks file
185endprotoent Network be done using protocols file
186endpwent User be done using passwd file
187endservent Network be done using services file
188eof I/O test a filehandle for its end
19799a22 189eval Flow,Misc catch exceptions or compile and run code
9e5f1ef1 190evalbytes Flow,Misc similar to string eval, but intend to parse a bytestream
cb1a09d0
AD
191exec Process abandon this program to run another
192exists HASH test whether a hash key is present
193exit Flow terminate this program
194exp Math raise I<e> to a power
9e5f1ef1 195fc String return casefolded version of a string
19799a22 196fcntl File file control system call
9e5f1ef1 197__FILE__ Flow the name of the current source file
cb1a09d0
AD
198fileno I/O return file descriptor from filehandle
199flock I/O lock an entire file with an advisory lock
200fork Process create a new process just like this one
201format I/O declare a picture format with use by the write() function
202formline Misc internal function used for formats
3017d6ff 203getc I/O get the next character from the filehandle
cb1a09d0
AD
204getgrent User get next group record
205getgrgid User get group record given group user ID
206getgrnam User get group record given group name
207gethostbyaddr Network get host record given its address
208gethostbyname Network get host record given name
209gethostent Network get next hosts record
210getlogin User return who logged in at this tty
211getnetbyaddr Network get network record given its address
212getnetbyname Network get networks record given name
213getnetent Network get next networks record
19799a22 214getpeername Socket find the other end of a socket connection
cb1a09d0
AD
215getpgrp Process get process group
216getppid Process get parent process ID
217getpriority Process get current nice value
218getprotobyname Network get protocol record given name
219getprotobynumber Network get protocol record numeric protocol
220getprotoent Network get next protocols record
221getpwent User get next passwd record
222getpwnam User get passwd record given user login name
223getpwuid User get passwd record given user ID
224getservbyname Network get services record given its name
225getservbyport Network get services record given numeric port
226getservent Network get next services record
227getsockname Socket retrieve the sockaddr for a given socket
228getsockopt Socket get socket options on a given socket
9e5f1ef1 229given Switch XXX RT #108848
cb1a09d0
AD
230glob File expand filenames using wildcards
231gmtime Time convert UNIX time into record or string using Greenwich time
232goto Flow create spaghetti code
233grep LIST locate elements in a list test true against a given criterion
234hex Math,String convert a string to a hexadecimal number
235import Modules,Namespace patch a module's namespace into your own
236index String find a substring within a string
237int Math get the integer portion of a number
238ioctl File system-dependent device control system call
239join LIST join a list into a string using a separator
49a1179c 240keys ARRAY,HASH retrieve list of indices from a hash
cb1a09d0
AD
241kill Process send a signal to a process or process group
242last Flow exit a block prematurely
243lc String return lower-case version of a string
244lcfirst String return a string with just the next letter in lower case
245length String return the number of bytes in a string
9e5f1ef1 246__LINE__ Flow the current source line number
b23d1689 247link File create a hard link in the filesystem
cb1a09d0
AD
248listen Socket register your socket as a server
249local Misc,Namespace create a temporary value for a global variable (dynamic scoping)
250localtime Time convert UNIX time into record or string using local time
3017d6ff 251lock Misc get a thread lock on a variable, subroutine, or method
cb1a09d0
AD
252log Math retrieve the natural logarithm for a number
253lstat File stat a symbolic link
254m// Regexp match a string with a regular expression pattern
255map LIST apply a change to a list to get back a new list with the changes
256mkdir File create a directory
257msgctl SysV SysV IPC message control operations
258msgget SysV get SysV IPC message queue
259msgrcv SysV receive a SysV IPC message from a message queue
260msgsnd SysV send a SysV IPC message to a message queue
261my Misc,Namespace declare and assign a local variable (lexical scoping)
262next Flow iterate a block prematurely
263no Modules unimport some module symbols or semantics at compile time
264package Modules,Objects,Namespace declare a separate global namespace
9e5f1ef1 265__PACKAGE__ Flow the current package
1b33caba 266prototype Flow,Misc get the prototype (if any) of a subroutine
cb1a09d0
AD
267oct String,Math convert a string to an octal number
268open File open a file, pipe, or descriptor
269opendir File open a directory
270ord String find a character's numeric representation
66c981cf 271our Misc,Namespace declare and assign a package variable (lexical scoping)
cb1a09d0
AD
272pack Binary,String convert a list into a binary representation
273pipe Process open a pair of connected filehandles
274pop ARRAY remove the last element from an array and return it
275pos Regexp find or set the offset for the last/next m//g search
276print I/O output a list to a filehandle
277printf I/O output a formatted list to a filehandle
278push ARRAY append one or more elements to an array
279q/STRING/ String singly quote a string
280qq/STRING/ String doubly quote a string
281quotemeta Regexp quote regular expression magic characters
282qw/STRING/ LIST quote a list of words
283qx/STRING/ Process backquote quote a string
5b3c99c0 284qr/STRING/ Regexp Compile pattern
cb1a09d0
AD
285rand Math retrieve the next pseudorandom number
286read I/O,Binary fixed-length buffered input from a filehandle
287readdir I/O get a directory from a directory handle
393d87f4 288readline I/O fetch a record from a file
cb1a09d0 289readlink File determine where a symbolic link is pointing
5b3c99c0 290readpipe Process execute a system command and collect standard output
cb1a09d0
AD
291recv Socket receive a message over a Socket
292redo Flow start this loop iteration over again
293ref Objects find out the type of thing being referenced
294rename File change a filename
295require Modules load in external functions from a library at runtime
296reset Misc clear all variables of a given name
297return Flow get out of a function early
298reverse String,LIST flip a string or a list
299rewinddir I/O reset directory handle
300rindex String right-to-left substring search
301rmdir File remove a directory
302s/// Regexp replace a pattern with a string
9e5f1ef1 303say I/O output a list to a filehandle, appending a newline
cb1a09d0
AD
304scalar Misc force a scalar context
305seek I/O reposition file pointer for random-access I/O
306seekdir I/O reposition directory pointer
307select I/O reset default output or do I/O multiplexing
308semctl SysV SysV semaphore control operations
309semget SysV get set of SysV semaphores
310semop SysV SysV semaphore operations
311send Socket send a message over a socket
312setgrent User prepare group file for use
313sethostent Network prepare hosts file for use
314setnetent Network prepare networks file for use
315setpgrp Process set the process group of a process
316setpriority Process set a process's nice value
317setprotoent Network prepare protocols file for use
318setpwent User prepare passwd file for use
319setservent Network prepare services file for use
320setsockopt Socket set some socket options
321shift ARRAY remove the first element of an array, and return it
322shmctl SysV SysV shared memory operations
323shmget SysV get SysV shared memory segment identifier
324shmread SysV read SysV shared memory
325shmwrite SysV write SysV shared memory
326shutdown Socket close down just half of a socket connection
19799a22 327sin Math return the sine of a number
cb1a09d0
AD
328sleep Process block for some number of seconds
329socket Socket create a socket
330socketpair Socket create a pair of sockets
331sort LIST sort a list of values
332splice ARRAY add or remove elements anywhere in an array
333split Regexp split up a string using a regexp delimiter
3017d6ff 334sprintf String formatted print into a string
cb1a09d0
AD
335sqrt Math square root function
336srand Math seed the random number generator
337stat File get a file's status information
9e5f1ef1 338state Misc,Namespace declare and assign a persistent lexical variable
cb1a09d0
AD
339study Regexp optimize input data for repeated searches
340sub Flow declare a subroutine, possibly anonymously
9e5f1ef1 341__SUB__ Flow the current subroutine, or C<undef> if not in a subroutine
b23d1689 342substr String get or alter a portion of a string
cb1a09d0
AD
343symlink File create a symbolic link to a file
344syscall I/O,Binary execute an arbitrary system call
5b3c99c0 345sysopen File open a file, pipe, or descriptor
cb1a09d0 346sysread I/O,Binary fixed-length unbuffered input from a filehandle
393d87f4 347sysseek I/O,Binary position I/O pointer on handle used with sysread and syswrite
cb1a09d0
AD
348system Process run a separate program
349syswrite I/O,Binary fixed-length unbuffered output to a filehandle
350tell I/O get current seekpointer on a filehandle
351telldir I/O get current seekpointer on a directory handle
352tie Objects bind a variable to an object class
5b3c99c0 353tied Objects get a reference to the object underlying a tied variable
cb1a09d0
AD
354time Time return number of seconds since 1970
355times Process,Time return elapsed time for self and child processes
356tr/// String transliterate a string
357truncate I/O shorten a file
358uc String return upper-case version of a string
359ucfirst String return a string with just the next letter in upper case
360umask File set file creation mode mask
361undef Misc remove a variable or function definition
362unlink File remove one link to a file
363unpack Binary,LIST convert binary structure into normal perl variables
364unshift ARRAY prepend more elements to the beginning of a list
365untie Objects break a tie binding to a variable
3017d6ff 366use Objects,Modules,Namespace load in a module at compile time and import its namespace
cb1a09d0 367utime File set a file's last access and modify times
49a1179c 368values ARRAY,HASH return a list of the values in a hash
cb1a09d0
AD
369vec Binary test or set particular bits in a string
370wait Process wait for any child process to die
371waitpid Process wait for a particular child process to die
91e74348 372wantarray Misc,Flow get void vs scalar vs list context of current subroutine call
cb1a09d0 373warn I/O print debugging info
9e5f1ef1 374when Switch XXX RT #108848
cb1a09d0
AD
375write I/O print a picture record
376y/// String transliterate a string