Regen toc and modlib.
[p5sagit/p5-mst-13.2.git] / pod / perlmodlib.pod
CommitLineData
4e860d0a 1# Generated by perlmodlib.PL DO NOT EDIT!
2
f102b883 3=head1 NAME
4
5perlmodlib - constructing new Perl modules and finding existing ones
6
7=head1 DESCRIPTION
8
9=head1 THE PERL MODULE LIBRARY
10
19799a22 11Many modules are included the Perl distribution. These are described
12below, and all end in F<.pm>. You may discover compiled library
13file (usually ending in F<.so>) or small pieces of modules to be
14autoloaded (ending in F<.al>); these were automatically generated
15by the installation process. You may also discover files in the
16library directory that end in either F<.pl> or F<.ph>. These are
17old libraries supplied so that old programs that use them still
18run. The F<.pl> files will all eventually be converted into standard
19modules, and the F<.ph> files made by B<h2ph> will probably end up
20as extension modules made by B<h2xs>. (Some F<.ph> values may
21already be available through the POSIX, Errno, or Fcntl modules.)
22The B<pl2pm> file in the distribution may help in your conversion,
23but it's just a mechanical process and therefore far from bulletproof.
f102b883 24
25=head2 Pragmatic Modules
26
19799a22 27They work somewhat like compiler directives (pragmata) in that they
28tend to affect the compilation of your program, and thus will usually
29work well only when used within a C<use>, or C<no>. Most of these
30are lexically scoped, so an inner BLOCK may countermand them
31by saying:
f102b883 32
33 no integer;
34 no strict 'refs';
4438c4b7 35 no warnings;
f102b883 36
37which lasts until the end of that BLOCK.
38
19799a22 39Some pragmas are lexically scoped--typically those that affect the
40C<$^H> hints variable. Others affect the current package instead,
77ca0c92 41like C<use vars> and C<use subs>, which allow you to predeclare a
19799a22 42variables or subroutines within a particular I<file> rather than
43just a block. Such declarations are effective for the entire file
44for which they were declared. You cannot rescind them with C<no
45vars> or C<no subs>.
f102b883 46
47The following pragmas are defined (and have their own documentation).
48
49=over 12
50
09bef843 51=item attributes
52
9e107c59 53Get/set subroutine or variable attributes
09bef843 54
19799a22 55=item attrs
f102b883 56
9e107c59 57Set/get attributes of a subroutine (deprecated)
19799a22 58
59=item autouse
60
9e107c59 61Postpone load of modules until a function is used
19799a22 62
63=item base
64
65Establish IS-A relationship with base class at compile time
f102b883 66
67=item blib
68
19799a22 69Use MakeMaker's uninstalled version of a package
70
2e1d04bc 71=item bytes
9e107c59 72
2e1d04bc 73Force byte semantics rather than character semantics
9e107c59 74
75=item charnames
76
77Define character names for C<\N{named}> string literal escape.
78
19799a22 79=item constant
80
9e107c59 81Declare constants
f102b883 82
83=item diagnostics
84
2e1d04bc 85Perl compiler pragma to force verbose warning diagnostics
19799a22 86
87=item fields
88
2e1d04bc 89Compile-time class fields
19799a22 90
91=item filetest
92
2e1d04bc 93Control the filetest permission operators
f102b883 94
95=item integer
96
4e860d0a 97Use integer arithmetic instead of floating point
f102b883 98
99=item less
100
2e1d04bc 101Request less of something from the compiler
f102b883 102
f102b883 103=item locale
104
2e1d04bc 105Use and avoid POSIX locales for built-in operations
106
107=item open
108
109Set default disciplines for input and output
f102b883 110
111=item ops
112
9e107c59 113Restrict unsafe operations when compiling
f102b883 114
115=item overload
116
2e1d04bc 117Package for overloading perl operations
f102b883 118
b3eb6a9b 119=item re
120
2e1d04bc 121Alter regular expression behaviour
b3eb6a9b 122
f102b883 123=item sigtrap
124
9e107c59 125Enable simple signal handling
f102b883 126
127=item strict
128
9e107c59 129Restrict unsafe constructs
f102b883 130
131=item subs
132
2e1d04bc 133Predeclare sub names
f102b883 134
4e860d0a 135=item unicode::distinct
136
137Strictly distinguish UTF8 data and non-UTF data.
138
19799a22 139=item utf8
f102b883 140
1fa7ca25 141Enable/disable UTF-8 (or UTF-EBCDIC) in source code
f102b883 142
143=item vars
144
2e1d04bc 145Predeclare global variable names (obsolete)
f102b883 146
4438c4b7 147=item warnings
0453d815 148
9e107c59 149Control optional warnings
19799a22 150
13a2d996 151=item warnings::register
152
153Warnings import function
154
f102b883 155=back
156
157=head2 Standard Modules
158
159Standard, bundled modules are all expected to behave in a well-defined
160manner with respect to namespace pollution because they use the
161Exporter module. See their own documentation for details.
162
163=over 12
164
165=item AnyDBM_File
166
2e1d04bc 167Provide framework for multiple DBMs
f102b883 168
dc6b6eef 169=item Attribute::Handlers
170
171Simpler definition of attribute handlers
172
f102b883 173=item AutoLoader
174
9e107c59 175Load subroutines only on demand
f102b883 176
177=item AutoSplit
178
9e107c59 179Split a package for autoloading
f102b883 180
19799a22 181=item B
182
2e1d04bc 183The Perl Compiler
19799a22 184
185=item B::Asmdata
186
187Autogenerated data about Perl ops, used to generate bytecode
188
189=item B::Assembler
190
191Assemble Perl bytecode
192
193=item B::Bblock
194
195Walk basic blocks
196
197=item B::Bytecode
198
199Perl compiler's bytecode backend
200
201=item B::C
202
203Perl compiler's C backend
204
205=item B::CC
206
207Perl compiler's optimized C translation backend
208
4e860d0a 209=item B::Concise
210
211Walk Perl syntax tree, printing concise info about ops
212
19799a22 213=item B::Debug
214
215Walk Perl syntax tree, printing debug info about ops
216
217=item B::Deparse
218
2e1d04bc 219Perl compiler backend to produce perl code
19799a22 220
221=item B::Disassembler
222
223Disassemble Perl bytecode
224
225=item B::Lint
226
2e1d04bc 227Perl lint
19799a22 228
229=item B::Showlex
230
231Show lexical variables used in functions or files
232
233=item B::Stackobj
234
235Helper module for CC backend
236
13a2d996 237=item B::Stash
238
239Show what stashes are loaded
240
19799a22 241=item B::Terse
242
243Walk Perl syntax tree, printing terse info about ops
244
245=item B::Xref
246
247Generates cross reference reports for Perl programs
248
f102b883 249=item Benchmark
250
2e1d04bc 251Benchmark running times of Perl code
9e107c59 252
253=item ByteLoader
254
2e1d04bc 255Load byte compiled perl code
f102b883 256
19799a22 257=item CGI
258
2e1d04bc 259Simple Common Gateway Interface Class
19799a22 260
261=item CGI::Apache
262
2e1d04bc 263Backward compatibility module for CGI.pm
19799a22 264
265=item CGI::Carp
266
267CGI routines for writing to the HTTPD (or other) error log
268
269=item CGI::Cookie
270
271Interface to Netscape Cookies
272
273=item CGI::Fast
274
275CGI Interface for Fast CGI
276
9e107c59 277=item CGI::Pretty
278
279Module to produce nicely formatted HTML code
280
19799a22 281=item CGI::Push
282
283Simple Interface to Server Push
284
285=item CGI::Switch
286
2e1d04bc 287Backward compatibility module for defunct CGI::Switch
19799a22 288
4e860d0a 289=item CGI::Util
290
291Internal utilities used by CGI module
292
f102b883 293=item CPAN
294
2e1d04bc 295Query, download and build perl modules from CPAN sites
f102b883 296
297=item CPAN::FirstTime
298
2e1d04bc 299Utility for CPAN::Config file Initialization
f102b883 300
301=item CPAN::Nox
302
19799a22 303Wrapper around CPAN.pm without using any XS module
f102b883 304
305=item Carp
306
2e1d04bc 307Warn of errors (from perspective of caller)
9e107c59 308
4e860d0a 309=item Carp::Heavy
310
311No user serviceable parts inside
312
313=item Class::ISA
314
315Report the search path for a class's ISA tree
316
f102b883 317=item Class::Struct
318
9e107c59 319Declare struct-like datatypes as Perl classes
f102b883 320
f102b883 321=item Cwd
322
9e107c59 323Get pathname of current working directory
f102b883 324
19799a22 325=item DB
326
2e1d04bc 327Programmatic interface to the Perl debugging API (draft, subject to
19799a22 328
f102b883 329=item DB_File
330
19799a22 331Perl5 access to Berkeley DB version 1.x
332
f102b883 333=item Devel::SelfStubber
334
9e107c59 335Generate stubs for a SelfLoading module
f102b883 336
4e860d0a 337=item Digest
338
339Modules that calculate message digests
340
f102b883 341=item DirHandle
342
9e107c59 343Supply object methods for directory handles
f102b883 344
19799a22 345=item Dumpvalue
346
2e1d04bc 347Provides screen dump of Perl data.
f102b883 348
13a2d996 349=item Encode
350
351Character encodings
352
4e860d0a 353=item Encode::EncodeFormat
354
355The format of encoding tables of the Encode extension
356
357=item Encode::Tcl
358
359Tcl encodings
360
f102b883 361=item English
362
2e1d04bc 363Use nice English (or awk) names for ugly punctuation variables
f102b883 364
365=item Env
366
2e1d04bc 367Perl module that imports environment variables as scalars or arrays
f102b883 368
369=item Exporter
370
2e1d04bc 371Implements default import method for modules
9e107c59 372
373=item Exporter::Heavy
374
375Exporter guts
19799a22 376
377=item ExtUtils::Command
378
2e1d04bc 379Utilities to replace common UNIX commands in Makefiles etc.
f102b883 380
422a9aca 381=item ExtUtils::Constant
382
383Generate XS code to import C header constants
384
f102b883 385=item ExtUtils::Embed
386
2e1d04bc 387Utilities for embedding Perl in C/C++ applications
f102b883 388
389=item ExtUtils::Install
390
9e107c59 391Install files from here to there
f102b883 392
19799a22 393=item ExtUtils::Installed
394
395Inventory management of installed modules
396
f102b883 397=item ExtUtils::Liblist
398
9e107c59 399Determine libraries to use and how to use them
400
401=item ExtUtils::MM_Cygwin
402
2e1d04bc 403Methods to override UN*X behaviour in ExtUtils::MakeMaker
f102b883 404
5d80033a 405=item ExtUtils::MM_NW5
406
407Methods to override UN*X behaviour in ExtUtils::MakeMaker
408
f102b883 409=item ExtUtils::MM_OS2
410
2e1d04bc 411Methods to override UN*X behaviour in ExtUtils::MakeMaker
f102b883 412
413=item ExtUtils::MM_Unix
414
9e107c59 415Methods used by ExtUtils::MakeMaker
f102b883 416
417=item ExtUtils::MM_VMS
418
2e1d04bc 419Methods to override UN*X behaviour in ExtUtils::MakeMaker
19799a22 420
421=item ExtUtils::MM_Win32
422
2e1d04bc 423Methods to override UN*X behaviour in ExtUtils::MakeMaker
f102b883 424
425=item ExtUtils::MakeMaker
426
9e107c59 427Create an extension Makefile
f102b883 428
429=item ExtUtils::Manifest
430
9e107c59 431Utilities to write and check a MANIFEST file
f102b883 432
433=item ExtUtils::Mkbootstrap
434
9e107c59 435Make a bootstrap file for use by DynaLoader
f102b883 436
437=item ExtUtils::Mksymlists
438
9e107c59 439Write linker options files for dynamic extension
f102b883 440
19799a22 441=item ExtUtils::Packlist
442
9e107c59 443Manage .packlist files
19799a22 444
f102b883 445=item ExtUtils::testlib
446
9e107c59 447Add blib/* directories to @INC
f102b883 448
b6c543e3 449=item Fatal
450
9e107c59 451Replace functions with equivalents which succeed or die
b6c543e3 452
f102b883 453=item Fcntl
454
2e1d04bc 455Load the C Fcntl.h defines
f102b883 456
457=item File::Basename
458
9e107c59 459Split a pathname into pieces
460
461=item File::CheckTree
462
463Run many filetest checks on a tree
f102b883 464
f102b883 465=item File::Compare
466
19799a22 467Compare files or filehandles
f102b883 468
469=item File::Copy
470
19799a22 471Copy files or filehandles
472
473=item File::DosGlob
474
2e1d04bc 475DOS like globbing and then some
f102b883 476
477=item File::Find
478
2e1d04bc 479Traverse a file tree
f102b883 480
481=item File::Path
482
2e1d04bc 483Create or remove directory trees
f102b883 484
f505c983 485=item File::Spec
486
9e107c59 487Portably perform operations on file names
f505c983 488
165c0277 489=item File::Spec::Epoc
490
491Methods for Epoc file specs
492
f505c983 493=item File::Spec::Functions
494
9e107c59 495Portably perform operations on file names
19799a22 496
497=item File::Spec::Mac
498
499File::Spec for MacOS
500
501=item File::Spec::OS2
502
9e107c59 503Methods for OS/2 file specs
19799a22 504
505=item File::Spec::Unix
506
9e107c59 507Methods used by File::Spec
19799a22 508
509=item File::Spec::VMS
510
9e107c59 511Methods for VMS file specs
19799a22 512
513=item File::Spec::Win32
514
9e107c59 515Methods for Win32 file specs
f505c983 516
2e1d04bc 517=item File::Temp
518
519Return name and handle of a temporary file safely
520
f102b883 521=item File::stat
522
9e107c59 523By-name interface to Perl's built-in stat() functions
f102b883 524
525=item FileCache
526
9e107c59 527Keep more files open than the system permits
f102b883 528
529=item FileHandle
530
9e107c59 531Supply object methods for filehandles
f102b883 532
165c0277 533=item Filter::Simple
534
535Simplified source filtering
536
f102b883 537=item FindBin
538
2e1d04bc 539Locate directory of original perl script
f102b883 540
541=item Getopt::Long
542
9e107c59 543Extended processing of command line options
f102b883 544
545=item Getopt::Std
546
19799a22 547Process single-character switches with switch clustering
f102b883 548
549=item I18N::Collate
550
2e1d04bc 551Compare 8-bit scalar data according to the current locale
f102b883 552
422a9aca 553=item I18N::LangTags
554
555Functions for dealing with RFC3066-style language tags
556
557=item I18N::LangTags::List
558
4f233aa4 559Tags and names for human languages
422a9aca 560
f102b883 561=item IO
562
2e1d04bc 563Load various IO modules
f102b883 564
565=item IPC::Open2
566
9e107c59 567Open a process for both reading and writing
f102b883 568
569=item IPC::Open3
570
9e107c59 571Open a process for reading, writing, and error handling
f102b883 572
4e860d0a 573=item Locale::Constants
574
575Constants for Locale codes
576
577=item Locale::Country
578
579ISO codes for country identification (ISO 3166)
580
581=item Locale::Currency
582
583ISO three letter codes for currency identification (ISO 4217)
584
585=item Locale::Language
586
587ISO two letter codes for language identification (ISO 639)
588
422a9aca 589=item Locale::Maketext
590
591Framework for localization
592
593=item Locale::Maketext::TPJ13
594
595Article about software localization
596
f102b883 597=item Math::BigFloat
598
5d80033a 599Arbitrary size floating point math package
f102b883 600
601=item Math::BigInt
602
19799a22 603Arbitrary size integer math package
f102b883 604
d0363f02 605=item Math::BigInt::Calc
606
607Pure Perl module to support Math::BigInt
608
f102b883 609=item Math::Complex
610
9e107c59 611Complex numbers and associated mathematical functions
f102b883 612
404b15a1 613=item Math::Trig
614
9e107c59 615Trigonometric functions
f102b883 616
5d80033a 617=item Memoize
618
619Make your functions faster by trading space for time
620
621=item Memoize::AnyDBM_File
622
623Glue to provide EXISTS for AnyDBM_File for Storable use
624
625=item Memoize::Expire
626
627Plug-in module for automatic expiration of memoized values
628
629=item Memoize::ExpireFile
630
631Test for Memoize expiration semantics
632
633=item Memoize::ExpireTest
634
635Test for Memoize expiration semantics
636
637=item Memoize::NDBM_File
638
639Glue to provide EXISTS for NDBM_File for Storable use
640
641=item Memoize::SDBM_File
642
643Glue to provide EXISTS for SDBM_File for Storable use
644
645=item Memoize::Saves
646
647Plug-in module to specify which return values should be memoized
648
649=item Memoize::Storable
650
651Store Memoized data in Storable database
652
2e1d04bc 653=item NDBM_File
654
655Tied access to ndbm files
656
1fa7ca25 657=item NEXT
658
659Provide a pseudo-class NEXT that allows method redispatch
660
5d80033a 661=item Net::Cmd
662
663Network Command class (as used by FTP, SMTP etc)
664
665=item Net::Config
666
667Local configuration data for libnet
668
669=item Net::Domain
670
671Attempt to evaluate the current host's internet name and domain
672
5d80033a 673=item Net::FTP
674
675FTP Client class
676
677=item Net::NNTP
678
679NNTP Client class
680
681=item Net::Netrc
682
683OO interface to users netrc file
684
5d80033a 685=item Net::POP3
686
687Post Office Protocol 3 Client class (RFC1081)
688
f102b883 689=item Net::Ping
690
9e107c59 691Check a remote host for reachability
f102b883 692
5d80033a 693=item Net::SMTP
694
695Simple Mail Transfer Protocol Client
696
5d80033a 697=item Net::Time
698
699Time and daytime network client interface
700
f102b883 701=item Net::hostent
702
9e107c59 703By-name interface to Perl's built-in gethost*() functions
f102b883 704
5d80033a 705=item Net::libnetFAQ
706
707Libnet Frequently Asked Questions
708
f102b883 709=item Net::netent
710
9e107c59 711By-name interface to Perl's built-in getnet*() functions
f102b883 712
713=item Net::protoent
714
9e107c59 715By-name interface to Perl's built-in getproto*() functions
f102b883 716
717=item Net::servent
718
9e107c59 719By-name interface to Perl's built-in getserv*() functions
f102b883 720
19799a22 721=item O
f102b883 722
19799a22 723Generic interface to Perl Compiler backends
f102b883 724
2e1d04bc 725=item ODBM_File
f102b883 726
2e1d04bc 727Tied access to odbm files
f102b883 728
2e1d04bc 729=item Opcode
f102b883 730
2e1d04bc 731Disable named opcodes when compiling perl code
19799a22 732
4e860d0a 733=item POSIX
734
735Perl interface to IEEE Std 1003.1
736
737=item PerlIO
738
739On demand loader for PerlIO layers and root of PerlIO::* name space
740
9e107c59 741=item Pod::Checker
742
743Check pod documents for syntax errors
744
2e1d04bc 745=item Pod::Find
746
747Find POD documents in directory trees
748
19799a22 749=item Pod::Html
750
9e107c59 751Module to convert pod files to HTML
752
753=item Pod::InputObjects
754
2e1d04bc 755Objects representing POD input paragraphs, commands, etc.
9e107c59 756
13a2d996 757=item Pod::LaTeX
758
759Convert Pod data to formatted Latex
760
9e107c59 761=item Pod::Man
762
763Convert POD data to formatted *roff input
764
2e1d04bc 765=item Pod::ParseUtils
766
767Helpers for POD parsing and conversion
768
9e107c59 769=item Pod::Parser
770
771Base class for creating POD filters and translators
772
2e1d04bc 773=item Pod::Plainer
774
775Perl extension for converting Pod to old style Pod.
776
9e107c59 777=item Pod::Select
778
779Extract selected sections of POD from input
19799a22 780
781=item Pod::Text
782
9e107c59 783Convert POD data to formatted ASCII text
784
785=item Pod::Text::Color
786
787Convert POD data to formatted color ASCII text
788
4e860d0a 789=item Pod::Text::Overstrike
790
791Convert POD data to formatted overstrike text
792
2e1d04bc 793=item Pod::Text::Termcap
794
795Convert POD data to ASCII text with format escapes
796
9e107c59 797=item Pod::Usage
798
799Print a usage message from embedded pod documentation
f102b883 800
801=item SDBM_File
802
19799a22 803Tied access to sdbm files
f102b883 804
805=item Safe
806
19799a22 807Compile and execute code in restricted compartments
f102b883 808
809=item Search::Dict
810
9e107c59 811Search for key in dictionary file
f102b883 812
813=item SelectSaver
814
9e107c59 815Save and restore selected file handle
f102b883 816
817=item SelfLoader
818
9e107c59 819Load functions only on demand
f102b883 820
821=item Shell
822
2e1d04bc 823Run shell commands transparently within perl
f102b883 824
825=item Socket
826
2e1d04bc 827Load the C socket.h defines and structure manipulators
f102b883 828
13a2d996 829=item Storable
830
831Persistency for perl data structures
832
4e860d0a 833=item Switch
834
835A switch statement for Perl
836
f102b883 837=item Symbol
838
9e107c59 839Manipulate Perl symbols and their names
f102b883 840
2e1d04bc 841=item Term::ANSIColor
f102b883 842
2e1d04bc 843Color screen output using ANSI escape sequences
f102b883 844
845=item Term::Cap
846
2e1d04bc 847Perl termcap interface
f102b883 848
849=item Term::Complete
850
2e1d04bc 851Perl word completion module
f102b883 852
853=item Term::ReadLine
854
2e1d04bc 855Perl interface to various C<readline> packages. If
19799a22 856
857=item Test
858
9e107c59 859Provides a simple framework for writing test scripts
f102b883 860
861=item Test::Harness
862
2e1d04bc 863Run perl standard test scripts with statistics
f102b883 864
7a49b635 865=item Test::More
866
867Yet another framework for writing test scripts
868
869=item Test::Simple
870
871Basic utilities for writing tests.
872
f102b883 873=item Text::Abbrev
874
9e107c59 875Create an abbreviation table from a list
f102b883 876
4e860d0a 877=item Text::Balanced
878
879Extract delimited text sequences from strings.
880
f102b883 881=item Text::ParseWords
882
2e1d04bc 883Parse text into an array of tokens or array of arrays
f102b883 884
885=item Text::Soundex
886
2e1d04bc 887Implementation of the Soundex Algorithm as Described by Knuth
f102b883 888
4e860d0a 889=item Text::Tabs
890
891Expand and unexpand tabs per the unix expand(1) and unexpand(1)
892
f102b883 893=item Text::Wrap
894
9e107c59 895Line wrapping to form simple paragraphs
19799a22 896
897=item Tie::Array
898
9e107c59 899Base class for tied arrays
19799a22 900
901=item Tie::Handle
902
9e107c59 903Base class definitions for tied handles
19799a22 904
9e107c59 905=item Tie::Hash
f102b883 906
9e107c59 907Base class definitions for tied hashes
f102b883 908
909=item Tie::RefHash
910
9e107c59 911Use references as hash keys
f102b883 912
9e107c59 913=item Tie::Scalar
f102b883 914
9e107c59 915Base class definitions for tied scalars
f102b883 916
917=item Tie::SubstrHash
918
19799a22 919Fixed-table-size, fixed-key-length hashing
f102b883 920
921=item Time::Local
922
9e107c59 923Efficiently compute time from local and GMT time
f102b883 924
925=item Time::gmtime
926
9e107c59 927By-name interface to Perl's built-in gmtime() function
f102b883 928
929=item Time::localtime
930
9e107c59 931By-name interface to Perl's built-in localtime() function
f102b883 932
933=item Time::tm
934
9e107c59 935Internal object used by Time::gmtime and Time::localtime
f102b883 936
937=item UNIVERSAL
938
9e107c59 939Base class for ALL classes (blessed references)
f102b883 940
fbe3d936 941=item Unicode::UCD
942
943Unicode character database
944
f102b883 945=item User::grent
946
9e107c59 947By-name interface to Perl's built-in getgr*() functions
f102b883 948
949=item User::pwent
950
9e107c59 951By-name interface to Perl's built-in getpw*() functions
f102b883 952
4e860d0a 953=item Win32
954
955Interfaces to some Win32 API Functions
956
f102b883 957=back
958
19799a22 959To find out I<all> modules installed on your system, including
2e1d04bc 960those without documentation or outside the standard release,
b1866b2d 961just do this:
f102b883 962
5a964f20 963 % find `perl -e 'print "@INC"'` -name '*.pm' -print
f102b883 964
2e1d04bc 965They should all have their own documentation installed and accessible
966via your system man(1) command. If you do not have a B<find>
19799a22 967program, you can use the Perl B<find2perl> program instead, which
968generates Perl code as output you can run through perl. If you
969have a B<man> program but it doesn't find your modules, you'll have
2e1d04bc 970to fix your manpath. See L<perl> for details. If you have no
971system B<man> command, you might try the B<perldoc> program.
f102b883 972
973=head2 Extension Modules
974
19799a22 975Extension modules are written in C (or a mix of Perl and C). They
976are usually dynamically loaded into Perl if and when you need them,
2e1d04bc 977but may also be be linked in statically. Supported extension modules
19799a22 978include Socket, Fcntl, and POSIX.
f102b883 979
980Many popular C extension modules do not come bundled (at least, not
19799a22 981completely) due to their sizes, volatility, or simply lack of time
982for adequate testing and configuration across the multitude of
983platforms on which Perl was beta-tested. You are encouraged to
984look for them on CPAN (described below), or using web search engines
985like Alta Vista or Deja News.
f102b883 986
987=head1 CPAN
988
19799a22 989CPAN stands for Comprehensive Perl Archive Network; it's a globally
990replicated trove of Perl materials, including documentation, style
2e1d04bc 991guides, tricks and traps, alternate ports to non-Unix systems and
19799a22 992occasional binary distributions for these. Search engines for
993CPAN can be found at http://cpan.perl.com/ and at
994http://theory.uwinnipeg.ca/mod_perl/cpan-search.pl .
995
996Most importantly, CPAN includes around a thousand unbundled modules,
997some of which require a C compiler to build. Major categories of
998modules are:
f102b883 999
4e860d0a 1000=over
f102b883 1001
1002=item *
551e1d92 1003
f102b883 1004Language Extensions and Documentation Tools
1005
1006=item *
551e1d92 1007
f102b883 1008Development Support
1009
1010=item *
551e1d92 1011
f102b883 1012Operating System Interfaces
1013
1014=item *
551e1d92 1015
f102b883 1016Networking, Device Control (modems) and InterProcess Communication
1017
1018=item *
551e1d92 1019
f102b883 1020Data Types and Data Type Utilities
1021
1022=item *
551e1d92 1023
f102b883 1024Database Interfaces
1025
1026=item *
551e1d92 1027
f102b883 1028User Interfaces
1029
1030=item *
551e1d92 1031
f102b883 1032Interfaces to / Emulations of Other Programming Languages
1033
1034=item *
551e1d92 1035
f102b883 1036File Names, File Systems and File Locking (see also File Handles)
1037
1038=item *
551e1d92 1039
f102b883 1040String Processing, Language Text Processing, Parsing, and Searching
1041
1042=item *
551e1d92 1043
f102b883 1044Option, Argument, Parameter, and Configuration File Processing
1045
1046=item *
551e1d92 1047
f102b883 1048Internationalization and Locale
1049
1050=item *
551e1d92 1051
f102b883 1052Authentication, Security, and Encryption
1053
1054=item *
551e1d92 1055
f102b883 1056World Wide Web, HTML, HTTP, CGI, MIME
1057
1058=item *
551e1d92 1059
f102b883 1060Server and Daemon Utilities
1061
1062=item *
551e1d92 1063
f102b883 1064Archiving and Compression
1065
1066=item *
551e1d92 1067
f102b883 1068Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
1069
1070=item *
551e1d92 1071
f102b883 1072Mail and Usenet News
1073
1074=item *
551e1d92 1075
f102b883 1076Control Flow Utilities (callbacks and exceptions etc)
1077
1078=item *
551e1d92 1079
f102b883 1080File Handle and Input/Output Stream Utilities
1081
1082=item *
551e1d92 1083
f102b883 1084Miscellaneous Modules
1085
1086=back
1087
19799a22 1088Registered CPAN sites as of this writing include the following.
f102b883 1089You should try to choose one close to you:
1090
4e860d0a 1091=head2 Africa
1092
cea6626f 1093=over 4
f102b883 1094
4e860d0a 1095=item *
1096
1097South Africa
1098
1099 ftp://ftp.is.co.za/programming/perl/CPAN/
1100 ftp://ftp.saix.net/pub/CPAN/
1101 ftp://ftpza.co.za/pub/mirrors/cpan/
1102 ftp://ftp.sun.ac.za/CPAN/
1103
1104=back
1105
1106=head2 Asia
1107
1108=over 4
1109
1110=item *
1111
1112China
1113
1114 ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/
1115 http://www2.linuxforum.net/mirror/CPAN/
1116 http://cpan.shellhung.org/
1117 ftp://ftp.shellhung.org/pub/CPAN
1118
1119=item *
1120
1121Hong Kong
1122
1123 http://CPAN.pacific.net.hk/
1124 ftp://ftp.pacific.net.hk/pub/mirror/CPAN/
1125
1126=item *
1127
1128Indonesia
1129
1130 http://piksi.itb.ac.id/CPAN/
1131 ftp://mirrors.piksi.itb.ac.id/CPAN/
1132 http://CPAN.mweb.co.id/
1133 ftp://ftp.mweb.co.id/pub/languages/perl/CPAN/
1134
1135=item *
1136
1137Israel
1138
1139 http://www.iglu.org.il:/pub/CPAN/
1140 ftp://ftp.iglu.org.il/pub/CPAN/
1141 http://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
1142 ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
1143
1144=item *
1145
1146Japan
1147
1148 ftp://ftp.u-aizu.ac.jp/pub/lang/perl/CPAN/
1149 ftp://ftp.kddlabs.co.jp/CPAN/
1150 http://mirror.nucba.ac.jp/mirror/Perl/
1151 ftp://mirror.nucba.ac.jp/mirror/Perl/
1152 ftp://ftp.meisei-u.ac.jp/pub/CPAN/
1153 ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
1154 ftp://ftp.dti.ad.jp/pub/lang/CPAN/
1155 ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
1156
1157=item *
1158
1159Saudi Arabia
1160
1161 ftp://ftp.isu.net.sa/pub/CPAN/
1162
1163=item *
1164
1165Singapore
1166
1167 http://cpan.hjc.edu.sg
1168 http://ftp.nus.edu.sg/unix/perl/CPAN/
1169 ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/
1170
1171=item *
1172
1173South Korea
1174
1175 http://CPAN.bora.net/
1176 ftp://ftp.bora.net/pub/CPAN/
1177 http://ftp.kornet.net/CPAN/
1178 ftp://ftp.kornet.net/pub/CPAN/
1179 ftp://ftp.nuri.net/pub/CPAN/
1180
1181=item *
1182
1183Taiwan
1184
1185 ftp://coda.nctu.edu.tw/UNIX/perl/CPAN
1186 ftp://ftp.ee.ncku.edu.tw/pub/perl/CPAN/
1187 ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/
1188
1189=item *
1190
1191Thailand
1192
1193 http://download.nectec.or.th/CPAN/
1194 ftp://ftp.nectec.or.th/pub/languages/CPAN/
1195 ftp://ftp.cs.riubon.ac.th/pub/mirrors/CPAN/
1196
1197=back
1198
1199=head2 Central America
1200
1201=over 4
1202
1203=item *
1204
1205Costa Rica
1206
1207 ftp://ftp.linux.co.cr/mirrors/CPAN/
1208 http://ftp.ucr.ac.cr/Unix/CPAN/
1209 ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/
1210
1211=back
1212
1213=head2 Europe
1214
1215=over 4
1216
1217=item *
1218
1219Austria
1220
1221 ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
1222
1223=item *
1224
1225Belgium
1226
1227 http://ftp.easynet.be/CPAN/
1228 ftp://ftp.easynet.be/CPAN/
1229 ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
1230
1231=item *
1232
1233Bulgaria
1234
1235 ftp://ftp.ntrl.net/pub/mirrors/CPAN/
1236
1237=item *
1238
1239Croatia
1240
1241 ftp://ftp.linux.hr/pub/CPAN/
1242
1243=item *
1244
1245Czech Republic
1246
1247 http://www.fi.muni.cz/pub/perl/
1248 ftp://ftp.fi.muni.cz/pub/perl/
1249 ftp://sunsite.mff.cuni.cz/MIRRORS/ftp.funet.fi/pub/languages/perl/CPAN/
1250
1251=item *
1252
1253Denmark
1254
1255 ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
1256 http://www.cpan.dk/CPAN/
1257 ftp://www.cpan.dk/ftp.cpan.org/CPAN/
1258
1259=item *
1260
1261England
1262
1263 http://www.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN
1264 ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/
1265 ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
1266 ftp://ftp.flirble.org/pub/languages/perl/CPAN/
1267 ftp://ftp.plig.org/pub/CPAN/
1268 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
1269 http://mirror.uklinux.net/CPAN/
1270 ftp://mirror.uklinux.net/pub/CPAN/
1271 ftp://usit.shef.ac.uk/pub/packages/CPAN/
1272
1273=item *
1274
1275Estonia
1276
1277 ftp://ftp.ut.ee/pub/languages/perl/CPAN/
1278
1279=item *
1280
1281Finland
1282
1283 ftp://ftp.funet.fi/pub/languages/perl/CPAN/
1284
1285=item *
1286
1287France
1288
1289 ftp://cpan.ftp.worldonline.fr/pub/CPAN/
1290 ftp://ftp.club-internet.fr/pub/perl/CPAN/
1291 ftp://ftp.lip6.fr/pub/perl/CPAN/
1292 ftp://ftp.oleane.net/pub/mirrors/CPAN/
1293 ftp://ftp.pasteur.fr/pub/computing/CPAN/
1294 ftp://cpan.cict.fr/pub/CPAN/
1295 ftp://ftp.uvsq.fr/pub/perl/CPAN/
1296
1297=item *
1298
1299Germany
1300
1301 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
1302 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/CPAN/
1303 ftp://ftp.uni-erlangen.de/pub/source/CPAN/
1304 ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/CPAN
1305 ftp://ftp.gigabell.net/pub/CPAN/
1306 http://ftp.gwdg.de/pub/languages/perl/CPAN/
1307 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
1308 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
1309 ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/
1310 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
1311 ftp://ftp.gmd.de/mirrors/CPAN/
1312
1313=item *
1314
1315Greece
1316
1317 ftp://ftp.forthnet.gr/pub/languages/perl/CPAN
1318 ftp://ftp.ntua.gr/pub/lang/perl/
1319
1320=item *
1321
1322Hungary
1323
1324 http://cpan.artifact.hu/
1325 ftp://cpan.artifact.hu/CPAN/
1326 ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
1327
1328=item *
1329
1330Iceland
1331
1332 http://cpan.gm.is/
1333 ftp://ftp.gm.is/pub/CPAN/
1334
1335=item *
1336
1337Ireland
1338
1339 http://cpan.indigo.ie/
1340 ftp://cpan.indigo.ie/pub/CPAN/
1341 http://sunsite.compapp.dcu.ie/pub/perl/
1342 ftp://sunsite.compapp.dcu.ie/pub/perl/
1343
1344=item *
1345
1346Italy
1347
1348 http://cpan.nettuno.it/
1349 http://gusp.dyndns.org/CPAN/
1350 ftp://gusp.dyndns.org/pub/CPAN
1351 http://softcity.iol.it/cpan
1352 ftp://softcity.iol.it/pub/cpan
1353 ftp://ftp.unina.it/pub/Other/CPAN/
1354 ftp://ftp.unipi.it/pub/mirror/perl/CPAN/
1355 ftp://cis.uniRoma2.it/CPAN/
1356 ftp://ftp.edisontel.it/pub/CPAN_Mirror/
1357 ftp://ftp.flashnet.it/pub/CPAN/
1358
1359=item *
1360
1361Latvia
1362
1363 http://kvin.lv/pub/CPAN/
1364
1365=item *
1366
1367Netherlands
1368
1369 ftp://download.xs4all.nl/pub/mirror/CPAN/
1370 ftp://ftp.nl.uu.net/pub/CPAN/
1371 ftp://ftp.nluug.nl/pub/languages/perl/CPAN/
1372 ftp://ftp.cpan.nl/pub/CPAN/
1373 http://www.cs.uu.nl/mirror/CPAN/
1374 ftp://ftp.cs.uu.nl/mirror/CPAN/
1375
1376=item *
1377
1378Norway
1379
1380 ftp://sunsite.uio.no/pub/languages/perl/CPAN/
1381 ftp://ftp.uit.no/pub/languages/perl/cpan/
1382
1383=item *
1384
1385Poland
1386
1387 ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
1388 ftp://ftp.mega.net.pl/pub/mirrors/ftp.perl.com/
1389 ftp://ftp.man.torun.pl/pub/doc/CPAN/
1390 ftp://sunsite.icm.edu.pl/pub/CPAN/
1391
1392=item *
1393
1394Portugal
1395
1396 ftp://ftp.ua.pt/pub/CPAN/
1397 ftp://perl.di.uminho.pt/pub/CPAN/
1398 ftp://ftp.ist.utl.pt/pub/CPAN/
1399 ftp://ftp.netc.pt/pub/CPAN/
1400
1401=item *
1402
1403Romania
1404
1405 ftp://archive.logicnet.ro/mirrors/ftp.cpan.org/CPAN/
1406 ftp://ftp.kappa.ro/pub/mirrors/ftp.perl.org/pub/CPAN/
1407 ftp://ftp.dntis.ro/pub/cpan/
1408 ftp://ftp.opsynet.com/cpan/
1409 ftp://ftp.dnttm.ro/pub/CPAN/
1410 ftp://ftp.timisoara.roedu.net/mirrors/CPAN/
1411
1412=item *
1413
1414Russia
1415
1416 ftp://ftp.chg.ru/pub/lang/perl/CPAN/
1417 http://cpan.rinet.ru/
1418 ftp://cpan.rinet.ru/pub/mirror/CPAN/
1419 ftp://ftp.aha.ru/pub/CPAN/
1420 ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
1421
1422=item *
1423
1424Slovakia
1425
1426 ftp://ftp.entry.sk/pub/languages/perl/CPAN/
1427
1428=item *
1429
1430Slovenia
1431
1432 ftp://ftp.arnes.si/software/perl/CPAN/
1433
1434=item *
1435
1436Spain
1437
1438 ftp://ftp.rediris.es/mirror/CPAN/
1439 ftp://ftp.etse.urv.es/pub/perl/
1440
1441=item *
1442
1443Sweden
1444
1445 http://ftp.du.se/CPAN/
1446 ftp://ftp.du.se/pub/CPAN/
1447 ftp://ftp.sunet.se/pub/lang/perl/CPAN/
1448
1449=item *
1450
1451Switzerland
1452
1453 ftp://ftp.danyk.ch/CPAN/
1454 ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
1455
1456=item *
1457
1458Turkey
1459
1460 ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/
1461
1462=back
1463
1464=head2 North America
1465
1466=over 4
1467
1468=item *
1469
1470Canada
1471
1472=over 8
1473
1474=item *
1475
1476Alberta
1477
1478 http://sunsite.ualberta.ca/pub/Mirror/CPAN/
1479 ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/
1480
1481=item *
1482
1483Manitoba
1484
1485 http://theoryx5.uwinnipeg.ca/pub/CPAN/
1486 ftp://theoryx5.uwinnipeg.ca/pub/CPAN/
1487
1488=item *
1489
1490Nova Scotia
1491
1492 ftp://cpan.chebucto.ns.ca/pub/CPAN/
1493
1494=item *
1495
1496Ontario
1497
1498 ftp://ftp.crc.ca/pub/packages/lang/perl/CPAN/
1499
1500=item *
1501
1502Mexico
1503
1504 http://www.msg.com.mx/CPAN/
1505 ftp://ftp.msg.com.mx/pub/CPAN/
1506
1507=back
1508
1509=item *
1510
1511United States
1512
1513=over 8
1514
1515=item *
1516
1517Alabama
1518
1519 http://mirror.hiwaay.net/CPAN/
1520 ftp://mirror.hiwaay.net/CPAN/
1521
1522=item *
1523
1524California
1525
1526 http://www.cpan.org/
1527 ftp://ftp.cpan.org/CPAN/
1528 ftp://cpan.nas.nasa.gov/pub/perl/CPAN/
1529 ftp://ftp.digital.com/pub/plan/perl/CPAN/
1530 http://www.kernel.org/pub/mirrors/cpan/
1531 ftp://ftp.kernel.org/pub/mirrors/cpan/
1532 http://www.perl.com/CPAN/
1533 http://download.sourceforge.net/mirrors/CPAN/
1534
1535=item *
1536
1537Colorado
1538
1539 ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
1540
1541=item *
1542
1543Florida
1544
1545 ftp://ftp.cise.ufl.edu/pub/perl/CPAN/
1546
1547=item *
1548
1549Georgia
1550
1551 ftp://ftp.twoguys.org/CPAN/
1552
1553=item *
1554
1555Illinois
1556
1557 http://www.neurogames.com/mirrors/CPAN
1558 http://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/
1559 ftp://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/
1560
1561=item *
1562
1563Indiana
1564
1565 ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/
1566 http://cpan.nitco.com/
1567 ftp://cpan.nitco.com/pub/CPAN/
1568 ftp://cpan.in-span.net/
1569 http://csociety-ftp.ecn.purdue.edu/pub/CPAN
1570 ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN
1571
1572=item *
1573
1574Kentucky
1575
1576 http://cpan.uky.edu/
1577 ftp://cpan.uky.edu/pub/CPAN/
1578
1579=item *
1580
1581Massachusetts
1582
1583 ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
1584 ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
1585
1586=item *
1587
1588New Jersey
1589
1590 ftp://ftp.cpanel.net/pub/CPAN/
1591
1592=item *
1593
1594New York
1595
1596 ftp://ftp.freesoftware.com/pub/perl/CPAN/
1597 http://www.deao.net/mirrors/CPAN/
1598 ftp://ftp.deao.net/pub/CPAN/
1599 ftp://ftp.stealth.net/pub/mirrors/ftp.cpan.org/pub/CPAN/
1600 http://mirror.nyc.anidea.com/CPAN/
1601 ftp://mirror.nyc.anidea.com/pub/CPAN/
1602 http://www.rge.com/pub/languages/perl/
1603 ftp://ftp.rge.com/pub/languages/perl/
1604 ftp://mirrors.cloud9.net/pub/mirrors/CPAN/
1605
1606=item *
1607
1608North Carolina
1609
1610 ftp://ftp.duke.edu/pub/perl/
1611
1612=item *
1613
1614Ohio
1615
1616 ftp://ftp.loaded.net/pub/CPAN/
1617
1618=item *
1619
1620Oklahoma
1621
1622 ftp://ftp.ou.edu/mirrors/CPAN/
1623
1624=item *
1625
1626Oregon
1627
1628 ftp://ftp.orst.edu/pub/packages/CPAN/
1629
1630=item *
1631
1632Pennsylvania
1633
1634 http://ftp.epix.net/CPAN/
1635 ftp://ftp.epix.net/pub/languages/perl/
1636 ftp://carroll.cac.psu.edu/pub/CPAN/
1637
1638=item *
1639
1640Tennessee
1641
1642 ftp://ftp.sunsite.utk.edu/pub/CPAN/
1643
1644=item *
1645
1646Texas
1647
1648 http://ftp.sedl.org/pub/mirrors/CPAN/
1649 http://jhcloos.com/pub/mirror/CPAN/
1650 ftp://jhcloos.com/pub/mirror/CPAN/
1651
1652=item *
1653
1654Utah
1655
1656 ftp://mirror.xmission.com/CPAN/
1657
1658=item *
1659
1660Virginia
1661
1662 http://mirrors.rcn.net/pub/lang/CPAN/
1663 ftp://mirrors.rcn.net/pub/lang/CPAN/
1664 ftp://ruff.cs.jmu.edu/pub/CPAN/
1665 http://perl.Liquidation.com/CPAN/
1666
1667=item *
1668
1669Washington
1670
1671 http://cpan.llarian.net/
1672 ftp://cpan.llarian.net/pub/CPAN/
1673 ftp://ftp-mirror.internap.com/pub/CPAN/
1674 ftp://ftp.spu.edu/pub/CPAN/
1675
1676=back
1677
1678=back
1679
1680=head2 Oceania
1681
1682=over 4
1683
1684=item *
1685
1686Australia
1687
1688 http://ftp.planetmirror.com/pub/CPAN/
1689 ftp://ftp.planetmirror.com/pub/CPAN/
1690 ftp://mirror.aarnet.edu.au/pub/perl/CPAN/
1691 ftp://cpan.topend.com.au/pub/CPAN/
1692
1693=item *
1694
1695New Zealand
1696
1697 ftp://ftp.auckland.ac.nz/pub/perl/CPAN/
1698
1699=back
1700
1701=head2 South America
1702
1703=over 4
1704
1705=item *
1706
1707Argentina
1708
1709 ftp://mirrors.bannerlandia.com.ar/mirrors/CPAN/
1710
1711=item *
1712
1713Brazil
1714
1715 ftp://cpan.pop-mg.com.br/pub/CPAN/
1716 ftp://ftp.matrix.com.br/pub/perl/
1717 ftp://cpan.if.usp.br/pub/mirror/CPAN/
1718
1719=item *
1720
1721Chile
1722
1723 ftp://ftp.psinet.cl/pub/programming/perl/CPAN/
1724 ftp://sunsite.dcc.uchile.cl/pub/lang/perl/
f102b883 1725
1726=back
1727
1728For an up-to-date listing of CPAN sites,
4e860d0a 1729see http://www.cpan.org/SITES or ftp://www.cpan.org/SITES .
f102b883 1730
1731=head1 Modules: Creation, Use, and Abuse
1732
1733(The following section is borrowed directly from Tim Bunce's modules
1734file, available at your nearest CPAN site.)
1735
1736Perl implements a class using a package, but the presence of a
1737package doesn't imply the presence of a class. A package is just a
1738namespace. A class is a package that provides subroutines that can be
1739used as methods. A method is just a subroutine that expects, as its
1740first argument, either the name of a package (for "static" methods),
1741or a reference to something (for "virtual" methods).
1742
1743A module is a file that (by convention) provides a class of the same
1744name (sans the .pm), plus an import method in that class that can be
1745called to fetch exported symbols. This module may implement some of
1746its methods by loading dynamic C or C++ objects, but that should be
1747totally transparent to the user of the module. Likewise, the module
1748might set up an AUTOLOAD function to slurp in subroutine definitions on
1749demand, but this is also transparent. Only the F<.pm> file is required to
2e1d04bc 1750exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about
f102b883 1751the AUTOLOAD mechanism.
1752
1753=head2 Guidelines for Module Creation
1754
1755=over 4
1756
4e860d0a 1757=item *
1758
1759Do similar modules already exist in some form?
f102b883 1760
1761If so, please try to reuse the existing modules either in whole or
1762by inheriting useful features into a new class. If this is not
1763practical try to get together with the module authors to work on
1764extending or enhancing the functionality of the existing modules.
1765A perfect example is the plethora of packages in perl4 for dealing
1766with command line options.
1767
1768If you are writing a module to expand an already existing set of
1769modules, please coordinate with the author of the package. It
1770helps if you follow the same naming scheme and module interaction
1771scheme as the original author.
1772
4e860d0a 1773=item *
1774
1775Try to design the new module to be easy to extend and reuse.
f102b883 1776
9f1b1f2d 1777Try to C<use warnings;> (or C<use warnings qw(...);>).
1778Remember that you can add C<no warnings qw(...);> to individual blocks
2e1d04bc 1779of code that need less warnings.
19799a22 1780
f102b883 1781Use blessed references. Use the two argument form of bless to bless
1782into the class name given as the first parameter of the constructor,
1783e.g.,:
1784
1785 sub new {
2e1d04bc 1786 my $class = shift;
1787 return bless {}, $class;
f102b883 1788 }
1789
1790or even this if you'd like it to be used as either a static
1791or a virtual method.
1792
1793 sub new {
2e1d04bc 1794 my $self = shift;
1795 my $class = ref($self) || $self;
1796 return bless {}, $class;
f102b883 1797 }
1798
1799Pass arrays as references so more parameters can be added later
1800(it's also faster). Convert functions into methods where
1801appropriate. Split large methods into smaller more flexible ones.
1802Inherit methods from other modules if appropriate.
1803
1804Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
19799a22 1805Generally you can delete the C<eq 'FOO'> part with no harm at all.
f102b883 1806Let the objects look after themselves! Generally, avoid hard-wired
1807class names as far as possible.
1808
c47ff5f1 1809Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and
1810C<< $r->func() >> would work (see L<perlbot> for more details).
f102b883 1811
1812Use autosplit so little used or newly added functions won't be a
5a964f20 1813burden to programs that don't use them. Add test functions to
f102b883 1814the module after __END__ either using AutoSplit or by saying:
1815
1816 eval join('',<main::DATA>) || die $@ unless caller();
1817
1818Does your module pass the 'empty subclass' test? If you say
19799a22 1819C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able
f102b883 1820to use SUBCLASS in exactly the same way as YOURCLASS. For example,
1821does your application still work if you change: C<$obj = new YOURCLASS;>
1822into: C<$obj = new SUBCLASS;> ?
1823
1824Avoid keeping any state information in your packages. It makes it
1825difficult for multiple other packages to use yours. Keep state
1826information in objects.
1827
2e1d04bc 1828Always use B<-w>.
19799a22 1829
1830Try to C<use strict;> (or C<use strict qw(...);>).
f102b883 1831Remember that you can add C<no strict qw(...);> to individual blocks
2e1d04bc 1832of code that need less strictness.
19799a22 1833
2e1d04bc 1834Always use B<-w>.
19799a22 1835
f102b883 1836Follow the guidelines in the perlstyle(1) manual.
1837
19799a22 1838Always use B<-w>.
1839
4e860d0a 1840=item *
1841
1842Some simple style guidelines
f102b883 1843
5a964f20 1844The perlstyle manual supplied with Perl has many helpful points.
f102b883 1845
1846Coding style is a matter of personal taste. Many people evolve their
1847style over several years as they learn what helps them write and
1848maintain good code. Here's one set of assorted suggestions that
1849seem to be widely used by experienced developers:
1850
1851Use underscores to separate words. It is generally easier to read
1852$var_names_like_this than $VarNamesLikeThis, especially for
1853non-native speakers of English. It's also a simple rule that works
1854consistently with VAR_NAMES_LIKE_THIS.
1855
1856Package/Module names are an exception to this rule. Perl informally
1857reserves lowercase module names for 'pragma' modules like integer
1858and strict. Other modules normally begin with a capital letter and
1859use mixed case with no underscores (need to be short and portable).
1860
1861You may find it helpful to use letter case to indicate the scope
1862or nature of a variable. For example:
1863
5a964f20 1864 $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
f102b883 1865 $Some_Caps_Here package-wide global/static
1866 $no_caps_here function scope my() or local() variables
1867
1868Function and method names seem to work best as all lowercase.
c47ff5f1 1869e.g., C<< $obj->as_string() >>.
f102b883 1870
1871You can use a leading underscore to indicate that a variable or
1872function should not be used outside the package that defined it.
1873
4e860d0a 1874=item *
1875
1876Select what to export.
f102b883 1877
1878Do NOT export method names!
1879
1880Do NOT export anything else by default without a good reason!
1881
1882Exports pollute the namespace of the module user. If you must
1883export try to use @EXPORT_OK in preference to @EXPORT and avoid
1884short or common names to reduce the risk of name clashes.
1885
1886Generally anything not exported is still accessible from outside the
c47ff5f1 1887module using the ModuleName::item_name (or C<< $blessed_ref->method >>)
f102b883 1888syntax. By convention you can use a leading underscore on names to
1889indicate informally that they are 'internal' and not for public use.
1890
1891(It is actually possible to get private functions by saying:
1892C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
1893directly as a method, because a method must have a name in the symbol
1894table.)
1895
1896As a general rule, if the module is trying to be object oriented
1897then export nothing. If it's just a collection of functions then
1898@EXPORT_OK anything but use @EXPORT with caution.
1899
4e860d0a 1900=item *
1901
1902Select a name for the module.
f102b883 1903
1904This name should be as descriptive, accurate, and complete as
1905possible. Avoid any risk of ambiguity. Always try to use two or
1906more whole words. Generally the name should reflect what is special
1907about what the module does rather than how it does it. Please use
1908nested module names to group informally or categorize a module.
1909There should be a very good reason for a module not to have a nested name.
1910Module names should begin with a capital letter.
1911
1912Having 57 modules all called Sort will not make life easy for anyone
1913(though having 23 called Sort::Quick is only marginally better :-).
1914Imagine someone trying to install your module alongside many others.
1915If in any doubt ask for suggestions in comp.lang.perl.misc.
1916
1917If you are developing a suite of related modules/classes it's good
1918practice to use nested classes with a common prefix as this will
1919avoid namespace clashes. For example: Xyz::Control, Xyz::View,
1920Xyz::Model etc. Use the modules in this list as a naming guide.
1921
1922If adding a new module to a set, follow the original author's
1923standards for naming modules and the interface to methods in
1924those modules.
1925
165c0277 1926If developing modules for private internal or project specific use,
1927that will never be released to the public, then you should ensure
1928that their names will not clash with any future public module. You
1929can do this either by using the reserved Local::* category or by
1930using a category name that includes an underscore like Foo_Corp::*.
1931
f102b883 1932To be portable each component of a module name should be limited to
193311 characters. If it might be used on MS-DOS then try to ensure each is
1934unique in the first 8 characters. Nested modules make this easier.
1935
4e860d0a 1936=item *
1937
1938Have you got it right?
f102b883 1939
1940How do you know that you've made the right decisions? Have you
1941picked an interface design that will cause problems later? Have
1942you picked the most appropriate name? Do you have any questions?
1943
1944The best way to know for sure, and pick up many helpful suggestions,
1945is to ask someone who knows. Comp.lang.perl.misc is read by just about
1946all the people who develop modules and it's the best place to ask.
1947
1948All you need to do is post a short summary of the module, its
1949purpose and interfaces. A few lines on each of the main methods is
1950probably enough. (If you post the whole module it might be ignored
1951by busy people - generally the very people you want to read it!)
1952
1953Don't worry about posting if you can't say when the module will be
1954ready - just say so in the message. It might be worth inviting
1955others to help you, they may be able to complete it for you!
1956
4e860d0a 1957=item *
1958
1959README and other Additional Files.
f102b883 1960
1961It's well known that software developers usually fully document the
1962software they write. If, however, the world is in urgent need of
1963your software and there is not enough time to write the full
1964documentation please at least provide a README file containing:
1965
1966=over 10
1967
1968=item *
4e860d0a 1969
f102b883 1970A description of the module/package/extension etc.
1971
1972=item *
4e860d0a 1973
f102b883 1974A copyright notice - see below.
1975
1976=item *
4e860d0a 1977
f102b883 1978Prerequisites - what else you may need to have.
1979
1980=item *
4e860d0a 1981
f102b883 1982How to build it - possible changes to Makefile.PL etc.
1983
1984=item *
4e860d0a 1985
f102b883 1986How to install it.
1987
1988=item *
4e860d0a 1989
f102b883 1990Recent changes in this release, especially incompatibilities
1991
1992=item *
4e860d0a 1993
f102b883 1994Changes / enhancements you plan to make in the future.
1995
1996=back
1997
1998If the README file seems to be getting too large you may wish to
1999split out some of the sections into separate files: INSTALL,
2000Copying, ToDo etc.
2001
2002=over 4
2003
2004=item Adding a Copyright Notice.
2005
4e860d0a 2006
f102b883 2007How you choose to license your work is a personal decision.
2008The general mechanism is to assert your Copyright and then make
2009a declaration of how others may copy/use/modify your work.
2010
2011Perl, for example, is supplied with two types of licence: The GNU
2012GPL and The Artistic Licence (see the files README, Copying, and
2013Artistic). Larry has good reasons for NOT just using the GNU GPL.
2014
2015My personal recommendation, out of respect for Larry, Perl, and the
5a964f20 2016Perl community at large is to state something simply like:
f102b883 2017
2018 Copyright (c) 1995 Your Name. All rights reserved.
2019 This program is free software; you can redistribute it and/or
2020 modify it under the same terms as Perl itself.
2021
2022This statement should at least appear in the README file. You may
2023also wish to include it in a Copying file and your source files.
2024Remember to include the other words in addition to the Copyright.
2025
4e860d0a 2026=item *
2027
2028Give the module a version/issue/release number.
f102b883 2029
2030To be fully compatible with the Exporter and MakeMaker modules you
2031should store your module's version number in a non-my package
2032variable called $VERSION. This should be a floating point
2033number with at least two digits after the decimal (i.e., hundredths,
2034e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.
19799a22 2035See L<Exporter> for details.
f102b883 2036
2037It may be handy to add a function or method to retrieve the number.
2038Use the number in announcements and archive file names when
2039releasing the module (ModuleName-1.02.tar.Z).
2040See perldoc ExtUtils::MakeMaker.pm for details.
2041
4e860d0a 2042=item *
2043
2044How to release and distribute a module.
f102b883 2045
2046It's good idea to post an announcement of the availability of your
2047module (or the module itself if small) to the comp.lang.perl.announce
2048Usenet newsgroup. This will at least ensure very wide once-off
2049distribution.
2050
2e1d04bc 2051If possible, register the module with CPAN. You should
f102b883 2052include details of its location in your announcement.
2053
2054Some notes about ftp archives: Please use a long descriptive file
5a964f20 2055name that includes the version number. Most incoming directories
f102b883 2056will not be readable/listable, i.e., you won't be able to see your
2057file after uploading it. Remember to send your email notification
2058message as soon as possible after uploading else your file may get
2059deleted automatically. Allow time for the file to be processed
2060and/or check the file has been processed before announcing its
2061location.
2062
2063FTP Archives for Perl Modules:
2064
6cecdcac 2065Follow the instructions and links on:
f102b883 2066
4e860d0a 2067 http://www.cpan.org/modules/00modlist.long.html
2068 http://www.cpan.org/modules/04pause.html
f102b883 2069
2070or upload to one of these sites:
2071
6cecdcac 2072 https://pause.kbx.de/pause/
2073 http://pause.perl.org/pause/
f102b883 2074
6cecdcac 2075and notify <modules@perl.org>.
f102b883 2076
2077By using the WWW interface you can ask the Upload Server to mirror
2078your modules from your ftp or WWW site into your own directory on
2079CPAN!
2080
2081Please remember to send me an updated entry for the Module list!
2082
4e860d0a 2083=item *
2084
2085Take care when changing a released module.
f102b883 2086
7b8d334a 2087Always strive to remain compatible with previous released versions.
2088Otherwise try to add a mechanism to revert to the
19799a22 2089old behavior if people rely on it. Document incompatible changes.
f102b883 2090
2091=back
2092
2093=back
2094
2095=head2 Guidelines for Converting Perl 4 Library Scripts into Modules
2096
2097=over 4
2098
4e860d0a 2099=item *
2100
2101There is no requirement to convert anything.
f102b883 2102
2103If it ain't broke, don't fix it! Perl 4 library scripts should
2104continue to work with no problems. You may need to make some minor
2105changes (like escaping non-array @'s in double quoted strings) but
2106there is no need to convert a .pl file into a Module for just that.
2107
4e860d0a 2108=item *
2109
2110Consider the implications.
f102b883 2111
5a964f20 2112All Perl applications that make use of the script will need to
f102b883 2113be changed (slightly) if the script is converted into a module. Is
2114it worth it unless you plan to make other changes at the same time?
2115
4e860d0a 2116=item *
2117
2118Make the most of the opportunity.
f102b883 2119
2120If you are going to convert the script to a module you can use the
19799a22 2121opportunity to redesign the interface. The guidelines for module
2122creation above include many of the issues you should consider.
f102b883 2123
4e860d0a 2124=item *
2125
2126The pl2pm utility will get you started.
f102b883 2127
2128This utility will read *.pl files (given as parameters) and write
2129corresponding *.pm files. The pl2pm utilities does the following:
2130
2131=over 10
2132
2133=item *
4e860d0a 2134
f102b883 2135Adds the standard Module prologue lines
2136
2137=item *
4e860d0a 2138
f102b883 2139Converts package specifiers from ' to ::
2140
2141=item *
4e860d0a 2142
f102b883 2143Converts die(...) to croak(...)
2144
2145=item *
4e860d0a 2146
f102b883 2147Several other minor changes
2148
2149=back
2150
2151Being a mechanical process pl2pm is not bullet proof. The converted
2152code will need careful checking, especially any package statements.
2153Don't delete the original .pl file till the new .pm one works!
2154
2155=back
2156
2157=head2 Guidelines for Reusing Application Code
2158
2159=over 4
2160
4e860d0a 2161=item *
551e1d92 2162
2163Complete applications rarely belong in the Perl Module Library.
f102b883 2164
4e860d0a 2165=item *
551e1d92 2166
2167Many applications contain some Perl code that could be reused.
f102b883 2168
2169Help save the world! Share your code in a form that makes it easy
2170to reuse.
2171
4e860d0a 2172=item *
551e1d92 2173
2174Break-out the reusable code into one or more separate module files.
f102b883 2175
4e860d0a 2176=item *
551e1d92 2177
2178Take the opportunity to reconsider and redesign the interfaces.
2179
4e860d0a 2180=item *
f102b883 2181
551e1d92 2182In some cases the 'application' can then be reduced to a small
f102b883 2183
2184fragment of code built on top of the reusable modules. In these cases
2185the application could invoked as:
2186
5a964f20 2187 % perl -e 'use Module::Name; method(@ARGV)' ...
f102b883 2188or
5a964f20 2189 % perl -mModule::Name ... (in perl5.002 or higher)
f102b883 2190
2191=back
2192
2193=head1 NOTE
2194
2195Perl does not enforce private and public parts of its modules as you may
2196have been used to in other languages like C++, Ada, or Modula-17. Perl
2197doesn't have an infatuation with enforced privacy. It would prefer
2198that you stayed out of its living room because you weren't invited, not
2199because it has a shotgun.
2200
2201The module and its user have a contract, part of which is common law,
2202and part of which is "written". Part of the common law contract is
2203that a module doesn't pollute any namespace it wasn't asked to. The
2204written contract for the module (A.K.A. documentation) may make other
2205provisions. But then you know when you C<use RedefineTheWorld> that
2206you're redefining the world and willing to take the consequences.