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