5 open (OUT, ">perlmodlib.tmp") or die $!;
6 my (@pragma, @mod, @MANIFEST);
7 open (MANIFEST, "../MANIFEST") or die $!;
11 next unless s|^lib/|| or m|^ext/|;
12 ($filename) = m|^(\S+)|;
13 $filename =~ s|^[^/]+/|| if $filename =~ s|^ext/||;
14 next unless $filename =~ m!\.p(m|od)$!;
15 next unless open (MOD, "../lib/$filename");
23 next unless /^=head1 NAME/;
29 warn "$filename missing =head1 NAME (okay if there is respective .pod)\n";
36 my $perlname = $filename;
37 $perlname =~ s!\.p(m|od)$!!;
38 $perlname =~ s!/!::!g;
40 ($name, $thing) = split / --? /, $title, 2;
42 unless ($name and $thing) {
43 warn "$filename missing name\n" unless $name;
44 warn "$filename missing thing\n" unless $thing;
49 $thing =~ s/^perl pragma to //i;
50 $thing = ucfirst($thing);
51 $title = "=item $perlname\n\n$thing\n\n";
53 if ($filename =~ /[A-Z]/) {
61 # Generated by perlmodlib.PL DO NOT EDIT!
65 perlmodlib - constructing new Perl modules and finding existing ones
69 =head1 THE PERL MODULE LIBRARY
71 Many modules are included the Perl distribution. These are described
72 below, and all end in F<.pm>. You may discover compiled library
73 file (usually ending in F<.so>) or small pieces of modules to be
74 autoloaded (ending in F<.al>); these were automatically generated
75 by the installation process. You may also discover files in the
76 library directory that end in either F<.pl> or F<.ph>. These are
77 old libraries supplied so that old programs that use them still
78 run. The F<.pl> files will all eventually be converted into standard
79 modules, and the F<.ph> files made by B<h2ph> will probably end up
80 as extension modules made by B<h2xs>. (Some F<.ph> values may
81 already be available through the POSIX, Errno, or Fcntl modules.)
82 The B<pl2pm> file in the distribution may help in your conversion,
83 but it's just a mechanical process and therefore far from bulletproof.
85 =head2 Pragmatic Modules
87 They work somewhat like compiler directives (pragmata) in that they
88 tend to affect the compilation of your program, and thus will usually
89 work well only when used within a C<use>, or C<no>. Most of these
90 are lexically scoped, so an inner BLOCK may countermand them
97 which lasts until the end of that BLOCK.
99 Some pragmas are lexically scoped--typically those that affect the
100 C<$^H> hints variable. Others affect the current package instead,
101 like C<use vars> and C<use subs>, which allow you to predeclare a
102 variables or subroutines within a particular I<file> rather than
103 just a block. Such declarations are effective for the entire file
104 for which they were declared. You cannot rescind them with C<no
107 The following pragmas are defined (and have their own documentation).
113 print OUT $_ for (sort @pragma);
118 =head2 Standard Modules
120 Standard, bundled modules are all expected to behave in a well-defined
121 manner with respect to namespace pollution because they use the
122 Exporter module. See their own documentation for details.
128 print OUT $_ for (sort @mod);
133 To find out I<all> modules installed on your system, including
134 those without documentation or outside the standard release,
137 % find `perl -e 'print "@INC"'` -name '*.pm' -print
139 They should all have their own documentation installed and accessible
140 via your system man(1) command. If you do not have a B<find>
141 program, you can use the Perl B<find2perl> program instead, which
142 generates Perl code as output you can run through perl. If you
143 have a B<man> program but it doesn't find your modules, you'll have
144 to fix your manpath. See L<perl> for details. If you have no
145 system B<man> command, you might try the B<perldoc> program.
147 =head2 Extension Modules
149 Extension modules are written in C (or a mix of Perl and C). They
150 are usually dynamically loaded into Perl if and when you need them,
151 but may also be linked in statically. Supported extension modules
152 include Socket, Fcntl, and POSIX.
154 Many popular C extension modules do not come bundled (at least, not
155 completely) due to their sizes, volatility, or simply lack of time
156 for adequate testing and configuration across the multitude of
157 platforms on which Perl was beta-tested. You are encouraged to
158 look for them on CPAN (described below), or using web search engines
159 like Alta Vista or Deja News.
163 CPAN stands for Comprehensive Perl Archive Network; it's a globally
164 replicated trove of Perl materials, including documentation, style
165 guides, tricks and traps, alternate ports to non-Unix systems and
166 occasional binary distributions for these. Search engines for
167 CPAN can be found at http://cpan.perl.com/ and at
168 http://theory.uwinnipeg.ca/mod_perl/cpan-search.pl .
170 Most importantly, CPAN includes around a thousand unbundled modules,
171 some of which require a C compiler to build. Major categories of
178 Language Extensions and Documentation Tools
186 Operating System Interfaces
190 Networking, Device Control (modems) and InterProcess Communication
194 Data Types and Data Type Utilities
206 Interfaces to / Emulations of Other Programming Languages
210 File Names, File Systems and File Locking (see also File Handles)
214 String Processing, Language Text Processing, Parsing, and Searching
218 Option, Argument, Parameter, and Configuration File Processing
222 Internationalization and Locale
226 Authentication, Security, and Encryption
230 World Wide Web, HTML, HTTP, CGI, MIME
234 Server and Daemon Utilities
238 Archiving and Compression
242 Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
250 Control Flow Utilities (callbacks and exceptions etc)
254 File Handle and Input/Output Stream Utilities
258 Miscellaneous Modules
262 Registered CPAN sites as of this writing include the following.
263 You should try to choose one close to you:
273 ftp://ftp.is.co.za/programming/perl/CPAN/
274 ftp://ftp.saix.net/pub/CPAN/
275 ftp://ftpza.co.za/pub/mirrors/cpan/
276 ftp://ftp.sun.ac.za/CPAN/
288 ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/
289 http://www2.linuxforum.net/mirror/CPAN/
290 http://cpan.shellhung.org/
291 ftp://ftp.shellhung.org/pub/CPAN
297 http://CPAN.pacific.net.hk/
298 ftp://ftp.pacific.net.hk/pub/mirror/CPAN/
304 http://piksi.itb.ac.id/CPAN/
305 ftp://mirrors.piksi.itb.ac.id/CPAN/
306 http://CPAN.mweb.co.id/
307 ftp://ftp.mweb.co.id/pub/languages/perl/CPAN/
313 http://www.iglu.org.il:/pub/CPAN/
314 ftp://ftp.iglu.org.il/pub/CPAN/
315 http://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
316 ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
322 ftp://ftp.u-aizu.ac.jp/pub/lang/perl/CPAN/
323 ftp://ftp.kddlabs.co.jp/CPAN/
324 http://mirror.nucba.ac.jp/mirror/Perl/
325 ftp://mirror.nucba.ac.jp/mirror/Perl/
326 ftp://ftp.meisei-u.ac.jp/pub/CPAN/
327 ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
328 ftp://ftp.dti.ad.jp/pub/lang/CPAN/
329 ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
335 ftp://ftp.isu.net.sa/pub/CPAN/
341 http://cpan.hjc.edu.sg
342 http://ftp.nus.edu.sg/unix/perl/CPAN/
343 ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/
349 http://CPAN.bora.net/
350 ftp://ftp.bora.net/pub/CPAN/
351 http://ftp.kornet.net/CPAN/
352 ftp://ftp.kornet.net/pub/CPAN/
353 ftp://ftp.nuri.net/pub/CPAN/
359 ftp://coda.nctu.edu.tw/UNIX/perl/CPAN
360 ftp://ftp.ee.ncku.edu.tw/pub/perl/CPAN/
361 ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/
367 http://download.nectec.or.th/CPAN/
368 ftp://ftp.nectec.or.th/pub/languages/CPAN/
369 ftp://ftp.cs.riubon.ac.th/pub/mirrors/CPAN/
373 =head2 Central America
381 ftp://ftp.linux.co.cr/mirrors/CPAN/
382 http://ftp.ucr.ac.cr/Unix/CPAN/
383 ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/
395 ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
401 http://ftp.easynet.be/CPAN/
402 ftp://ftp.easynet.be/CPAN/
403 ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
409 ftp://ftp.ntrl.net/pub/mirrors/CPAN/
415 ftp://ftp.linux.hr/pub/CPAN/
421 http://www.fi.muni.cz/pub/perl/
422 ftp://ftp.fi.muni.cz/pub/perl/
423 ftp://sunsite.mff.cuni.cz/MIRRORS/ftp.funet.fi/pub/languages/perl/CPAN/
429 ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
430 http://www.cpan.dk/CPAN/
431 ftp://www.cpan.dk/ftp.cpan.org/CPAN/
437 http://www.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN
438 ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/
439 ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
440 ftp://ftp.flirble.org/pub/languages/perl/CPAN/
441 ftp://ftp.plig.org/pub/CPAN/
442 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
443 http://mirror.uklinux.net/CPAN/
444 ftp://mirror.uklinux.net/pub/CPAN/
445 ftp://usit.shef.ac.uk/pub/packages/CPAN/
451 ftp://ftp.ut.ee/pub/languages/perl/CPAN/
457 ftp://ftp.funet.fi/pub/languages/perl/CPAN/
463 ftp://cpan.ftp.worldonline.fr/pub/CPAN/
464 ftp://ftp.club-internet.fr/pub/perl/CPAN/
465 ftp://ftp.lip6.fr/pub/perl/CPAN/
466 ftp://ftp.oleane.net/pub/mirrors/CPAN/
467 ftp://ftp.pasteur.fr/pub/computing/CPAN/
468 ftp://cpan.cict.fr/pub/CPAN/
469 ftp://ftp.uvsq.fr/pub/perl/CPAN/
475 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
476 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/CPAN/
477 ftp://ftp.uni-erlangen.de/pub/source/CPAN/
478 ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/CPAN
479 ftp://ftp.gigabell.net/pub/CPAN/
480 http://ftp.gwdg.de/pub/languages/perl/CPAN/
481 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
482 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
483 ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/
484 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
485 ftp://ftp.gmd.de/mirrors/CPAN/
491 ftp://ftp.forthnet.gr/pub/languages/perl/CPAN
492 ftp://ftp.ntua.gr/pub/lang/perl/
498 http://cpan.artifact.hu/
499 ftp://cpan.artifact.hu/CPAN/
500 ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
507 ftp://ftp.gm.is/pub/CPAN/
513 http://cpan.indigo.ie/
514 ftp://cpan.indigo.ie/pub/CPAN/
515 http://sunsite.compapp.dcu.ie/pub/perl/
516 ftp://sunsite.compapp.dcu.ie/pub/perl/
522 http://cpan.nettuno.it/
523 http://gusp.dyndns.org/CPAN/
524 ftp://gusp.dyndns.org/pub/CPAN
525 http://softcity.iol.it/cpan
526 ftp://softcity.iol.it/pub/cpan
527 ftp://ftp.unina.it/pub/Other/CPAN/
528 ftp://ftp.unipi.it/pub/mirror/perl/CPAN/
529 ftp://cis.uniRoma2.it/CPAN/
530 ftp://ftp.edisontel.it/pub/CPAN_Mirror/
531 ftp://ftp.flashnet.it/pub/CPAN/
537 http://kvin.lv/pub/CPAN/
543 ftp://download.xs4all.nl/pub/mirror/CPAN/
544 ftp://ftp.nl.uu.net/pub/CPAN/
545 ftp://ftp.nluug.nl/pub/languages/perl/CPAN/
546 ftp://ftp.cpan.nl/pub/CPAN/
547 http://www.cs.uu.nl/mirror/CPAN/
548 ftp://ftp.cs.uu.nl/mirror/CPAN/
554 ftp://sunsite.uio.no/pub/languages/perl/CPAN/
555 ftp://ftp.uit.no/pub/languages/perl/cpan/
561 ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
562 ftp://ftp.mega.net.pl/pub/mirrors/ftp.perl.com/
563 ftp://ftp.man.torun.pl/pub/doc/CPAN/
564 ftp://sunsite.icm.edu.pl/pub/CPAN/
570 ftp://ftp.ua.pt/pub/CPAN/
571 ftp://perl.di.uminho.pt/pub/CPAN/
572 ftp://ftp.ist.utl.pt/pub/CPAN/
573 ftp://ftp.netc.pt/pub/CPAN/
579 ftp://archive.logicnet.ro/mirrors/ftp.cpan.org/CPAN/
580 ftp://ftp.kappa.ro/pub/mirrors/ftp.perl.org/pub/CPAN/
581 ftp://ftp.dntis.ro/pub/cpan/
582 ftp://ftp.opsynet.com/cpan/
583 ftp://ftp.dnttm.ro/pub/CPAN/
584 ftp://ftp.timisoara.roedu.net/mirrors/CPAN/
590 ftp://ftp.chg.ru/pub/lang/perl/CPAN/
591 http://cpan.rinet.ru/
592 ftp://cpan.rinet.ru/pub/mirror/CPAN/
593 ftp://ftp.aha.ru/pub/CPAN/
594 ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
600 ftp://ftp.entry.sk/pub/languages/perl/CPAN/
606 ftp://ftp.arnes.si/software/perl/CPAN/
612 ftp://ftp.rediris.es/mirror/CPAN/
613 ftp://ftp.etse.urv.es/pub/perl/
619 http://ftp.du.se/CPAN/
620 ftp://ftp.du.se/pub/CPAN/
621 ftp://ftp.sunet.se/pub/lang/perl/CPAN/
627 ftp://ftp.danyk.ch/CPAN/
628 ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
634 ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/
652 http://sunsite.ualberta.ca/pub/Mirror/CPAN/
653 ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/
659 http://theoryx5.uwinnipeg.ca/pub/CPAN/
660 ftp://theoryx5.uwinnipeg.ca/pub/CPAN/
666 ftp://cpan.chebucto.ns.ca/pub/CPAN/
672 ftp://ftp.crc.ca/pub/packages/lang/perl/CPAN/
678 http://www.msg.com.mx/CPAN/
679 ftp://ftp.msg.com.mx/pub/CPAN/
693 http://mirror.hiwaay.net/CPAN/
694 ftp://mirror.hiwaay.net/CPAN/
701 ftp://ftp.cpan.org/CPAN/
702 ftp://cpan.nas.nasa.gov/pub/perl/CPAN/
703 ftp://ftp.digital.com/pub/plan/perl/CPAN/
704 http://www.kernel.org/pub/mirrors/cpan/
705 ftp://ftp.kernel.org/pub/mirrors/cpan/
706 http://www.perl.com/CPAN/
707 http://download.sourceforge.net/mirrors/CPAN/
713 ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
719 ftp://ftp.cise.ufl.edu/pub/perl/CPAN/
725 ftp://ftp.twoguys.org/CPAN/
731 http://www.neurogames.com/mirrors/CPAN
732 http://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/
733 ftp://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/
739 ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/
740 http://cpan.nitco.com/
741 ftp://cpan.nitco.com/pub/CPAN/
742 ftp://cpan.in-span.net/
743 http://csociety-ftp.ecn.purdue.edu/pub/CPAN
744 ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN
751 ftp://cpan.uky.edu/pub/CPAN/
757 ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
758 ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
764 ftp://ftp.cpanel.net/pub/CPAN/
770 ftp://ftp.freesoftware.com/pub/perl/CPAN/
771 http://www.deao.net/mirrors/CPAN/
772 ftp://ftp.deao.net/pub/CPAN/
773 ftp://ftp.stealth.net/pub/mirrors/ftp.cpan.org/pub/CPAN/
774 http://mirror.nyc.anidea.com/CPAN/
775 ftp://mirror.nyc.anidea.com/pub/CPAN/
776 http://www.rge.com/pub/languages/perl/
777 ftp://ftp.rge.com/pub/languages/perl/
778 ftp://mirrors.cloud9.net/pub/mirrors/CPAN/
784 ftp://ftp.duke.edu/pub/perl/
790 ftp://ftp.loaded.net/pub/CPAN/
796 ftp://ftp.ou.edu/mirrors/CPAN/
802 ftp://ftp.orst.edu/pub/packages/CPAN/
808 http://ftp.epix.net/CPAN/
809 ftp://ftp.epix.net/pub/languages/perl/
810 ftp://carroll.cac.psu.edu/pub/CPAN/
816 ftp://ftp.sunsite.utk.edu/pub/CPAN/
822 http://ftp.sedl.org/pub/mirrors/CPAN/
823 http://jhcloos.com/pub/mirror/CPAN/
824 ftp://jhcloos.com/pub/mirror/CPAN/
830 ftp://mirror.xmission.com/CPAN/
836 http://mirrors.rcn.net/pub/lang/CPAN/
837 ftp://mirrors.rcn.net/pub/lang/CPAN/
838 ftp://ruff.cs.jmu.edu/pub/CPAN/
839 http://perl.Liquidation.com/CPAN/
845 http://cpan.llarian.net/
846 ftp://cpan.llarian.net/pub/CPAN/
847 ftp://ftp-mirror.internap.com/pub/CPAN/
848 ftp://ftp.spu.edu/pub/CPAN/
862 http://ftp.planetmirror.com/pub/CPAN/
863 ftp://ftp.planetmirror.com/pub/CPAN/
864 ftp://mirror.aarnet.edu.au/pub/perl/CPAN/
865 ftp://cpan.topend.com.au/pub/CPAN/
871 ftp://ftp.auckland.ac.nz/pub/perl/CPAN/
883 ftp://mirrors.bannerlandia.com.ar/mirrors/CPAN/
889 ftp://cpan.pop-mg.com.br/pub/CPAN/
890 ftp://ftp.matrix.com.br/pub/perl/
891 ftp://cpan.if.usp.br/pub/mirror/CPAN/
897 ftp://ftp.psinet.cl/pub/programming/perl/CPAN/
898 ftp://sunsite.dcc.uchile.cl/pub/lang/perl/
902 For an up-to-date listing of CPAN sites,
903 see http://www.cpan.org/SITES or ftp://www.cpan.org/SITES .
905 =head1 Modules: Creation, Use, and Abuse
907 (The following section is borrowed directly from Tim Bunce's modules
908 file, available at your nearest CPAN site.)
910 Perl implements a class using a package, but the presence of a
911 package doesn't imply the presence of a class. A package is just a
912 namespace. A class is a package that provides subroutines that can be
913 used as methods. A method is just a subroutine that expects, as its
914 first argument, either the name of a package (for "static" methods),
915 or a reference to something (for "virtual" methods).
917 A module is a file that (by convention) provides a class of the same
918 name (sans the .pm), plus an import method in that class that can be
919 called to fetch exported symbols. This module may implement some of
920 its methods by loading dynamic C or C++ objects, but that should be
921 totally transparent to the user of the module. Likewise, the module
922 might set up an AUTOLOAD function to slurp in subroutine definitions on
923 demand, but this is also transparent. Only the F<.pm> file is required to
924 exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about
925 the AUTOLOAD mechanism.
927 =head2 Guidelines for Module Creation
933 Do similar modules already exist in some form?
935 If so, please try to reuse the existing modules either in whole or
936 by inheriting useful features into a new class. If this is not
937 practical try to get together with the module authors to work on
938 extending or enhancing the functionality of the existing modules.
939 A perfect example is the plethora of packages in perl4 for dealing
940 with command line options.
942 If you are writing a module to expand an already existing set of
943 modules, please coordinate with the author of the package. It
944 helps if you follow the same naming scheme and module interaction
945 scheme as the original author.
949 Try to design the new module to be easy to extend and reuse.
951 Try to C<use warnings;> (or C<use warnings qw(...);>).
952 Remember that you can add C<no warnings qw(...);> to individual blocks
953 of code that need less warnings.
955 Use blessed references. Use the two argument form of bless to bless
956 into the class name given as the first parameter of the constructor,
961 return bless {}, $class;
964 or even this if you'd like it to be used as either a static
969 my $class = ref($self) || $self;
970 return bless {}, $class;
973 Pass arrays as references so more parameters can be added later
974 (it's also faster). Convert functions into methods where
975 appropriate. Split large methods into smaller more flexible ones.
976 Inherit methods from other modules if appropriate.
978 Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
979 Generally you can delete the C<eq 'FOO'> part with no harm at all.
980 Let the objects look after themselves! Generally, avoid hard-wired
981 class names as far as possible.
983 Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and
984 C<< $r->func() >> would work (see L<perlbot> for more details).
986 Use autosplit so little used or newly added functions won't be a
987 burden to programs that don't use them. Add test functions to
988 the module after __END__ either using AutoSplit or by saying:
990 eval join('',<main::DATA>) || die $@ unless caller();
992 Does your module pass the 'empty subclass' test? If you say
993 C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able
994 to use SUBCLASS in exactly the same way as YOURCLASS. For example,
995 does your application still work if you change: C<$obj = new YOURCLASS;>
996 into: C<$obj = new SUBCLASS;> ?
998 Avoid keeping any state information in your packages. It makes it
999 difficult for multiple other packages to use yours. Keep state
1000 information in objects.
1004 Try to C<use strict;> (or C<use strict qw(...);>).
1005 Remember that you can add C<no strict qw(...);> to individual blocks
1006 of code that need less strictness.
1010 Follow the guidelines in the perlstyle(1) manual.
1016 Some simple style guidelines
1018 The perlstyle manual supplied with Perl has many helpful points.
1020 Coding style is a matter of personal taste. Many people evolve their
1021 style over several years as they learn what helps them write and
1022 maintain good code. Here's one set of assorted suggestions that
1023 seem to be widely used by experienced developers:
1025 Use underscores to separate words. It is generally easier to read
1026 $var_names_like_this than $VarNamesLikeThis, especially for
1027 non-native speakers of English. It's also a simple rule that works
1028 consistently with VAR_NAMES_LIKE_THIS.
1030 Package/Module names are an exception to this rule. Perl informally
1031 reserves lowercase module names for 'pragma' modules like integer
1032 and strict. Other modules normally begin with a capital letter and
1033 use mixed case with no underscores (need to be short and portable).
1035 You may find it helpful to use letter case to indicate the scope
1036 or nature of a variable. For example:
1038 $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
1039 $Some_Caps_Here package-wide global/static
1040 $no_caps_here function scope my() or local() variables
1042 Function and method names seem to work best as all lowercase.
1043 e.g., C<< $obj->as_string() >>.
1045 You can use a leading underscore to indicate that a variable or
1046 function should not be used outside the package that defined it.
1050 Select what to export.
1052 Do NOT export method names!
1054 Do NOT export anything else by default without a good reason!
1056 Exports pollute the namespace of the module user. If you must
1057 export try to use @EXPORT_OK in preference to @EXPORT and avoid
1058 short or common names to reduce the risk of name clashes.
1060 Generally anything not exported is still accessible from outside the
1061 module using the ModuleName::item_name (or C<< $blessed_ref->method >>)
1062 syntax. By convention you can use a leading underscore on names to
1063 indicate informally that they are 'internal' and not for public use.
1065 (It is actually possible to get private functions by saying:
1066 C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
1067 directly as a method, because a method must have a name in the symbol
1070 As a general rule, if the module is trying to be object oriented
1071 then export nothing. If it's just a collection of functions then
1072 @EXPORT_OK anything but use @EXPORT with caution.
1076 Select a name for the module.
1078 This name should be as descriptive, accurate, and complete as
1079 possible. Avoid any risk of ambiguity. Always try to use two or
1080 more whole words. Generally the name should reflect what is special
1081 about what the module does rather than how it does it. Please use
1082 nested module names to group informally or categorize a module.
1083 There should be a very good reason for a module not to have a nested name.
1084 Module names should begin with a capital letter.
1086 Having 57 modules all called Sort will not make life easy for anyone
1087 (though having 23 called Sort::Quick is only marginally better :-).
1088 Imagine someone trying to install your module alongside many others.
1089 If in any doubt ask for suggestions in comp.lang.perl.misc.
1091 If you are developing a suite of related modules/classes it's good
1092 practice to use nested classes with a common prefix as this will
1093 avoid namespace clashes. For example: Xyz::Control, Xyz::View,
1094 Xyz::Model etc. Use the modules in this list as a naming guide.
1096 If adding a new module to a set, follow the original author's
1097 standards for naming modules and the interface to methods in
1100 If developing modules for private internal or project specific use,
1101 that will never be released to the public, then you should ensure
1102 that their names will not clash with any future public module. You
1103 can do this either by using the reserved Local::* category or by
1104 using a category name that includes an underscore like Foo_Corp::*.
1106 To be portable each component of a module name should be limited to
1107 11 characters. If it might be used on MS-DOS then try to ensure each is
1108 unique in the first 8 characters. Nested modules make this easier.
1112 Have you got it right?
1114 How do you know that you've made the right decisions? Have you
1115 picked an interface design that will cause problems later? Have
1116 you picked the most appropriate name? Do you have any questions?
1118 The best way to know for sure, and pick up many helpful suggestions,
1119 is to ask someone who knows. Comp.lang.perl.misc is read by just about
1120 all the people who develop modules and it's the best place to ask.
1122 All you need to do is post a short summary of the module, its
1123 purpose and interfaces. A few lines on each of the main methods is
1124 probably enough. (If you post the whole module it might be ignored
1125 by busy people - generally the very people you want to read it!)
1127 Don't worry about posting if you can't say when the module will be
1128 ready - just say so in the message. It might be worth inviting
1129 others to help you, they may be able to complete it for you!
1133 README and other Additional Files.
1135 It's well known that software developers usually fully document the
1136 software they write. If, however, the world is in urgent need of
1137 your software and there is not enough time to write the full
1138 documentation please at least provide a README file containing:
1144 A description of the module/package/extension etc.
1148 A copyright notice - see below.
1152 Prerequisites - what else you may need to have.
1156 How to build it - possible changes to Makefile.PL etc.
1164 Recent changes in this release, especially incompatibilities
1168 Changes / enhancements you plan to make in the future.
1172 If the README file seems to be getting too large you may wish to
1173 split out some of the sections into separate files: INSTALL,
1178 =item Adding a Copyright Notice.
1181 How you choose to license your work is a personal decision.
1182 The general mechanism is to assert your Copyright and then make
1183 a declaration of how others may copy/use/modify your work.
1185 Perl, for example, is supplied with two types of licence: The GNU
1186 GPL and The Artistic Licence (see the files README, Copying, and
1187 Artistic). Larry has good reasons for NOT just using the GNU GPL.
1189 My personal recommendation, out of respect for Larry, Perl, and the
1190 Perl community at large is to state something simply like:
1192 Copyright (c) 1995 Your Name. All rights reserved.
1193 This program is free software; you can redistribute it and/or
1194 modify it under the same terms as Perl itself.
1196 This statement should at least appear in the README file. You may
1197 also wish to include it in a Copying file and your source files.
1198 Remember to include the other words in addition to the Copyright.
1202 Give the module a version/issue/release number.
1204 To be fully compatible with the Exporter and MakeMaker modules you
1205 should store your module's version number in a non-my package
1206 variable called $VERSION. This should be a floating point
1207 number with at least two digits after the decimal (i.e., hundredths,
1208 e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.
1209 See L<Exporter> for details.
1211 It may be handy to add a function or method to retrieve the number.
1212 Use the number in announcements and archive file names when
1213 releasing the module (ModuleName-1.02.tar.Z).
1214 See perldoc ExtUtils::MakeMaker.pm for details.
1218 How to release and distribute a module.
1220 It's good idea to post an announcement of the availability of your
1221 module (or the module itself if small) to the comp.lang.perl.announce
1222 Usenet newsgroup. This will at least ensure very wide once-off
1225 If possible, register the module with CPAN. You should
1226 include details of its location in your announcement.
1228 Some notes about ftp archives: Please use a long descriptive file
1229 name that includes the version number. Most incoming directories
1230 will not be readable/listable, i.e., you won't be able to see your
1231 file after uploading it. Remember to send your email notification
1232 message as soon as possible after uploading else your file may get
1233 deleted automatically. Allow time for the file to be processed
1234 and/or check the file has been processed before announcing its
1237 FTP Archives for Perl Modules:
1239 Follow the instructions and links on:
1241 http://www.cpan.org/modules/00modlist.long.html
1242 http://www.cpan.org/modules/04pause.html
1244 or upload to one of these sites:
1246 https://pause.kbx.de/pause/
1247 http://pause.perl.org/pause/
1249 and notify <modules@perl.org>.
1251 By using the WWW interface you can ask the Upload Server to mirror
1252 your modules from your ftp or WWW site into your own directory on
1255 Please remember to send me an updated entry for the Module list!
1259 Take care when changing a released module.
1261 Always strive to remain compatible with previous released versions.
1262 Otherwise try to add a mechanism to revert to the
1263 old behavior if people rely on it. Document incompatible changes.
1269 =head2 Guidelines for Converting Perl 4 Library Scripts into Modules
1275 There is no requirement to convert anything.
1277 If it ain't broke, don't fix it! Perl 4 library scripts should
1278 continue to work with no problems. You may need to make some minor
1279 changes (like escaping non-array @'s in double quoted strings) but
1280 there is no need to convert a .pl file into a Module for just that.
1284 Consider the implications.
1286 All Perl applications that make use of the script will need to
1287 be changed (slightly) if the script is converted into a module. Is
1288 it worth it unless you plan to make other changes at the same time?
1292 Make the most of the opportunity.
1294 If you are going to convert the script to a module you can use the
1295 opportunity to redesign the interface. The guidelines for module
1296 creation above include many of the issues you should consider.
1300 The pl2pm utility will get you started.
1302 This utility will read *.pl files (given as parameters) and write
1303 corresponding *.pm files. The pl2pm utilities does the following:
1309 Adds the standard Module prologue lines
1313 Converts package specifiers from ' to ::
1317 Converts die(...) to croak(...)
1321 Several other minor changes
1325 Being a mechanical process pl2pm is not bullet proof. The converted
1326 code will need careful checking, especially any package statements.
1327 Don't delete the original .pl file till the new .pm one works!
1331 =head2 Guidelines for Reusing Application Code
1337 Complete applications rarely belong in the Perl Module Library.
1341 Many applications contain some Perl code that could be reused.
1343 Help save the world! Share your code in a form that makes it easy
1348 Break-out the reusable code into one or more separate module files.
1352 Take the opportunity to reconsider and redesign the interfaces.
1356 In some cases the 'application' can then be reduced to a small
1358 fragment of code built on top of the reusable modules. In these cases
1359 the application could invoked as:
1361 % perl -e 'use Module::Name; method(@ARGV)' ...
1363 % perl -mModule::Name ... (in perl5.002 or higher)
1369 Perl does not enforce private and public parts of its modules as you may
1370 have been used to in other languages like C++, Ada, or Modula-17. Perl
1371 doesn't have an infatuation with enforced privacy. It would prefer
1372 that you stayed out of its living room because you weren't invited, not
1373 because it has a shotgun.
1375 The module and its user have a contract, part of which is common law,
1376 and part of which is "written". Part of the common law contract is
1377 that a module doesn't pollute any namespace it wasn't asked to. The
1378 written contract for the module (A.K.A. documentation) may make other
1379 provisions. But then you know when you C<use RedefineTheWorld> that
1380 you're redefining the world and willing to take the consequences.
1383 close MANIFEST or warn "$0: failed to close MANIFEST (../MANIFEST): $!";
1384 close OUT or warn "$0: failed to close OUT (perlmodlib.tmp): $!";