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