3 perlmodlib - constructing new Perl modules and finding existing ones
7 =head1 THE PERL MODULE LIBRARY
9 A number of modules are included the Perl distribution. These are
10 described below, and all end in F<.pm>. You may also discover files in
11 the library directory that end in either F<.pl> or F<.ph>. These are old
12 libraries supplied so that old programs that use them still run. The
13 F<.pl> files will all eventually be converted into standard modules, and
14 the F<.ph> files made by B<h2ph> will probably end up as extension modules
15 made by B<h2xs>. (Some F<.ph> values may already be available through the
16 POSIX module.) The B<pl2pm> file in the distribution may help in your
17 conversion, but it's just a mechanical process and therefore far from
20 =head2 Pragmatic Modules
22 They work somewhat like pragmas in that they tend to affect the compilation of
23 your program, and thus will usually work well only when used within a
24 C<use>, or C<no>. Most of these are lexically scoped, so an inner BLOCK
25 may countermand any of these by saying:
30 which lasts until the end of that BLOCK.
32 Unlike the pragmas that effect the C<$^H> hints variable, the C<use
33 vars> and C<use subs> declarations are not BLOCK-scoped. They allow
34 you to predeclare a variables or subroutines within a particular
35 I<file> rather than just a block. Such declarations are effective
36 for the entire file for which they were declared. You cannot rescind
37 them with C<no vars> or C<no subs>.
39 The following pragmas are defined (and have their own documentation).
43 =item use autouse MODULE => qw(sub1 sub2 sub3)
45 Defers C<require MODULE> until someone calls one of the specified
46 subroutines (which must be exported by MODULE). This pragma should be
47 used with caution, and only when necessary.
51 manipulate @INC at compile time to use MakeMaker's uninstalled version
56 force verbose warning diagnostics
60 compute arithmetic in integer instead of double
64 request less of something from the compiler
68 manipulate @INC at compile time
72 use or ignore current locale for builtin operations (see L<perllocale>)
76 restrict named opcodes when compiling or running Perl code
80 overload basic Perl operations
84 alter behaviour of regular expressions
88 enable simple signal handling
92 restrict unsafe constructs
100 adopt certain VMS-specific behaviors
104 predeclare global variable names
108 =head2 Standard Modules
110 Standard, bundled modules are all expected to behave in a well-defined
111 manner with respect to namespace pollution because they use the
112 Exporter module. See their own documentation for details.
118 provide framework for multiple DBMs
122 load functions only on demand
126 split a package for autoloading
130 benchmark running times of code
134 interface to Comprehensive Perl Archive Network
136 =item CPAN::FirstTime
138 create a CPAN configuration file
142 run CPAN while avoiding compiled extensions
146 warn of errors (from perspective of caller)
150 declare struct-like datatypes
154 access Perl configuration information
158 get pathname of current working directory
162 access to Berkeley DB
164 =item Devel::SelfStubber
166 generate stubs for a SelfLoading module
170 supply object methods for directory handles
174 dynamically load C libraries into Perl code
178 use nice English (or awk) names for ugly punctuation variables
182 import environment variables
186 implements default import method for modules
188 =item ExtUtils::Embed
190 utilities for embedding Perl in C/C++ applications
192 =item ExtUtils::Install
194 install files from here to there
196 =item ExtUtils::Liblist
198 determine libraries to use and how to use them
200 =item ExtUtils::MM_OS2
202 methods to override Unix behaviour in ExtUtils::MakeMaker
204 =item ExtUtils::MM_Unix
206 methods used by ExtUtils::MakeMaker
208 =item ExtUtils::MM_VMS
210 methods to override Unix behaviour in ExtUtils::MakeMaker
212 =item ExtUtils::MakeMaker
214 create an extension Makefile
216 =item ExtUtils::Manifest
218 utilities to write and check a MANIFEST file
220 =item ExtUtils::Mkbootstrap
222 make a bootstrap file for use by DynaLoader
224 =item ExtUtils::Mksymlists
226 write linker options files for dynamic extension
228 =item ExtUtils::testlib
230 add blib/* directories to @INC
234 make errors in builtins or Perl functions fatal
238 load the C Fcntl.h defines
242 split a pathname into pieces
244 =item File::CheckTree
246 run many filetest checks on a tree
250 compare files or filehandles
254 copy files or filehandles
262 create or remove a series of directories
266 by-name interface to Perl's builtin stat() functions
270 keep more files open than the system permits
274 supply object methods for filehandles
278 locate directory of original Perl script
282 access to the gdbm library
286 extended processing of command line options
290 process single-character switches with switch clustering
294 compare 8-bit scalar data according to the current locale
298 load various IO modules
302 supply object methods for filehandles
306 supply object methods for I/O handles
310 supply object methods for pipes
314 supply seek based methods for I/O objects
318 OO interface to the select system call
322 object interface to socket communications
326 open a process for both reading and writing
330 open a process for reading, writing, and error handling
334 arbitrary length float math package
338 arbitrary size integer math package
342 complex numbers and associated mathematical functions
346 simple interface to parts of Math::Complex for those who
347 need trigonometric functions only for real numbers
351 tied access to ndbm files
359 by-name interface to Perl's builtin gethost*() functions
363 by-name interface to Perl's builtin getnet*() functions
367 by-name interface to Perl's builtin getproto*() functions
371 by-name interface to Perl's builtin getserv*() functions
375 disable named opcodes when compiling or running Perl code
379 convert POD data to formatted ASCII text
383 interface to IEEE Standard 1003.1
387 tied access to sdbm files
391 compile and execute code in restricted compartments
395 search for key in dictionary file
399 save and restore selected file handle
403 load functions only on demand
407 run shell commands transparently within Perl
411 load the C socket.h defines and structure manipulators
415 manipulate Perl symbols and their names
419 try every conceivable way to get hostname
423 interface to the Unix syslog(3) calls
431 word completion module
435 interface to various C<readline> packages
439 run Perl standard test scripts with statistics
443 create an abbreviation table from a list
445 =item Text::ParseWords
447 parse text into an array of tokens
451 implementation of the Soundex Algorithm as described by Knuth
455 expand and unexpand tabs per the Unix expand(1) and unexpand(1)
459 line wrapping to form simple paragraphs
463 base class definitions for tied hashes
467 base class definitions for tied hashes with references as keys
471 base class definitions for tied scalars
473 =item Tie::SubstrHash
475 fixed-table-size, fixed-key-length hashing
479 efficiently compute time from local and GMT time
483 by-name interface to Perl's builtin gmtime() function
485 =item Time::localtime
487 by-name interface to Perl's builtin localtime() function
491 internal object used by Time::gmtime and Time::localtime
495 base class for ALL classes (blessed references)
499 by-name interface to Perl's builtin getgr*() functions
503 by-name interface to Perl's builtin getpw*() functions
507 To find out I<all> the modules installed on your system, including
508 those without documentation or outside the standard release, do this:
510 % find `perl -e 'print "@INC"'` -name '*.pm' -print
512 They should all have their own documentation installed and accessible via
513 your system man(1) command. If that fails, try the I<perldoc> program.
515 =head2 Extension Modules
517 Extension modules are written in C (or a mix of Perl and C) and may be
518 statically linked or in general are
519 dynamically loaded into Perl if and when you need them. Supported
520 extension modules include the Socket, Fcntl, and POSIX modules.
522 Many popular C extension modules do not come bundled (at least, not
523 completely) due to their sizes, volatility, or simply lack of time for
524 adequate testing and configuration across the multitude of platforms on
525 which Perl was beta-tested. You are encouraged to look for them in
526 archie(1L), the Perl FAQ or Meta-FAQ, the WWW page, and even with their
527 authors before randomly posting asking for their present condition and
532 CPAN stands for the Comprehensive Perl Archive Network. This is a globally
533 replicated collection of all known Perl materials, including hundreds
534 of unbundled modules. Here are the major categories of modules:
539 Language Extensions and Documentation Tools
545 Operating System Interfaces
548 Networking, Device Control (modems) and InterProcess Communication
551 Data Types and Data Type Utilities
560 Interfaces to / Emulations of Other Programming Languages
563 File Names, File Systems and File Locking (see also File Handles)
566 String Processing, Language Text Processing, Parsing, and Searching
569 Option, Argument, Parameter, and Configuration File Processing
572 Internationalization and Locale
575 Authentication, Security, and Encryption
578 World Wide Web, HTML, HTTP, CGI, MIME
581 Server and Daemon Utilities
584 Archiving and Compression
587 Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
593 Control Flow Utilities (callbacks and exceptions etc)
596 File Handle and Input/Output Stream Utilities
599 Miscellaneous Modules
603 The registered CPAN sites as of this writing include the following.
604 You should try to choose one close to you:
611 South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
612 ftp://ftpza.co.za/pub/mirrors/cpan/
617 Armenia ftp://sunsite.aua.am/pub/CPAN/
618 China ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/
619 Hong Kong ftp://ftp.hkstar.com/pub/CPAN/
620 Israel ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
621 Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
622 ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
623 ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
624 ftp://ftp.meisei-u.ac.jp/pub/CPAN/
625 ftp://mirror.nucba.ac.jp/mirror/Perl/
626 Singapore ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/
627 South Korea ftp://ftp.bora.net/pub/CPAN/
628 ftp://ftp.nuri.net/pub/CPAN/
629 Taiwan ftp://ftp.wownet.net/pub2/PERL/
630 ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/
631 Thailand ftp://ftp.cs.riubon.ac.th/pub/mirrors/CPAN/
632 ftp://ftp.nectec.or.th/pub/mirrors/CPAN/
637 Australia ftp://cpan.topend.com.au/pub/CPAN/
638 ftp://ftp.labyrinth.net.au/pub/perl/CPAN/
639 ftp://ftp.sage-au.org.au/pub/compilers/perl/CPAN/
640 ftp://mirror.aarnet.edu.au/pub/perl/CPAN/
641 New Zealand ftp://ftp.auckland.ac.nz/pub/perl/CPAN/
642 ftp://sunsite.net.nz/pub/languages/perl/CPAN/
647 Costa Rica ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/
652 Austria ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
653 Belgium ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
654 Bulgaria ftp://ftp.ntrl.net/pub/mirrors/CPAN/
655 Croatia ftp://ftp.linux.hr/pub/CPAN/
656 Czech Republic ftp://ftp.fi.muni.cz/pub/perl/
657 ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/
658 Denmark ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
659 Estonia ftp://ftp.ut.ee/pub/languages/perl/CPAN/
660 Finland ftp://ftp.funet.fi/pub/languages/perl/CPAN/
661 France ftp://ftp.lip6.fr/pub/perl/CPAN/
662 ftp://ftp.oleane.net/pub/mirrors/CPAN/
663 ftp://ftp.pasteur.fr/pub/computing/CPAN/
664 Germany ftp://ftp.archive.de.uu.net/pub/CPAN/
665 ftp://ftp.gmd.de/packages/CPAN/
666 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
667 ftp://ftp.leo.org/pub/comp/programming/languages/script/perl/CPAN/
668 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
669 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
670 ftp://ftp.uni-erlangen.de/pub/source/CPAN/
671 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
672 Greece ftp://ftp.ntua.gr/pub/lang/perl/
673 Hungary ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
674 Ireland ftp://sunsite.compapp.dcu.ie/pub/perl/
675 Italy ftp://cis.uniRoma2.it/CPAN/
676 ftp://ftp.flashnet.it/pub/CPAN/
677 ftp://ftp.unipi.it/pub/mirror/perl/CPAN/
678 Netherlands ftp://ftp.cs.uu.nl/mirror/CPAN/
679 ftp://ftp.nluug.nl/pub/languages/perl/CPAN/
680 Norway ftp://ftp.uit.no/pub/languages/perl/cpan/
681 ftp://sunsite.uio.no/pub/languages/perl/CPAN/
682 Poland ftp://ftp.man.szczecin.pl/pub/perl/CPAN/
683 ftp://ftp.man.torun.pl/pub/doc/CPAN/
684 ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
685 ftp://sunsite.icm.edu.pl/pub/CPAN/
686 Portugal ftp://ftp.ci.uminho.pt/pub/mirrors/cpan/
687 ftp://ftp.ua.pt/pub/CPAN/
688 Romania ftp://ftp.dntis.ro/pub/mirrors/perl-cpan/
689 ftp://ftp.dnttm.ro/pub/CPAN/
690 Russia ftp://cpan.npi.msu.su/CPAN/
691 ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
692 Slovakia ftp://ftp.entry.sk/pub/languages/perl/CPAN/
693 Slovenia ftp://ftp.arnes.si/software/perl/CPAN/
694 Spain ftp://ftp.etse.urv.es/pub/perl/
695 ftp://ftp.rediris.es/mirror/CPAN/
696 Sweden ftp://ftp.sunet.se/pub/lang/perl/CPAN/
697 Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
698 Turkey ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/
699 United Kingdom ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
700 ftp://ftp.flirble.org/pub/languages/perl/CPAN/
701 ftp://ftp.plig.org/pub/CPAN/
702 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
703 ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/
708 Alberta ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/
709 California ftp://ftp.cdrom.com/pub/perl/CPAN/
710 ftp://ftp.digital.com/pub/plan/perl/CPAN/
711 Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
712 Florida ftp://ftp.cise.ufl.edu/pub/perl/CPAN/
713 Illinois ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/
714 Indiana ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN/
715 ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/
716 Manitoba ftp://theory.uwinnipeg.ca/pub/CPAN/
717 Massachusetts ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
718 ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
719 Mexico D.F. ftp://ftp.msg.com.mx/pub/CPAN/
720 New York ftp://ftp.rge.com/pub/languages/perl/
721 North Carolina ftp://ftp.duke.edu/pub/perl/
722 Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/
723 Ontario ftp://ftp.crc.ca/pub/packages/perl/CPAN/
724 Oregon ftp://ftp.orst.edu/pub/packages/CPAN/
725 Pennsylvania ftp://ftp.epix.net/pub/languages/perl/
726 Texas ftp://ftp.sedl.org/pub/mirrors/CPAN/
727 Utah ftp://mirror.xmission.com/CPAN/
728 Virginia ftp://ftp.perl.org/pub/perl/CPAN/
729 ftp://ruff.cs.jmu.edu/pub/CPAN/
730 Washington ftp://ftp.spu.edu/pub/CPAN/
735 Brazil ftp://cpan.if.usp.br/pub/mirror/CPAN/
736 Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
737 ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/
741 For an up-to-date listing of CPAN sites,
742 see F<http://www.perl.com/perl/CPAN> or F<ftp://ftp.perl.com/perl/>.
744 =head1 Modules: Creation, Use, and Abuse
746 (The following section is borrowed directly from Tim Bunce's modules
747 file, available at your nearest CPAN site.)
749 Perl implements a class using a package, but the presence of a
750 package doesn't imply the presence of a class. A package is just a
751 namespace. A class is a package that provides subroutines that can be
752 used as methods. A method is just a subroutine that expects, as its
753 first argument, either the name of a package (for "static" methods),
754 or a reference to something (for "virtual" methods).
756 A module is a file that (by convention) provides a class of the same
757 name (sans the .pm), plus an import method in that class that can be
758 called to fetch exported symbols. This module may implement some of
759 its methods by loading dynamic C or C++ objects, but that should be
760 totally transparent to the user of the module. Likewise, the module
761 might set up an AUTOLOAD function to slurp in subroutine definitions on
762 demand, but this is also transparent. Only the F<.pm> file is required to
763 exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about
764 the AUTOLOAD mechanism.
766 =head2 Guidelines for Module Creation
770 =item Do similar modules already exist in some form?
772 If so, please try to reuse the existing modules either in whole or
773 by inheriting useful features into a new class. If this is not
774 practical try to get together with the module authors to work on
775 extending or enhancing the functionality of the existing modules.
776 A perfect example is the plethora of packages in perl4 for dealing
777 with command line options.
779 If you are writing a module to expand an already existing set of
780 modules, please coordinate with the author of the package. It
781 helps if you follow the same naming scheme and module interaction
782 scheme as the original author.
784 =item Try to design the new module to be easy to extend and reuse.
786 Use blessed references. Use the two argument form of bless to bless
787 into the class name given as the first parameter of the constructor,
792 return bless {}, $class;
795 or even this if you'd like it to be used as either a static
800 my $class = ref($self) || $self;
801 return bless {}, $class;
804 Pass arrays as references so more parameters can be added later
805 (it's also faster). Convert functions into methods where
806 appropriate. Split large methods into smaller more flexible ones.
807 Inherit methods from other modules if appropriate.
809 Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
810 Generally you can delete the "C<eq 'FOO'>" part with no harm at all.
811 Let the objects look after themselves! Generally, avoid hard-wired
812 class names as far as possible.
814 Avoid C<$r-E<gt>Class::func()> where using C<@ISA=qw(... Class ...)> and
815 C<$r-E<gt>func()> would work (see L<perlbot> for more details).
817 Use autosplit so little used or newly added functions won't be a
818 burden to programs that don't use them. Add test functions to
819 the module after __END__ either using AutoSplit or by saying:
821 eval join('',<main::DATA>) || die $@ unless caller();
823 Does your module pass the 'empty subclass' test? If you say
824 "C<@SUBCLASS::ISA = qw(YOURCLASS);>" your applications should be able
825 to use SUBCLASS in exactly the same way as YOURCLASS. For example,
826 does your application still work if you change: C<$obj = new YOURCLASS;>
827 into: C<$obj = new SUBCLASS;> ?
829 Avoid keeping any state information in your packages. It makes it
830 difficult for multiple other packages to use yours. Keep state
831 information in objects.
833 Always use B<-w>. Try to C<use strict;> (or C<use strict qw(...);>).
834 Remember that you can add C<no strict qw(...);> to individual blocks
835 of code that need less strictness. Always use B<-w>. Always use B<-w>!
836 Follow the guidelines in the perlstyle(1) manual.
838 =item Some simple style guidelines
840 The perlstyle manual supplied with Perl has many helpful points.
842 Coding style is a matter of personal taste. Many people evolve their
843 style over several years as they learn what helps them write and
844 maintain good code. Here's one set of assorted suggestions that
845 seem to be widely used by experienced developers:
847 Use underscores to separate words. It is generally easier to read
848 $var_names_like_this than $VarNamesLikeThis, especially for
849 non-native speakers of English. It's also a simple rule that works
850 consistently with VAR_NAMES_LIKE_THIS.
852 Package/Module names are an exception to this rule. Perl informally
853 reserves lowercase module names for 'pragma' modules like integer
854 and strict. Other modules normally begin with a capital letter and
855 use mixed case with no underscores (need to be short and portable).
857 You may find it helpful to use letter case to indicate the scope
858 or nature of a variable. For example:
860 $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
861 $Some_Caps_Here package-wide global/static
862 $no_caps_here function scope my() or local() variables
864 Function and method names seem to work best as all lowercase.
865 e.g., C<$obj-E<gt>as_string()>.
867 You can use a leading underscore to indicate that a variable or
868 function should not be used outside the package that defined it.
870 =item Select what to export.
872 Do NOT export method names!
874 Do NOT export anything else by default without a good reason!
876 Exports pollute the namespace of the module user. If you must
877 export try to use @EXPORT_OK in preference to @EXPORT and avoid
878 short or common names to reduce the risk of name clashes.
880 Generally anything not exported is still accessible from outside the
881 module using the ModuleName::item_name (or C<$blessed_ref-E<gt>method>)
882 syntax. By convention you can use a leading underscore on names to
883 indicate informally that they are 'internal' and not for public use.
885 (It is actually possible to get private functions by saying:
886 C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
887 directly as a method, because a method must have a name in the symbol
890 As a general rule, if the module is trying to be object oriented
891 then export nothing. If it's just a collection of functions then
892 @EXPORT_OK anything but use @EXPORT with caution.
894 =item Select a name for the module.
896 This name should be as descriptive, accurate, and complete as
897 possible. Avoid any risk of ambiguity. Always try to use two or
898 more whole words. Generally the name should reflect what is special
899 about what the module does rather than how it does it. Please use
900 nested module names to group informally or categorize a module.
901 There should be a very good reason for a module not to have a nested name.
902 Module names should begin with a capital letter.
904 Having 57 modules all called Sort will not make life easy for anyone
905 (though having 23 called Sort::Quick is only marginally better :-).
906 Imagine someone trying to install your module alongside many others.
907 If in any doubt ask for suggestions in comp.lang.perl.misc.
909 If you are developing a suite of related modules/classes it's good
910 practice to use nested classes with a common prefix as this will
911 avoid namespace clashes. For example: Xyz::Control, Xyz::View,
912 Xyz::Model etc. Use the modules in this list as a naming guide.
914 If adding a new module to a set, follow the original author's
915 standards for naming modules and the interface to methods in
918 To be portable each component of a module name should be limited to
919 11 characters. If it might be used on MS-DOS then try to ensure each is
920 unique in the first 8 characters. Nested modules make this easier.
922 =item Have you got it right?
924 How do you know that you've made the right decisions? Have you
925 picked an interface design that will cause problems later? Have
926 you picked the most appropriate name? Do you have any questions?
928 The best way to know for sure, and pick up many helpful suggestions,
929 is to ask someone who knows. Comp.lang.perl.misc is read by just about
930 all the people who develop modules and it's the best place to ask.
932 All you need to do is post a short summary of the module, its
933 purpose and interfaces. A few lines on each of the main methods is
934 probably enough. (If you post the whole module it might be ignored
935 by busy people - generally the very people you want to read it!)
937 Don't worry about posting if you can't say when the module will be
938 ready - just say so in the message. It might be worth inviting
939 others to help you, they may be able to complete it for you!
941 =item README and other Additional Files.
943 It's well known that software developers usually fully document the
944 software they write. If, however, the world is in urgent need of
945 your software and there is not enough time to write the full
946 documentation please at least provide a README file containing:
951 A description of the module/package/extension etc.
954 A copyright notice - see below.
957 Prerequisites - what else you may need to have.
960 How to build it - possible changes to Makefile.PL etc.
966 Recent changes in this release, especially incompatibilities
969 Changes / enhancements you plan to make in the future.
973 If the README file seems to be getting too large you may wish to
974 split out some of the sections into separate files: INSTALL,
979 =item Adding a Copyright Notice.
981 How you choose to license your work is a personal decision.
982 The general mechanism is to assert your Copyright and then make
983 a declaration of how others may copy/use/modify your work.
985 Perl, for example, is supplied with two types of licence: The GNU
986 GPL and The Artistic Licence (see the files README, Copying, and
987 Artistic). Larry has good reasons for NOT just using the GNU GPL.
989 My personal recommendation, out of respect for Larry, Perl, and the
990 Perl community at large is to state something simply like:
992 Copyright (c) 1995 Your Name. All rights reserved.
993 This program is free software; you can redistribute it and/or
994 modify it under the same terms as Perl itself.
996 This statement should at least appear in the README file. You may
997 also wish to include it in a Copying file and your source files.
998 Remember to include the other words in addition to the Copyright.
1000 =item Give the module a version/issue/release number.
1002 To be fully compatible with the Exporter and MakeMaker modules you
1003 should store your module's version number in a non-my package
1004 variable called $VERSION. This should be a floating point
1005 number with at least two digits after the decimal (i.e., hundredths,
1006 e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.
1007 See Exporter.pm in Perl5.001m or later for details.
1009 It may be handy to add a function or method to retrieve the number.
1010 Use the number in announcements and archive file names when
1011 releasing the module (ModuleName-1.02.tar.Z).
1012 See perldoc ExtUtils::MakeMaker.pm for details.
1014 =item How to release and distribute a module.
1016 It's good idea to post an announcement of the availability of your
1017 module (or the module itself if small) to the comp.lang.perl.announce
1018 Usenet newsgroup. This will at least ensure very wide once-off
1021 If possible you should place the module into a major ftp archive and
1022 include details of its location in your announcement.
1024 Some notes about ftp archives: Please use a long descriptive file
1025 name that includes the version number. Most incoming directories
1026 will not be readable/listable, i.e., you won't be able to see your
1027 file after uploading it. Remember to send your email notification
1028 message as soon as possible after uploading else your file may get
1029 deleted automatically. Allow time for the file to be processed
1030 and/or check the file has been processed before announcing its
1033 FTP Archives for Perl Modules:
1035 Follow the instructions and links on
1037 http://franz.ww.tu-berlin.de/modulelist
1039 or upload to one of these sites:
1041 ftp://franz.ww.tu-berlin.de/incoming
1042 ftp://ftp.cis.ufl.edu/incoming
1044 and notify <F<upload@franz.ww.tu-berlin.de>>.
1046 By using the WWW interface you can ask the Upload Server to mirror
1047 your modules from your ftp or WWW site into your own directory on
1050 Please remember to send me an updated entry for the Module list!
1052 =item Take care when changing a released module.
1054 Always strive to remain compatible with previous released versions.
1055 Otherwise try to add a mechanism to revert to the
1056 old behaviour if people rely on it. Document incompatible changes.
1062 =head2 Guidelines for Converting Perl 4 Library Scripts into Modules
1066 =item There is no requirement to convert anything.
1068 If it ain't broke, don't fix it! Perl 4 library scripts should
1069 continue to work with no problems. You may need to make some minor
1070 changes (like escaping non-array @'s in double quoted strings) but
1071 there is no need to convert a .pl file into a Module for just that.
1073 =item Consider the implications.
1075 All Perl applications that make use of the script will need to
1076 be changed (slightly) if the script is converted into a module. Is
1077 it worth it unless you plan to make other changes at the same time?
1079 =item Make the most of the opportunity.
1081 If you are going to convert the script to a module you can use the
1082 opportunity to redesign the interface. The 'Guidelines for Module
1083 Creation' above include many of the issues you should consider.
1085 =item The pl2pm utility will get you started.
1087 This utility will read *.pl files (given as parameters) and write
1088 corresponding *.pm files. The pl2pm utilities does the following:
1093 Adds the standard Module prologue lines
1096 Converts package specifiers from ' to ::
1099 Converts die(...) to croak(...)
1102 Several other minor changes
1106 Being a mechanical process pl2pm is not bullet proof. The converted
1107 code will need careful checking, especially any package statements.
1108 Don't delete the original .pl file till the new .pm one works!
1112 =head2 Guidelines for Reusing Application Code
1116 =item Complete applications rarely belong in the Perl Module Library.
1118 =item Many applications contain some Perl code that could be reused.
1120 Help save the world! Share your code in a form that makes it easy
1123 =item Break-out the reusable code into one or more separate module files.
1125 =item Take the opportunity to reconsider and redesign the interfaces.
1127 =item In some cases the 'application' can then be reduced to a small
1129 fragment of code built on top of the reusable modules. In these cases
1130 the application could invoked as:
1132 % perl -e 'use Module::Name; method(@ARGV)' ...
1134 % perl -mModule::Name ... (in perl5.002 or higher)
1140 Perl does not enforce private and public parts of its modules as you may
1141 have been used to in other languages like C++, Ada, or Modula-17. Perl
1142 doesn't have an infatuation with enforced privacy. It would prefer
1143 that you stayed out of its living room because you weren't invited, not
1144 because it has a shotgun.
1146 The module and its user have a contract, part of which is common law,
1147 and part of which is "written". Part of the common law contract is
1148 that a module doesn't pollute any namespace it wasn't asked to. The
1149 written contract for the module (A.K.A. documentation) may make other
1150 provisions. But then you know when you C<use RedefineTheWorld> that
1151 you're redefining the world and willing to take the consequences.