Commit | Line | Data |
---|---|---|
f102b883 TC |
1 | =head1 NAME |
2 | ||
3 | perlmodlib - constructing new Perl modules and finding existing ones | |
4 | ||
5 | =head1 DESCRIPTION | |
6 | ||
7 | =head1 THE PERL MODULE LIBRARY | |
8 | ||
19799a22 GS |
9 | Many modules are included the Perl distribution. These are described |
10 | below, and all end in F<.pm>. You may discover compiled library | |
11 | file (usually ending in F<.so>) or small pieces of modules to be | |
12 | autoloaded (ending in F<.al>); these were automatically generated | |
13 | by the installation process. You may also discover files in the | |
14 | library directory that end in either F<.pl> or F<.ph>. These are | |
15 | old libraries supplied so that old programs that use them still | |
16 | run. The F<.pl> files will all eventually be converted into standard | |
17 | modules, and the F<.ph> files made by B<h2ph> will probably end up | |
18 | as extension modules made by B<h2xs>. (Some F<.ph> values may | |
19 | already be available through the POSIX, Errno, or Fcntl modules.) | |
20 | The B<pl2pm> file in the distribution may help in your conversion, | |
21 | but it's just a mechanical process and therefore far from bulletproof. | |
f102b883 TC |
22 | |
23 | =head2 Pragmatic Modules | |
24 | ||
19799a22 GS |
25 | They work somewhat like compiler directives (pragmata) in that they |
26 | tend to affect the compilation of your program, and thus will usually | |
27 | work well only when used within a C<use>, or C<no>. Most of these | |
28 | are lexically scoped, so an inner BLOCK may countermand them | |
29 | by saying: | |
f102b883 TC |
30 | |
31 | no integer; | |
32 | no strict 'refs'; | |
4438c4b7 | 33 | no warnings; |
f102b883 TC |
34 | |
35 | which lasts until the end of that BLOCK. | |
36 | ||
19799a22 GS |
37 | Some pragmas are lexically scoped--typically those that affect the |
38 | C<$^H> hints variable. Others affect the current package instead, | |
77ca0c92 | 39 | like C<use vars> and C<use subs>, which allow you to predeclare a |
19799a22 GS |
40 | variables or subroutines within a particular I<file> rather than |
41 | just a block. Such declarations are effective for the entire file | |
42 | for which they were declared. You cannot rescind them with C<no | |
43 | vars> or C<no subs>. | |
f102b883 TC |
44 | |
45 | The following pragmas are defined (and have their own documentation). | |
46 | ||
47 | =over 12 | |
48 | ||
09bef843 SB |
49 | =item attributes |
50 | ||
9e107c59 | 51 | Get/set subroutine or variable attributes |
09bef843 | 52 | |
19799a22 | 53 | =item attrs |
f102b883 | 54 | |
9e107c59 | 55 | Set/get attributes of a subroutine (deprecated) |
19799a22 GS |
56 | |
57 | =item autouse | |
58 | ||
9e107c59 | 59 | Postpone load of modules until a function is used |
19799a22 GS |
60 | |
61 | =item base | |
62 | ||
63 | Establish IS-A relationship with base class at compile time | |
f102b883 TC |
64 | |
65 | =item blib | |
66 | ||
19799a22 GS |
67 | Use MakeMaker's uninstalled version of a package |
68 | ||
2e1d04bc | 69 | =item bytes |
9e107c59 | 70 | |
2e1d04bc | 71 | Force byte semantics rather than character semantics |
9e107c59 GS |
72 | |
73 | =item charnames | |
74 | ||
75 | Define character names for C<\N{named}> string literal escape. | |
76 | ||
19799a22 GS |
77 | =item constant |
78 | ||
9e107c59 | 79 | Declare constants |
f102b883 TC |
80 | |
81 | =item diagnostics | |
82 | ||
2e1d04bc | 83 | Perl compiler pragma to force verbose warning diagnostics |
19799a22 GS |
84 | |
85 | =item fields | |
86 | ||
2e1d04bc | 87 | Compile-time class fields |
19799a22 GS |
88 | |
89 | =item filetest | |
90 | ||
2e1d04bc | 91 | Control the filetest permission operators |
f102b883 TC |
92 | |
93 | =item integer | |
94 | ||
9e107c59 | 95 | Compute arithmetic in integer instead of double |
f102b883 TC |
96 | |
97 | =item less | |
98 | ||
2e1d04bc | 99 | Request less of something from the compiler |
f102b883 | 100 | |
f102b883 TC |
101 | =item locale |
102 | ||
2e1d04bc JH |
103 | Use and avoid POSIX locales for built-in operations |
104 | ||
105 | =item open | |
106 | ||
107 | Set default disciplines for input and output | |
f102b883 TC |
108 | |
109 | =item ops | |
110 | ||
9e107c59 | 111 | Restrict unsafe operations when compiling |
f102b883 TC |
112 | |
113 | =item overload | |
114 | ||
2e1d04bc | 115 | Package for overloading perl operations |
f102b883 | 116 | |
165c0277 JH |
117 | =item perlio |
118 | ||
119 | Configure C level IO | |
120 | ||
b3eb6a9b GS |
121 | =item re |
122 | ||
2e1d04bc | 123 | Alter regular expression behaviour |
b3eb6a9b | 124 | |
f102b883 TC |
125 | =item sigtrap |
126 | ||
9e107c59 | 127 | Enable simple signal handling |
f102b883 TC |
128 | |
129 | =item strict | |
130 | ||
9e107c59 | 131 | Restrict unsafe constructs |
f102b883 TC |
132 | |
133 | =item subs | |
134 | ||
2e1d04bc | 135 | Predeclare sub names |
f102b883 | 136 | |
19799a22 | 137 | =item utf8 |
f102b883 | 138 | |
2e1d04bc | 139 | Enable/disable UTF-8 in source code |
f102b883 TC |
140 | |
141 | =item vars | |
142 | ||
2e1d04bc | 143 | Predeclare global variable names (obsolete) |
f102b883 | 144 | |
4438c4b7 | 145 | =item warnings |
0453d815 | 146 | |
9e107c59 | 147 | Control optional warnings |
19799a22 | 148 | |
13a2d996 SP |
149 | =item warnings::register |
150 | ||
151 | Warnings import function | |
152 | ||
f102b883 TC |
153 | =back |
154 | ||
155 | =head2 Standard Modules | |
156 | ||
157 | Standard, bundled modules are all expected to behave in a well-defined | |
158 | manner with respect to namespace pollution because they use the | |
159 | Exporter module. See their own documentation for details. | |
160 | ||
161 | =over 12 | |
162 | ||
163 | =item AnyDBM_File | |
164 | ||
2e1d04bc | 165 | Provide framework for multiple DBMs |
f102b883 TC |
166 | |
167 | =item AutoLoader | |
168 | ||
9e107c59 | 169 | Load subroutines only on demand |
f102b883 TC |
170 | |
171 | =item AutoSplit | |
172 | ||
9e107c59 | 173 | Split a package for autoloading |
f102b883 | 174 | |
19799a22 GS |
175 | =item B |
176 | ||
2e1d04bc | 177 | The Perl Compiler |
19799a22 GS |
178 | |
179 | =item B::Asmdata | |
180 | ||
181 | Autogenerated data about Perl ops, used to generate bytecode | |
182 | ||
183 | =item B::Assembler | |
184 | ||
185 | Assemble Perl bytecode | |
186 | ||
187 | =item B::Bblock | |
188 | ||
189 | Walk basic blocks | |
190 | ||
191 | =item B::Bytecode | |
192 | ||
193 | Perl compiler's bytecode backend | |
194 | ||
195 | =item B::C | |
196 | ||
197 | Perl compiler's C backend | |
198 | ||
199 | =item B::CC | |
200 | ||
201 | Perl compiler's optimized C translation backend | |
202 | ||
203 | =item B::Debug | |
204 | ||
205 | Walk Perl syntax tree, printing debug info about ops | |
206 | ||
207 | =item B::Deparse | |
208 | ||
2e1d04bc | 209 | Perl compiler backend to produce perl code |
19799a22 GS |
210 | |
211 | =item B::Disassembler | |
212 | ||
213 | Disassemble Perl bytecode | |
214 | ||
215 | =item B::Lint | |
216 | ||
2e1d04bc | 217 | Perl lint |
19799a22 GS |
218 | |
219 | =item B::Showlex | |
220 | ||
221 | Show lexical variables used in functions or files | |
222 | ||
223 | =item B::Stackobj | |
224 | ||
225 | Helper module for CC backend | |
226 | ||
13a2d996 SP |
227 | =item B::Stash |
228 | ||
229 | Show what stashes are loaded | |
230 | ||
19799a22 GS |
231 | =item B::Terse |
232 | ||
233 | Walk Perl syntax tree, printing terse info about ops | |
234 | ||
235 | =item B::Xref | |
236 | ||
237 | Generates cross reference reports for Perl programs | |
238 | ||
f102b883 TC |
239 | =item Benchmark |
240 | ||
2e1d04bc | 241 | Benchmark running times of Perl code |
9e107c59 GS |
242 | |
243 | =item ByteLoader | |
244 | ||
2e1d04bc | 245 | Load byte compiled perl code |
f102b883 | 246 | |
19799a22 GS |
247 | =item CGI |
248 | ||
2e1d04bc | 249 | Simple Common Gateway Interface Class |
19799a22 GS |
250 | |
251 | =item CGI::Apache | |
252 | ||
2e1d04bc | 253 | Backward compatibility module for CGI.pm |
19799a22 GS |
254 | |
255 | =item CGI::Carp | |
256 | ||
257 | CGI routines for writing to the HTTPD (or other) error log | |
258 | ||
259 | =item CGI::Cookie | |
260 | ||
261 | Interface to Netscape Cookies | |
262 | ||
263 | =item CGI::Fast | |
264 | ||
265 | CGI Interface for Fast CGI | |
266 | ||
9e107c59 GS |
267 | =item CGI::Pretty |
268 | ||
269 | Module to produce nicely formatted HTML code | |
270 | ||
19799a22 GS |
271 | =item CGI::Push |
272 | ||
273 | Simple Interface to Server Push | |
274 | ||
275 | =item CGI::Switch | |
276 | ||
2e1d04bc | 277 | Backward compatibility module for defunct CGI::Switch |
19799a22 | 278 | |
f102b883 TC |
279 | =item CPAN |
280 | ||
2e1d04bc | 281 | Query, download and build perl modules from CPAN sites |
f102b883 TC |
282 | |
283 | =item CPAN::FirstTime | |
284 | ||
2e1d04bc | 285 | Utility for CPAN::Config file Initialization |
f102b883 TC |
286 | |
287 | =item CPAN::Nox | |
288 | ||
19799a22 | 289 | Wrapper around CPAN.pm without using any XS module |
f102b883 TC |
290 | |
291 | =item Carp | |
292 | ||
2e1d04bc | 293 | Warn of errors (from perspective of caller) |
9e107c59 | 294 | |
f102b883 TC |
295 | =item Class::Struct |
296 | ||
9e107c59 | 297 | Declare struct-like datatypes as Perl classes |
f102b883 | 298 | |
f102b883 TC |
299 | =item Cwd |
300 | ||
9e107c59 | 301 | Get pathname of current working directory |
f102b883 | 302 | |
19799a22 GS |
303 | =item DB |
304 | ||
2e1d04bc | 305 | Programmatic interface to the Perl debugging API (draft, subject to |
19799a22 | 306 | |
f102b883 TC |
307 | =item DB_File |
308 | ||
19799a22 GS |
309 | Perl5 access to Berkeley DB version 1.x |
310 | ||
f102b883 TC |
311 | =item Devel::SelfStubber |
312 | ||
9e107c59 | 313 | Generate stubs for a SelfLoading module |
f102b883 TC |
314 | |
315 | =item DirHandle | |
316 | ||
9e107c59 | 317 | Supply object methods for directory handles |
f102b883 | 318 | |
19799a22 GS |
319 | =item Dumpvalue |
320 | ||
2e1d04bc | 321 | Provides screen dump of Perl data. |
f102b883 | 322 | |
13a2d996 SP |
323 | =item Encode |
324 | ||
325 | Character encodings | |
326 | ||
f102b883 TC |
327 | =item English |
328 | ||
2e1d04bc | 329 | Use nice English (or awk) names for ugly punctuation variables |
f102b883 TC |
330 | |
331 | =item Env | |
332 | ||
2e1d04bc | 333 | Perl module that imports environment variables as scalars or arrays |
f102b883 TC |
334 | |
335 | =item Exporter | |
336 | ||
2e1d04bc | 337 | Implements default import method for modules |
9e107c59 GS |
338 | |
339 | =item Exporter::Heavy | |
340 | ||
341 | Exporter guts | |
19799a22 GS |
342 | |
343 | =item ExtUtils::Command | |
344 | ||
2e1d04bc | 345 | Utilities to replace common UNIX commands in Makefiles etc. |
f102b883 TC |
346 | |
347 | =item ExtUtils::Embed | |
348 | ||
2e1d04bc | 349 | Utilities for embedding Perl in C/C++ applications |
f102b883 TC |
350 | |
351 | =item ExtUtils::Install | |
352 | ||
9e107c59 | 353 | Install files from here to there |
f102b883 | 354 | |
19799a22 GS |
355 | =item ExtUtils::Installed |
356 | ||
357 | Inventory management of installed modules | |
358 | ||
f102b883 TC |
359 | =item ExtUtils::Liblist |
360 | ||
9e107c59 GS |
361 | Determine libraries to use and how to use them |
362 | ||
363 | =item ExtUtils::MM_Cygwin | |
364 | ||
2e1d04bc | 365 | Methods to override UN*X behaviour in ExtUtils::MakeMaker |
f102b883 TC |
366 | |
367 | =item ExtUtils::MM_OS2 | |
368 | ||
2e1d04bc | 369 | Methods to override UN*X behaviour in ExtUtils::MakeMaker |
f102b883 TC |
370 | |
371 | =item ExtUtils::MM_Unix | |
372 | ||
9e107c59 | 373 | Methods used by ExtUtils::MakeMaker |
f102b883 TC |
374 | |
375 | =item ExtUtils::MM_VMS | |
376 | ||
2e1d04bc | 377 | Methods to override UN*X behaviour in ExtUtils::MakeMaker |
19799a22 GS |
378 | |
379 | =item ExtUtils::MM_Win32 | |
380 | ||
2e1d04bc | 381 | Methods to override UN*X behaviour in ExtUtils::MakeMaker |
f102b883 TC |
382 | |
383 | =item ExtUtils::MakeMaker | |
384 | ||
9e107c59 | 385 | Create an extension Makefile |
f102b883 TC |
386 | |
387 | =item ExtUtils::Manifest | |
388 | ||
9e107c59 | 389 | Utilities to write and check a MANIFEST file |
f102b883 TC |
390 | |
391 | =item ExtUtils::Mkbootstrap | |
392 | ||
9e107c59 | 393 | Make a bootstrap file for use by DynaLoader |
f102b883 TC |
394 | |
395 | =item ExtUtils::Mksymlists | |
396 | ||
9e107c59 | 397 | Write linker options files for dynamic extension |
f102b883 | 398 | |
19799a22 GS |
399 | =item ExtUtils::Packlist |
400 | ||
9e107c59 | 401 | Manage .packlist files |
19799a22 | 402 | |
f102b883 TC |
403 | =item ExtUtils::testlib |
404 | ||
9e107c59 | 405 | Add blib/* directories to @INC |
f102b883 | 406 | |
b6c543e3 IZ |
407 | =item Fatal |
408 | ||
9e107c59 | 409 | Replace functions with equivalents which succeed or die |
b6c543e3 | 410 | |
f102b883 TC |
411 | =item Fcntl |
412 | ||
2e1d04bc | 413 | Load the C Fcntl.h defines |
f102b883 TC |
414 | |
415 | =item File::Basename | |
416 | ||
9e107c59 GS |
417 | Split a pathname into pieces |
418 | ||
419 | =item File::CheckTree | |
420 | ||
421 | Run many filetest checks on a tree | |
f102b883 | 422 | |
f102b883 TC |
423 | =item File::Compare |
424 | ||
19799a22 | 425 | Compare files or filehandles |
f102b883 TC |
426 | |
427 | =item File::Copy | |
428 | ||
19799a22 GS |
429 | Copy files or filehandles |
430 | ||
431 | =item File::DosGlob | |
432 | ||
2e1d04bc | 433 | DOS like globbing and then some |
f102b883 TC |
434 | |
435 | =item File::Find | |
436 | ||
2e1d04bc | 437 | Traverse a file tree |
f102b883 TC |
438 | |
439 | =item File::Path | |
440 | ||
2e1d04bc | 441 | Create or remove directory trees |
f102b883 | 442 | |
f505c983 GS |
443 | =item File::Spec |
444 | ||
9e107c59 | 445 | Portably perform operations on file names |
f505c983 | 446 | |
165c0277 JH |
447 | =item File::Spec::Epoc |
448 | ||
449 | Methods for Epoc file specs | |
450 | ||
f505c983 GS |
451 | =item File::Spec::Functions |
452 | ||
9e107c59 | 453 | Portably perform operations on file names |
19799a22 GS |
454 | |
455 | =item File::Spec::Mac | |
456 | ||
457 | File::Spec for MacOS | |
458 | ||
459 | =item File::Spec::OS2 | |
460 | ||
9e107c59 | 461 | Methods for OS/2 file specs |
19799a22 GS |
462 | |
463 | =item File::Spec::Unix | |
464 | ||
9e107c59 | 465 | Methods used by File::Spec |
19799a22 GS |
466 | |
467 | =item File::Spec::VMS | |
468 | ||
9e107c59 | 469 | Methods for VMS file specs |
19799a22 GS |
470 | |
471 | =item File::Spec::Win32 | |
472 | ||
9e107c59 | 473 | Methods for Win32 file specs |
f505c983 | 474 | |
2e1d04bc JH |
475 | =item File::Temp |
476 | ||
477 | Return name and handle of a temporary file safely | |
478 | ||
f102b883 TC |
479 | =item File::stat |
480 | ||
9e107c59 | 481 | By-name interface to Perl's built-in stat() functions |
f102b883 TC |
482 | |
483 | =item FileCache | |
484 | ||
9e107c59 | 485 | Keep more files open than the system permits |
f102b883 TC |
486 | |
487 | =item FileHandle | |
488 | ||
9e107c59 | 489 | Supply object methods for filehandles |
f102b883 | 490 | |
165c0277 JH |
491 | =item Filter::Simple |
492 | ||
493 | Simplified source filtering | |
494 | ||
f102b883 TC |
495 | =item FindBin |
496 | ||
2e1d04bc | 497 | Locate directory of original perl script |
f102b883 TC |
498 | |
499 | =item Getopt::Long | |
500 | ||
9e107c59 | 501 | Extended processing of command line options |
f102b883 TC |
502 | |
503 | =item Getopt::Std | |
504 | ||
19799a22 | 505 | Process single-character switches with switch clustering |
f102b883 TC |
506 | |
507 | =item I18N::Collate | |
508 | ||
2e1d04bc | 509 | Compare 8-bit scalar data according to the current locale |
f102b883 TC |
510 | |
511 | =item IO | |
512 | ||
2e1d04bc | 513 | Load various IO modules |
f102b883 TC |
514 | |
515 | =item IPC::Open2 | |
516 | ||
9e107c59 | 517 | Open a process for both reading and writing |
f102b883 TC |
518 | |
519 | =item IPC::Open3 | |
520 | ||
9e107c59 | 521 | Open a process for reading, writing, and error handling |
f102b883 TC |
522 | |
523 | =item Math::BigFloat | |
524 | ||
19799a22 | 525 | Arbitrary length float math package |
f102b883 TC |
526 | |
527 | =item Math::BigInt | |
528 | ||
19799a22 | 529 | Arbitrary size integer math package |
f102b883 TC |
530 | |
531 | =item Math::Complex | |
532 | ||
9e107c59 | 533 | Complex numbers and associated mathematical functions |
f102b883 | 534 | |
404b15a1 CS |
535 | =item Math::Trig |
536 | ||
9e107c59 | 537 | Trigonometric functions |
f102b883 | 538 | |
2e1d04bc JH |
539 | =item NDBM_File |
540 | ||
541 | Tied access to ndbm files | |
542 | ||
f102b883 TC |
543 | =item Net::Ping |
544 | ||
9e107c59 | 545 | Check a remote host for reachability |
f102b883 TC |
546 | |
547 | =item Net::hostent | |
548 | ||
9e107c59 | 549 | By-name interface to Perl's built-in gethost*() functions |
f102b883 TC |
550 | |
551 | =item Net::netent | |
552 | ||
9e107c59 | 553 | By-name interface to Perl's built-in getnet*() functions |
f102b883 TC |
554 | |
555 | =item Net::protoent | |
556 | ||
9e107c59 | 557 | By-name interface to Perl's built-in getproto*() functions |
f102b883 TC |
558 | |
559 | =item Net::servent | |
560 | ||
9e107c59 | 561 | By-name interface to Perl's built-in getserv*() functions |
f102b883 | 562 | |
19799a22 | 563 | =item O |
f102b883 | 564 | |
19799a22 | 565 | Generic interface to Perl Compiler backends |
f102b883 | 566 | |
2e1d04bc | 567 | =item ODBM_File |
f102b883 | 568 | |
2e1d04bc | 569 | Tied access to odbm files |
f102b883 | 570 | |
2e1d04bc | 571 | =item Opcode |
f102b883 | 572 | |
2e1d04bc | 573 | Disable named opcodes when compiling perl code |
19799a22 | 574 | |
9e107c59 GS |
575 | =item Pod::Checker |
576 | ||
577 | Check pod documents for syntax errors | |
578 | ||
2e1d04bc JH |
579 | =item Pod::Find |
580 | ||
581 | Find POD documents in directory trees | |
582 | ||
19799a22 GS |
583 | =item Pod::Html |
584 | ||
9e107c59 GS |
585 | Module to convert pod files to HTML |
586 | ||
587 | =item Pod::InputObjects | |
588 | ||
2e1d04bc | 589 | Objects representing POD input paragraphs, commands, etc. |
9e107c59 | 590 | |
13a2d996 SP |
591 | =item Pod::LaTeX |
592 | ||
593 | Convert Pod data to formatted Latex | |
594 | ||
9e107c59 GS |
595 | =item Pod::Man |
596 | ||
597 | Convert POD data to formatted *roff input | |
598 | ||
2e1d04bc JH |
599 | =item Pod::ParseUtils |
600 | ||
601 | Helpers for POD parsing and conversion | |
602 | ||
9e107c59 GS |
603 | =item Pod::Parser |
604 | ||
605 | Base class for creating POD filters and translators | |
606 | ||
2e1d04bc JH |
607 | =item Pod::Plainer |
608 | ||
609 | Perl extension for converting Pod to old style Pod. | |
610 | ||
9e107c59 GS |
611 | =item Pod::Select |
612 | ||
613 | Extract selected sections of POD from input | |
19799a22 GS |
614 | |
615 | =item Pod::Text | |
616 | ||
9e107c59 GS |
617 | Convert POD data to formatted ASCII text |
618 | ||
619 | =item Pod::Text::Color | |
620 | ||
621 | Convert POD data to formatted color ASCII text | |
622 | ||
2e1d04bc JH |
623 | =item Pod::Text::Termcap |
624 | ||
625 | Convert POD data to ASCII text with format escapes | |
626 | ||
9e107c59 GS |
627 | =item Pod::Usage |
628 | ||
629 | Print a usage message from embedded pod documentation | |
f102b883 TC |
630 | |
631 | =item SDBM_File | |
632 | ||
19799a22 | 633 | Tied access to sdbm files |
f102b883 TC |
634 | |
635 | =item Safe | |
636 | ||
19799a22 | 637 | Compile and execute code in restricted compartments |
f102b883 TC |
638 | |
639 | =item Search::Dict | |
640 | ||
9e107c59 | 641 | Search for key in dictionary file |
f102b883 TC |
642 | |
643 | =item SelectSaver | |
644 | ||
9e107c59 | 645 | Save and restore selected file handle |
f102b883 TC |
646 | |
647 | =item SelfLoader | |
648 | ||
9e107c59 | 649 | Load functions only on demand |
f102b883 TC |
650 | |
651 | =item Shell | |
652 | ||
2e1d04bc | 653 | Run shell commands transparently within perl |
f102b883 TC |
654 | |
655 | =item Socket | |
656 | ||
2e1d04bc | 657 | Load the C socket.h defines and structure manipulators |
f102b883 | 658 | |
13a2d996 SP |
659 | =item Storable |
660 | ||
661 | Persistency for perl data structures | |
662 | ||
f102b883 TC |
663 | =item Symbol |
664 | ||
9e107c59 | 665 | Manipulate Perl symbols and their names |
f102b883 | 666 | |
2e1d04bc | 667 | =item Term::ANSIColor |
f102b883 | 668 | |
2e1d04bc | 669 | Color screen output using ANSI escape sequences |
f102b883 TC |
670 | |
671 | =item Term::Cap | |
672 | ||
2e1d04bc | 673 | Perl termcap interface |
f102b883 TC |
674 | |
675 | =item Term::Complete | |
676 | ||
2e1d04bc | 677 | Perl word completion module |
f102b883 TC |
678 | |
679 | =item Term::ReadLine | |
680 | ||
2e1d04bc | 681 | Perl interface to various C<readline> packages. If |
19799a22 GS |
682 | |
683 | =item Test | |
684 | ||
9e107c59 | 685 | Provides a simple framework for writing test scripts |
f102b883 TC |
686 | |
687 | =item Test::Harness | |
688 | ||
2e1d04bc | 689 | Run perl standard test scripts with statistics |
f102b883 TC |
690 | |
691 | =item Text::Abbrev | |
692 | ||
9e107c59 | 693 | Create an abbreviation table from a list |
f102b883 TC |
694 | |
695 | =item Text::ParseWords | |
696 | ||
2e1d04bc | 697 | Parse text into an array of tokens or array of arrays |
f102b883 TC |
698 | |
699 | =item Text::Soundex | |
700 | ||
2e1d04bc | 701 | Implementation of the Soundex Algorithm as Described by Knuth |
f102b883 TC |
702 | |
703 | =item Text::Wrap | |
704 | ||
9e107c59 | 705 | Line wrapping to form simple paragraphs |
19799a22 GS |
706 | |
707 | =item Tie::Array | |
708 | ||
9e107c59 | 709 | Base class for tied arrays |
19799a22 GS |
710 | |
711 | =item Tie::Handle | |
712 | ||
9e107c59 | 713 | Base class definitions for tied handles |
19799a22 | 714 | |
9e107c59 | 715 | =item Tie::Hash |
f102b883 | 716 | |
9e107c59 | 717 | Base class definitions for tied hashes |
f102b883 TC |
718 | |
719 | =item Tie::RefHash | |
720 | ||
9e107c59 | 721 | Use references as hash keys |
f102b883 | 722 | |
9e107c59 | 723 | =item Tie::Scalar |
f102b883 | 724 | |
9e107c59 | 725 | Base class definitions for tied scalars |
f102b883 TC |
726 | |
727 | =item Tie::SubstrHash | |
728 | ||
19799a22 | 729 | Fixed-table-size, fixed-key-length hashing |
f102b883 TC |
730 | |
731 | =item Time::Local | |
732 | ||
9e107c59 | 733 | Efficiently compute time from local and GMT time |
f102b883 TC |
734 | |
735 | =item Time::gmtime | |
736 | ||
9e107c59 | 737 | By-name interface to Perl's built-in gmtime() function |
f102b883 TC |
738 | |
739 | =item Time::localtime | |
740 | ||
9e107c59 | 741 | By-name interface to Perl's built-in localtime() function |
f102b883 TC |
742 | |
743 | =item Time::tm | |
744 | ||
9e107c59 | 745 | Internal object used by Time::gmtime and Time::localtime |
f102b883 TC |
746 | |
747 | =item UNIVERSAL | |
748 | ||
9e107c59 | 749 | Base class for ALL classes (blessed references) |
f102b883 TC |
750 | |
751 | =item User::grent | |
752 | ||
9e107c59 | 753 | By-name interface to Perl's built-in getgr*() functions |
f102b883 TC |
754 | |
755 | =item User::pwent | |
756 | ||
9e107c59 | 757 | By-name interface to Perl's built-in getpw*() functions |
f102b883 TC |
758 | |
759 | =back | |
760 | ||
19799a22 | 761 | To find out I<all> modules installed on your system, including |
2e1d04bc | 762 | those without documentation or outside the standard release, |
b1866b2d | 763 | just do this: |
f102b883 | 764 | |
5a964f20 | 765 | % find `perl -e 'print "@INC"'` -name '*.pm' -print |
f102b883 | 766 | |
2e1d04bc JH |
767 | They should all have their own documentation installed and accessible |
768 | via your system man(1) command. If you do not have a B<find> | |
19799a22 GS |
769 | program, you can use the Perl B<find2perl> program instead, which |
770 | generates Perl code as output you can run through perl. If you | |
771 | have a B<man> program but it doesn't find your modules, you'll have | |
2e1d04bc JH |
772 | to fix your manpath. See L<perl> for details. If you have no |
773 | system B<man> command, you might try the B<perldoc> program. | |
f102b883 TC |
774 | |
775 | =head2 Extension Modules | |
776 | ||
19799a22 GS |
777 | Extension modules are written in C (or a mix of Perl and C). They |
778 | are usually dynamically loaded into Perl if and when you need them, | |
2e1d04bc | 779 | but may also be be linked in statically. Supported extension modules |
19799a22 | 780 | include Socket, Fcntl, and POSIX. |
f102b883 TC |
781 | |
782 | Many popular C extension modules do not come bundled (at least, not | |
19799a22 GS |
783 | completely) due to their sizes, volatility, or simply lack of time |
784 | for adequate testing and configuration across the multitude of | |
785 | platforms on which Perl was beta-tested. You are encouraged to | |
786 | look for them on CPAN (described below), or using web search engines | |
787 | like Alta Vista or Deja News. | |
f102b883 TC |
788 | |
789 | =head1 CPAN | |
790 | ||
19799a22 GS |
791 | CPAN stands for Comprehensive Perl Archive Network; it's a globally |
792 | replicated trove of Perl materials, including documentation, style | |
2e1d04bc | 793 | guides, tricks and traps, alternate ports to non-Unix systems and |
19799a22 GS |
794 | occasional binary distributions for these. Search engines for |
795 | CPAN can be found at http://cpan.perl.com/ and at | |
796 | http://theory.uwinnipeg.ca/mod_perl/cpan-search.pl . | |
797 | ||
798 | Most importantly, CPAN includes around a thousand unbundled modules, | |
799 | some of which require a C compiler to build. Major categories of | |
800 | modules are: | |
f102b883 | 801 | |
cea6626f | 802 | =over 4 |
f102b883 TC |
803 | |
804 | =item * | |
551e1d92 | 805 | |
f102b883 TC |
806 | Language Extensions and Documentation Tools |
807 | ||
808 | =item * | |
551e1d92 | 809 | |
f102b883 TC |
810 | Development Support |
811 | ||
812 | =item * | |
551e1d92 | 813 | |
f102b883 TC |
814 | Operating System Interfaces |
815 | ||
816 | =item * | |
551e1d92 | 817 | |
f102b883 TC |
818 | Networking, Device Control (modems) and InterProcess Communication |
819 | ||
820 | =item * | |
551e1d92 | 821 | |
f102b883 TC |
822 | Data Types and Data Type Utilities |
823 | ||
824 | =item * | |
551e1d92 | 825 | |
f102b883 TC |
826 | Database Interfaces |
827 | ||
828 | =item * | |
551e1d92 | 829 | |
f102b883 TC |
830 | User Interfaces |
831 | ||
832 | =item * | |
551e1d92 | 833 | |
f102b883 TC |
834 | Interfaces to / Emulations of Other Programming Languages |
835 | ||
836 | =item * | |
551e1d92 | 837 | |
f102b883 TC |
838 | File Names, File Systems and File Locking (see also File Handles) |
839 | ||
840 | =item * | |
551e1d92 | 841 | |
f102b883 TC |
842 | String Processing, Language Text Processing, Parsing, and Searching |
843 | ||
844 | =item * | |
551e1d92 | 845 | |
f102b883 TC |
846 | Option, Argument, Parameter, and Configuration File Processing |
847 | ||
848 | =item * | |
551e1d92 | 849 | |
f102b883 TC |
850 | Internationalization and Locale |
851 | ||
852 | =item * | |
551e1d92 | 853 | |
f102b883 TC |
854 | Authentication, Security, and Encryption |
855 | ||
856 | =item * | |
551e1d92 | 857 | |
f102b883 TC |
858 | World Wide Web, HTML, HTTP, CGI, MIME |
859 | ||
860 | =item * | |
551e1d92 | 861 | |
f102b883 TC |
862 | Server and Daemon Utilities |
863 | ||
864 | =item * | |
551e1d92 | 865 | |
f102b883 TC |
866 | Archiving and Compression |
867 | ||
868 | =item * | |
551e1d92 | 869 | |
f102b883 TC |
870 | Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing |
871 | ||
872 | =item * | |
551e1d92 | 873 | |
f102b883 TC |
874 | Mail and Usenet News |
875 | ||
876 | =item * | |
551e1d92 | 877 | |
f102b883 TC |
878 | Control Flow Utilities (callbacks and exceptions etc) |
879 | ||
880 | =item * | |
551e1d92 | 881 | |
f102b883 TC |
882 | File Handle and Input/Output Stream Utilities |
883 | ||
884 | =item * | |
551e1d92 | 885 | |
f102b883 TC |
886 | Miscellaneous Modules |
887 | ||
888 | =back | |
889 | ||
19799a22 | 890 | Registered CPAN sites as of this writing include the following. |
f102b883 TC |
891 | You should try to choose one close to you: |
892 | ||
cea6626f | 893 | =over 4 |
f102b883 | 894 | |
19799a22 | 895 | =item Africa |
f102b883 | 896 | |
0974df93 JH |
897 | South Africa ftp://ftp.is.co.za/programming/perl/CPAN/ |
898 | ftp://ftp.saix.net/pub/CPAN/ | |
899 | ftp://ftp.sun.ac.za/CPAN/ | |
be94a901 | 900 | ftp://ftpza.co.za/pub/mirrors/cpan/ |
f102b883 | 901 | |
6cecdcac | 902 | |
19799a22 | 903 | =item Asia |
f102b883 | 904 | |
0974df93 | 905 | China ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/ |
6cecdcac | 906 | Hong Kong ftp://ftp.pacific.net.hk/pub/mirror/CPAN/ |
0974df93 JH |
907 | Indonesia ftp://malone.piksi.itb.ac.id/pub/CPAN/ |
908 | Israel ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/ | |
909 | Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/ | |
be94a901 GS |
910 | ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/ |
911 | ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/ | |
912 | ftp://ftp.meisei-u.ac.jp/pub/CPAN/ | |
19799a22 | 913 | ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/ |
be94a901 | 914 | ftp://mirror.nucba.ac.jp/mirror/Perl/ |
6cecdcac | 915 | Saudi-Arabia ftp://ftp.isu.net.sa/pub/CPAN/ |
0974df93 JH |
916 | Singapore ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/ |
917 | South Korea ftp://ftp.bora.net/pub/CPAN/ | |
918 | ftp://ftp.kornet.net/pub/CPAN/ | |
be94a901 | 919 | ftp://ftp.nuri.net/pub/CPAN/ |
0974df93 JH |
920 | Taiwan ftp://coda.nctu.edu.tw/computer-languages/perl/CPAN/ |
921 | ftp://ftp.ee.ncku.edu.tw/pub3/perl/CPAN/ | |
be94a901 | 922 | ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/ |
6cecdcac GS |
923 | Thailand ftp://ftp.nectec.or.th/pub/mirrors/CPAN/ |
924 | ||
f102b883 | 925 | |
19799a22 | 926 | =item Australasia |
f102b883 | 927 | |
0974df93 | 928 | Australia ftp://cpan.topend.com.au/pub/CPAN/ |
6cecdcac | 929 | ftp://ftp.labyrinth.net.au/pub/perl-CPAN/ |
be94a901 GS |
930 | ftp://ftp.sage-au.org.au/pub/compilers/perl/CPAN/ |
931 | ftp://mirror.aarnet.edu.au/pub/perl/CPAN/ | |
0974df93 | 932 | New Zealand ftp://ftp.auckland.ac.nz/pub/perl/CPAN/ |
be94a901 GS |
933 | ftp://sunsite.net.nz/pub/languages/perl/CPAN/ |
934 | ||
6cecdcac | 935 | |
0974df93 | 936 | =item Central America |
be94a901 | 937 | |
0974df93 | 938 | Costa Rica ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/ |
f102b883 | 939 | |
6cecdcac | 940 | |
19799a22 | 941 | =item Europe |
f102b883 | 942 | |
0974df93 JH |
943 | Austria ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/ |
944 | Belgium ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/ | |
945 | Bulgaria ftp://ftp.ntrl.net/pub/mirrors/CPAN/ | |
946 | Croatia ftp://ftp.linux.hr/pub/CPAN/ | |
947 | Czech Republic ftp://ftp.fi.muni.cz/pub/perl/ | |
be94a901 | 948 | ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/ |
0974df93 JH |
949 | Denmark ftp://sunsite.auc.dk/pub/languages/perl/CPAN/ |
950 | Estonia ftp://ftp.ut.ee/pub/languages/perl/CPAN/ | |
951 | Finland ftp://ftp.funet.fi/pub/languages/perl/CPAN/ | |
6cecdcac GS |
952 | France ftp://ftp.grolier.fr/pub/perl/CPAN/ |
953 | ftp://ftp.lip6.fr/pub/perl/CPAN/ | |
be94a901 GS |
954 | ftp://ftp.oleane.net/pub/mirrors/CPAN/ |
955 | ftp://ftp.pasteur.fr/pub/computing/CPAN/ | |
0974df93 | 956 | ftp://ftp.uvsq.fr/pub/perl/CPAN/ |
6cecdcac GS |
957 | German ftp://ftp.gigabell.net/pub/CPAN/ |
958 | Germany ftp://ftp.archive.de.uu.net/pub/CPAN/ | |
959 | ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/ | |
960 | ftp://ftp.gmd.de/packages/CPAN/ | |
961 | ftp://ftp.gwdg.de/pub/languages/perl/CPAN/ | |
2e1d04bc JH |
962 | |
963 | ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/ | |
6cecdcac GS |
964 | ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/ |
965 | ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/ | |
966 | ftp://ftp.uni-erlangen.de/pub/source/CPAN/ | |
967 | ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/ | |
0974df93 | 968 | Germany ftp://ftp.archive.de.uu.net/pub/CPAN/ |
6cecdcac | 969 | ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/ |
be94a901 GS |
970 | ftp://ftp.gmd.de/packages/CPAN/ |
971 | ftp://ftp.gwdg.de/pub/languages/perl/CPAN/ | |
2e1d04bc JH |
972 | |
973 | ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/ | |
be94a901 GS |
974 | ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/ |
975 | ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/ | |
976 | ftp://ftp.uni-erlangen.de/pub/source/CPAN/ | |
977 | ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/ | |
0974df93 JH |
978 | Greece ftp://ftp.ntua.gr/pub/lang/perl/ |
979 | Hungary ftp://ftp.kfki.hu/pub/packages/perl/CPAN/ | |
980 | Iceland ftp://ftp.gm.is/pub/CPAN/ | |
981 | Ireland ftp://cpan.indigo.ie/pub/CPAN/ | |
982 | ftp://sunsite.compapp.dcu.ie/pub/perl/ | |
983 | Italy ftp://cis.uniRoma2.it/CPAN/ | |
be94a901 | 984 | ftp://ftp.flashnet.it/pub/CPAN/ |
19799a22 | 985 | ftp://ftp.unina.it/pub/Other/CPAN/ |
be94a901 | 986 | ftp://ftp.unipi.it/pub/mirror/perl/CPAN/ |
0974df93 | 987 | Netherlands ftp://ftp.cs.uu.nl/mirror/CPAN/ |
be94a901 | 988 | ftp://ftp.nluug.nl/pub/languages/perl/CPAN/ |
0974df93 | 989 | Norway ftp://ftp.uit.no/pub/languages/perl/cpan/ |
be94a901 | 990 | ftp://sunsite.uio.no/pub/languages/perl/CPAN/ |
6cecdcac | 991 | Poland ftp://ftp.man.torun.pl/pub/CPAN/ |
be94a901 GS |
992 | ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/ |
993 | ftp://sunsite.icm.edu.pl/pub/CPAN/ | |
0974df93 | 994 | Portugal ftp://ftp.ci.uminho.pt/pub/mirrors/cpan/ |
19799a22 | 995 | ftp://ftp.ist.utl.pt/pub/CPAN/ |
be94a901 | 996 | ftp://ftp.ua.pt/pub/CPAN/ |
6cecdcac | 997 | Romania ftp://ftp.dnttm.ro/pub/CPAN/ |
19799a22 | 998 | Russia ftp://ftp.chg.ru/pub/lang/perl/CPAN/ |
be94a901 | 999 | ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/ |
0974df93 JH |
1000 | Slovakia ftp://ftp.entry.sk/pub/languages/perl/CPAN/ |
1001 | Slovenia ftp://ftp.arnes.si/software/perl/CPAN/ | |
1002 | Spain ftp://ftp.etse.urv.es/pub/perl/ | |
be94a901 | 1003 | ftp://ftp.rediris.es/mirror/CPAN/ |
0974df93 JH |
1004 | Sweden ftp://ftp.sunet.se/pub/lang/perl/CPAN/ |
1005 | Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/ | |
1006 | Turkey ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/ | |
1007 | United Kingdom ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/ | |
be94a901 | 1008 | ftp://ftp.flirble.org/pub/languages/perl/CPAN/ |
2e1d04bc JH |
1009 | |
1010 | ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/ | |
be94a901 GS |
1011 | ftp://ftp.plig.org/pub/CPAN/ |
1012 | ftp://sunsite.doc.ic.ac.uk/packages/CPAN/ | |
f102b883 | 1013 | |
6cecdcac | 1014 | |
19799a22 | 1015 | =item North America |
f102b883 | 1016 | |
0974df93 | 1017 | Alberta ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/ |
19799a22 | 1018 | California ftp://cpan.nas.nasa.gov/pub/perl/CPAN/ |
0974df93 | 1019 | ftp://cpan.valueclick.com/CPAN/ |
19799a22 | 1020 | ftp://ftp.cdrom.com/pub/perl/CPAN/ |
6cecdcac | 1021 | http://download.sourceforge.net/mirrors/CPAN/ |
0974df93 JH |
1022 | Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/ |
1023 | Florida ftp://ftp.cise.ufl.edu/pub/perl/CPAN/ | |
6cecdcac | 1024 | Georgia ftp://ftp.twoguys.org/CPAN/ |
0974df93 JH |
1025 | Illinois ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/ |
1026 | Indiana ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN/ | |
be94a901 | 1027 | ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/ |
0974df93 JH |
1028 | Kentucky ftp://ftp.uky.edu/CPAN/ |
1029 | Manitoba ftp://theoryx5.uwinnipeg.ca/pub/CPAN/ | |
2e1d04bc JH |
1030 | Massachusetts |
1031 | ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/ | |
be94a901 | 1032 | ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/ |
19799a22 | 1033 | Mexico ftp://ftp.msg.com.mx/pub/CPAN/ |
0974df93 JH |
1034 | New York ftp://ftp.deao.net/pub/CPAN/ |
1035 | ftp://ftp.rge.com/pub/languages/perl/ | |
0974df93 | 1036 | North Carolina ftp://ftp.duke.edu/pub/perl/ |
6cecdcac | 1037 | Nova Scotia ftp://cpan.chebucto.ns.ca/pub/CPAN/ |
0974df93 | 1038 | Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/ |
19799a22 | 1039 | Ontario ftp://ftp.crc.ca/pub/packages/lang/perl/CPAN/ |
0974df93 JH |
1040 | Oregon ftp://ftp.orst.edu/pub/packages/CPAN/ |
1041 | Pennsylvania ftp://ftp.epix.net/pub/languages/perl/ | |
1042 | Tennessee ftp://ftp.sunsite.utk.edu/pub/CPAN/ | |
1043 | Texas ftp://ftp.sedl.org/pub/mirrors/CPAN/ | |
6cecdcac | 1044 | ftp://jhcloos.com/pub/mirror/CPAN/ |
0974df93 JH |
1045 | Utah ftp://mirror.xmission.com/CPAN/ |
1046 | Virginia ftp://ftp.perl.org/pub/perl/CPAN/ | |
be94a901 | 1047 | ftp://ruff.cs.jmu.edu/pub/CPAN/ |
19799a22 | 1048 | Washington ftp://ftp-mirror.internap.com/pub/CPAN/ |
6cecdcac | 1049 | ftp://ftp.llarian.net/pub/CPAN/ |
19799a22 | 1050 | ftp://ftp.spu.edu/pub/CPAN/ |
f102b883 | 1051 | |
6cecdcac | 1052 | |
19799a22 | 1053 | =item South America |
f102b883 | 1054 | |
0974df93 JH |
1055 | Brazil ftp://cpan.if.usp.br/pub/mirror/CPAN/ |
1056 | ftp://ftp.matrix.com.br/pub/perl/ | |
6cecdcac | 1057 | Chile ftp://sunsite.dcc.uchile.cl/pub/Lang/PERL/ |
f102b883 TC |
1058 | |
1059 | =back | |
1060 | ||
1061 | For an up-to-date listing of CPAN sites, | |
6cecdcac | 1062 | see http://www.perl.com/perl/CPAN/SITES or ftp://www.perl.com/CPAN/SITES . |
f102b883 TC |
1063 | |
1064 | =head1 Modules: Creation, Use, and Abuse | |
1065 | ||
1066 | (The following section is borrowed directly from Tim Bunce's modules | |
1067 | file, available at your nearest CPAN site.) | |
1068 | ||
1069 | Perl implements a class using a package, but the presence of a | |
1070 | package doesn't imply the presence of a class. A package is just a | |
1071 | namespace. A class is a package that provides subroutines that can be | |
1072 | used as methods. A method is just a subroutine that expects, as its | |
1073 | first argument, either the name of a package (for "static" methods), | |
1074 | or a reference to something (for "virtual" methods). | |
1075 | ||
1076 | A module is a file that (by convention) provides a class of the same | |
1077 | name (sans the .pm), plus an import method in that class that can be | |
1078 | called to fetch exported symbols. This module may implement some of | |
1079 | its methods by loading dynamic C or C++ objects, but that should be | |
1080 | totally transparent to the user of the module. Likewise, the module | |
1081 | might set up an AUTOLOAD function to slurp in subroutine definitions on | |
1082 | demand, but this is also transparent. Only the F<.pm> file is required to | |
2e1d04bc | 1083 | exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about |
f102b883 TC |
1084 | the AUTOLOAD mechanism. |
1085 | ||
1086 | =head2 Guidelines for Module Creation | |
1087 | ||
1088 | =over 4 | |
1089 | ||
1090 | =item Do similar modules already exist in some form? | |
1091 | ||
1092 | If so, please try to reuse the existing modules either in whole or | |
1093 | by inheriting useful features into a new class. If this is not | |
1094 | practical try to get together with the module authors to work on | |
1095 | extending or enhancing the functionality of the existing modules. | |
1096 | A perfect example is the plethora of packages in perl4 for dealing | |
1097 | with command line options. | |
1098 | ||
1099 | If you are writing a module to expand an already existing set of | |
1100 | modules, please coordinate with the author of the package. It | |
1101 | helps if you follow the same naming scheme and module interaction | |
1102 | scheme as the original author. | |
1103 | ||
1104 | =item Try to design the new module to be easy to extend and reuse. | |
1105 | ||
9f1b1f2d GS |
1106 | Try to C<use warnings;> (or C<use warnings qw(...);>). |
1107 | Remember that you can add C<no warnings qw(...);> to individual blocks | |
2e1d04bc | 1108 | of code that need less warnings. |
19799a22 | 1109 | |
f102b883 TC |
1110 | Use blessed references. Use the two argument form of bless to bless |
1111 | into the class name given as the first parameter of the constructor, | |
1112 | e.g.,: | |
1113 | ||
1114 | sub new { | |
2e1d04bc JH |
1115 | my $class = shift; |
1116 | return bless {}, $class; | |
f102b883 TC |
1117 | } |
1118 | ||
1119 | or even this if you'd like it to be used as either a static | |
1120 | or a virtual method. | |
1121 | ||
1122 | sub new { | |
2e1d04bc JH |
1123 | my $self = shift; |
1124 | my $class = ref($self) || $self; | |
1125 | return bless {}, $class; | |
f102b883 TC |
1126 | } |
1127 | ||
1128 | Pass arrays as references so more parameters can be added later | |
1129 | (it's also faster). Convert functions into methods where | |
1130 | appropriate. Split large methods into smaller more flexible ones. | |
1131 | Inherit methods from other modules if appropriate. | |
1132 | ||
1133 | Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>. | |
19799a22 | 1134 | Generally you can delete the C<eq 'FOO'> part with no harm at all. |
f102b883 TC |
1135 | Let the objects look after themselves! Generally, avoid hard-wired |
1136 | class names as far as possible. | |
1137 | ||
c47ff5f1 GS |
1138 | Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and |
1139 | C<< $r->func() >> would work (see L<perlbot> for more details). | |
f102b883 TC |
1140 | |
1141 | Use autosplit so little used or newly added functions won't be a | |
5a964f20 | 1142 | burden to programs that don't use them. Add test functions to |
f102b883 TC |
1143 | the module after __END__ either using AutoSplit or by saying: |
1144 | ||
1145 | eval join('',<main::DATA>) || die $@ unless caller(); | |
1146 | ||
1147 | Does your module pass the 'empty subclass' test? If you say | |
19799a22 | 1148 | C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able |
f102b883 TC |
1149 | to use SUBCLASS in exactly the same way as YOURCLASS. For example, |
1150 | does your application still work if you change: C<$obj = new YOURCLASS;> | |
1151 | into: C<$obj = new SUBCLASS;> ? | |
1152 | ||
1153 | Avoid keeping any state information in your packages. It makes it | |
1154 | difficult for multiple other packages to use yours. Keep state | |
1155 | information in objects. | |
1156 | ||
2e1d04bc | 1157 | Always use B<-w>. |
19799a22 GS |
1158 | |
1159 | Try to C<use strict;> (or C<use strict qw(...);>). | |
f102b883 | 1160 | Remember that you can add C<no strict qw(...);> to individual blocks |
2e1d04bc | 1161 | of code that need less strictness. |
19799a22 | 1162 | |
2e1d04bc | 1163 | Always use B<-w>. |
19799a22 | 1164 | |
f102b883 TC |
1165 | Follow the guidelines in the perlstyle(1) manual. |
1166 | ||
19799a22 GS |
1167 | Always use B<-w>. |
1168 | ||
f102b883 TC |
1169 | =item Some simple style guidelines |
1170 | ||
5a964f20 | 1171 | The perlstyle manual supplied with Perl has many helpful points. |
f102b883 TC |
1172 | |
1173 | Coding style is a matter of personal taste. Many people evolve their | |
1174 | style over several years as they learn what helps them write and | |
1175 | maintain good code. Here's one set of assorted suggestions that | |
1176 | seem to be widely used by experienced developers: | |
1177 | ||
1178 | Use underscores to separate words. It is generally easier to read | |
1179 | $var_names_like_this than $VarNamesLikeThis, especially for | |
1180 | non-native speakers of English. It's also a simple rule that works | |
1181 | consistently with VAR_NAMES_LIKE_THIS. | |
1182 | ||
1183 | Package/Module names are an exception to this rule. Perl informally | |
1184 | reserves lowercase module names for 'pragma' modules like integer | |
1185 | and strict. Other modules normally begin with a capital letter and | |
1186 | use mixed case with no underscores (need to be short and portable). | |
1187 | ||
1188 | You may find it helpful to use letter case to indicate the scope | |
1189 | or nature of a variable. For example: | |
1190 | ||
5a964f20 | 1191 | $ALL_CAPS_HERE constants only (beware clashes with Perl vars) |
f102b883 TC |
1192 | $Some_Caps_Here package-wide global/static |
1193 | $no_caps_here function scope my() or local() variables | |
1194 | ||
1195 | Function and method names seem to work best as all lowercase. | |
c47ff5f1 | 1196 | e.g., C<< $obj->as_string() >>. |
f102b883 TC |
1197 | |
1198 | You can use a leading underscore to indicate that a variable or | |
1199 | function should not be used outside the package that defined it. | |
1200 | ||
1201 | =item Select what to export. | |
1202 | ||
1203 | Do NOT export method names! | |
1204 | ||
1205 | Do NOT export anything else by default without a good reason! | |
1206 | ||
1207 | Exports pollute the namespace of the module user. If you must | |
1208 | export try to use @EXPORT_OK in preference to @EXPORT and avoid | |
1209 | short or common names to reduce the risk of name clashes. | |
1210 | ||
1211 | Generally anything not exported is still accessible from outside the | |
c47ff5f1 | 1212 | module using the ModuleName::item_name (or C<< $blessed_ref->method >>) |
f102b883 TC |
1213 | syntax. By convention you can use a leading underscore on names to |
1214 | indicate informally that they are 'internal' and not for public use. | |
1215 | ||
1216 | (It is actually possible to get private functions by saying: | |
1217 | C<my $subref = sub { ... }; &$subref;>. But there's no way to call that | |
1218 | directly as a method, because a method must have a name in the symbol | |
1219 | table.) | |
1220 | ||
1221 | As a general rule, if the module is trying to be object oriented | |
1222 | then export nothing. If it's just a collection of functions then | |
1223 | @EXPORT_OK anything but use @EXPORT with caution. | |
1224 | ||
1225 | =item Select a name for the module. | |
1226 | ||
1227 | This name should be as descriptive, accurate, and complete as | |
1228 | possible. Avoid any risk of ambiguity. Always try to use two or | |
1229 | more whole words. Generally the name should reflect what is special | |
1230 | about what the module does rather than how it does it. Please use | |
1231 | nested module names to group informally or categorize a module. | |
1232 | There should be a very good reason for a module not to have a nested name. | |
1233 | Module names should begin with a capital letter. | |
1234 | ||
1235 | Having 57 modules all called Sort will not make life easy for anyone | |
1236 | (though having 23 called Sort::Quick is only marginally better :-). | |
1237 | Imagine someone trying to install your module alongside many others. | |
1238 | If in any doubt ask for suggestions in comp.lang.perl.misc. | |
1239 | ||
1240 | If you are developing a suite of related modules/classes it's good | |
1241 | practice to use nested classes with a common prefix as this will | |
1242 | avoid namespace clashes. For example: Xyz::Control, Xyz::View, | |
1243 | Xyz::Model etc. Use the modules in this list as a naming guide. | |
1244 | ||
1245 | If adding a new module to a set, follow the original author's | |
1246 | standards for naming modules and the interface to methods in | |
1247 | those modules. | |
1248 | ||
165c0277 JH |
1249 | If developing modules for private internal or project specific use, |
1250 | that will never be released to the public, then you should ensure | |
1251 | that their names will not clash with any future public module. You | |
1252 | can do this either by using the reserved Local::* category or by | |
1253 | using a category name that includes an underscore like Foo_Corp::*. | |
1254 | ||
f102b883 TC |
1255 | To be portable each component of a module name should be limited to |
1256 | 11 characters. If it might be used on MS-DOS then try to ensure each is | |
1257 | unique in the first 8 characters. Nested modules make this easier. | |
1258 | ||
1259 | =item Have you got it right? | |
1260 | ||
1261 | How do you know that you've made the right decisions? Have you | |
1262 | picked an interface design that will cause problems later? Have | |
1263 | you picked the most appropriate name? Do you have any questions? | |
1264 | ||
1265 | The best way to know for sure, and pick up many helpful suggestions, | |
1266 | is to ask someone who knows. Comp.lang.perl.misc is read by just about | |
1267 | all the people who develop modules and it's the best place to ask. | |
1268 | ||
1269 | All you need to do is post a short summary of the module, its | |
1270 | purpose and interfaces. A few lines on each of the main methods is | |
1271 | probably enough. (If you post the whole module it might be ignored | |
1272 | by busy people - generally the very people you want to read it!) | |
1273 | ||
1274 | Don't worry about posting if you can't say when the module will be | |
1275 | ready - just say so in the message. It might be worth inviting | |
1276 | others to help you, they may be able to complete it for you! | |
1277 | ||
1278 | =item README and other Additional Files. | |
1279 | ||
1280 | It's well known that software developers usually fully document the | |
1281 | software they write. If, however, the world is in urgent need of | |
1282 | your software and there is not enough time to write the full | |
1283 | documentation please at least provide a README file containing: | |
1284 | ||
1285 | =over 10 | |
1286 | ||
1287 | =item * | |
1288 | A description of the module/package/extension etc. | |
1289 | ||
1290 | =item * | |
1291 | A copyright notice - see below. | |
1292 | ||
1293 | =item * | |
1294 | Prerequisites - what else you may need to have. | |
1295 | ||
1296 | =item * | |
1297 | How to build it - possible changes to Makefile.PL etc. | |
1298 | ||
1299 | =item * | |
1300 | How to install it. | |
1301 | ||
1302 | =item * | |
1303 | Recent changes in this release, especially incompatibilities | |
1304 | ||
1305 | =item * | |
1306 | Changes / enhancements you plan to make in the future. | |
1307 | ||
1308 | =back | |
1309 | ||
1310 | If the README file seems to be getting too large you may wish to | |
1311 | split out some of the sections into separate files: INSTALL, | |
1312 | Copying, ToDo etc. | |
1313 | ||
1314 | =over 4 | |
1315 | ||
1316 | =item Adding a Copyright Notice. | |
1317 | ||
1318 | How you choose to license your work is a personal decision. | |
1319 | The general mechanism is to assert your Copyright and then make | |
1320 | a declaration of how others may copy/use/modify your work. | |
1321 | ||
1322 | Perl, for example, is supplied with two types of licence: The GNU | |
1323 | GPL and The Artistic Licence (see the files README, Copying, and | |
1324 | Artistic). Larry has good reasons for NOT just using the GNU GPL. | |
1325 | ||
1326 | My personal recommendation, out of respect for Larry, Perl, and the | |
5a964f20 | 1327 | Perl community at large is to state something simply like: |
f102b883 TC |
1328 | |
1329 | Copyright (c) 1995 Your Name. All rights reserved. | |
1330 | This program is free software; you can redistribute it and/or | |
1331 | modify it under the same terms as Perl itself. | |
1332 | ||
1333 | This statement should at least appear in the README file. You may | |
1334 | also wish to include it in a Copying file and your source files. | |
1335 | Remember to include the other words in addition to the Copyright. | |
1336 | ||
1337 | =item Give the module a version/issue/release number. | |
1338 | ||
1339 | To be fully compatible with the Exporter and MakeMaker modules you | |
1340 | should store your module's version number in a non-my package | |
1341 | variable called $VERSION. This should be a floating point | |
1342 | number with at least two digits after the decimal (i.e., hundredths, | |
1343 | e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version. | |
19799a22 | 1344 | See L<Exporter> for details. |
f102b883 TC |
1345 | |
1346 | It may be handy to add a function or method to retrieve the number. | |
1347 | Use the number in announcements and archive file names when | |
1348 | releasing the module (ModuleName-1.02.tar.Z). | |
1349 | See perldoc ExtUtils::MakeMaker.pm for details. | |
1350 | ||
1351 | =item How to release and distribute a module. | |
1352 | ||
1353 | It's good idea to post an announcement of the availability of your | |
1354 | module (or the module itself if small) to the comp.lang.perl.announce | |
1355 | Usenet newsgroup. This will at least ensure very wide once-off | |
1356 | distribution. | |
1357 | ||
2e1d04bc | 1358 | If possible, register the module with CPAN. You should |
f102b883 TC |
1359 | include details of its location in your announcement. |
1360 | ||
1361 | Some notes about ftp archives: Please use a long descriptive file | |
5a964f20 | 1362 | name that includes the version number. Most incoming directories |
f102b883 TC |
1363 | will not be readable/listable, i.e., you won't be able to see your |
1364 | file after uploading it. Remember to send your email notification | |
1365 | message as soon as possible after uploading else your file may get | |
1366 | deleted automatically. Allow time for the file to be processed | |
1367 | and/or check the file has been processed before announcing its | |
1368 | location. | |
1369 | ||
1370 | FTP Archives for Perl Modules: | |
1371 | ||
6cecdcac | 1372 | Follow the instructions and links on: |
f102b883 | 1373 | |
6cecdcac GS |
1374 | http://www.perl.com/CPAN/modules/00modlist.long.html |
1375 | http://www.perl.com/CPAN/modules/04pause.html | |
f102b883 TC |
1376 | |
1377 | or upload to one of these sites: | |
1378 | ||
6cecdcac GS |
1379 | https://pause.kbx.de/pause/ |
1380 | http://pause.perl.org/pause/ | |
f102b883 | 1381 | |
6cecdcac | 1382 | and notify <modules@perl.org>. |
f102b883 TC |
1383 | |
1384 | By using the WWW interface you can ask the Upload Server to mirror | |
1385 | your modules from your ftp or WWW site into your own directory on | |
1386 | CPAN! | |
1387 | ||
1388 | Please remember to send me an updated entry for the Module list! | |
1389 | ||
1390 | =item Take care when changing a released module. | |
1391 | ||
7b8d334a GS |
1392 | Always strive to remain compatible with previous released versions. |
1393 | Otherwise try to add a mechanism to revert to the | |
19799a22 | 1394 | old behavior if people rely on it. Document incompatible changes. |
f102b883 TC |
1395 | |
1396 | =back | |
1397 | ||
1398 | =back | |
1399 | ||
1400 | =head2 Guidelines for Converting Perl 4 Library Scripts into Modules | |
1401 | ||
1402 | =over 4 | |
1403 | ||
1404 | =item There is no requirement to convert anything. | |
1405 | ||
1406 | If it ain't broke, don't fix it! Perl 4 library scripts should | |
1407 | continue to work with no problems. You may need to make some minor | |
1408 | changes (like escaping non-array @'s in double quoted strings) but | |
1409 | there is no need to convert a .pl file into a Module for just that. | |
1410 | ||
1411 | =item Consider the implications. | |
1412 | ||
5a964f20 | 1413 | All Perl applications that make use of the script will need to |
f102b883 TC |
1414 | be changed (slightly) if the script is converted into a module. Is |
1415 | it worth it unless you plan to make other changes at the same time? | |
1416 | ||
1417 | =item Make the most of the opportunity. | |
1418 | ||
1419 | If you are going to convert the script to a module you can use the | |
19799a22 GS |
1420 | opportunity to redesign the interface. The guidelines for module |
1421 | creation above include many of the issues you should consider. | |
f102b883 TC |
1422 | |
1423 | =item The pl2pm utility will get you started. | |
1424 | ||
1425 | This utility will read *.pl files (given as parameters) and write | |
1426 | corresponding *.pm files. The pl2pm utilities does the following: | |
1427 | ||
1428 | =over 10 | |
1429 | ||
1430 | =item * | |
1431 | Adds the standard Module prologue lines | |
1432 | ||
1433 | =item * | |
1434 | Converts package specifiers from ' to :: | |
1435 | ||
1436 | =item * | |
1437 | Converts die(...) to croak(...) | |
1438 | ||
1439 | =item * | |
1440 | Several other minor changes | |
1441 | ||
1442 | =back | |
1443 | ||
1444 | Being a mechanical process pl2pm is not bullet proof. The converted | |
1445 | code will need careful checking, especially any package statements. | |
1446 | Don't delete the original .pl file till the new .pm one works! | |
1447 | ||
1448 | =back | |
1449 | ||
1450 | =head2 Guidelines for Reusing Application Code | |
1451 | ||
1452 | =over 4 | |
1453 | ||
551e1d92 RB |
1454 | =item * |
1455 | ||
1456 | Complete applications rarely belong in the Perl Module Library. | |
f102b883 | 1457 | |
551e1d92 RB |
1458 | =item * |
1459 | ||
1460 | Many applications contain some Perl code that could be reused. | |
f102b883 TC |
1461 | |
1462 | Help save the world! Share your code in a form that makes it easy | |
1463 | to reuse. | |
1464 | ||
551e1d92 RB |
1465 | =item * |
1466 | ||
1467 | Break-out the reusable code into one or more separate module files. | |
f102b883 | 1468 | |
551e1d92 RB |
1469 | =item * |
1470 | ||
1471 | Take the opportunity to reconsider and redesign the interfaces. | |
1472 | ||
1473 | =item * | |
f102b883 | 1474 | |
551e1d92 | 1475 | In some cases the 'application' can then be reduced to a small |
f102b883 TC |
1476 | |
1477 | fragment of code built on top of the reusable modules. In these cases | |
1478 | the application could invoked as: | |
1479 | ||
5a964f20 | 1480 | % perl -e 'use Module::Name; method(@ARGV)' ... |
f102b883 | 1481 | or |
5a964f20 | 1482 | % perl -mModule::Name ... (in perl5.002 or higher) |
f102b883 TC |
1483 | |
1484 | =back | |
1485 | ||
1486 | =head1 NOTE | |
1487 | ||
1488 | Perl does not enforce private and public parts of its modules as you may | |
1489 | have been used to in other languages like C++, Ada, or Modula-17. Perl | |
1490 | doesn't have an infatuation with enforced privacy. It would prefer | |
1491 | that you stayed out of its living room because you weren't invited, not | |
1492 | because it has a shotgun. | |
1493 | ||
1494 | The module and its user have a contract, part of which is common law, | |
1495 | and part of which is "written". Part of the common law contract is | |
1496 | that a module doesn't pollute any namespace it wasn't asked to. The | |
1497 | written contract for the module (A.K.A. documentation) may make other | |
1498 | provisions. But then you know when you C<use RedefineTheWorld> that | |
1499 | you're redefining the world and willing to take the consequences. |