home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / RiscOS / APP / DEVS / PERL / RPC106.ZIP / Rpc106 / Docs / perlmodlib < prev    next >
Text File  |  1997-11-23  |  30KB  |  877 lines

  1. NAME
  2.     perlmodlib - constructing new Perl modules and finding existing
  3.     ones
  4.  
  5. DESCRIPTION
  6. THE PERL MODULE LIBRARY
  7.     A number of modules are included the Perl distribution. These
  8.     are described below, and all end in .pm. You may also discover
  9.     files in the library directory that end in either .pl or .ph.
  10.     These are old libraries supplied so that old programs that use
  11.     them still run. The .pl files will all eventually be converted
  12.     into standard modules, and the .ph files made by h2ph will
  13.     probably end up as extension modules made by h2xs. (Some .ph
  14.     values may already be available through the POSIX module.) The
  15.     pl2pm file in the distribution may help in your conversion, but
  16.     it's just a mechanical process and therefore far from
  17.     bulletproof.
  18.  
  19.   Pragmatic Modules
  20.  
  21.     They work somewhat like pragmas in that they tend to affect the
  22.     compilation of your program, and thus will usually work well
  23.     only when used within a `use', or `no'. Most of these are
  24.     locally scoped, so an inner BLOCK may countermand any of these
  25.     by saying:
  26.  
  27.     no integer;
  28.     no strict 'refs';
  29.  
  30.     which lasts until the end of that BLOCK.
  31.  
  32.     Unlike the pragmas that effect the `$^H' hints variable, the
  33.     `use vars' and `use subs' declarations are not BLOCK-scoped.
  34.     They allow you to predeclare a variables or subroutines within a
  35.     particular *file* rather than just a block. Such declarations
  36.     are effective for the entire file for which they were declared.
  37.     You cannot rescind them with `no vars' or `no subs'.
  38.  
  39.     The following pragmas are defined (and have their own
  40.     documentation).
  41.  
  42.     use autouse MODULE => qw(sub1 sub2 sub3)
  43.         Defers `require MODULE' until someone calls one of
  44.         the specified subroutines (which must be exported by
  45.         MODULE). This pragma should be used with caution,
  46.         and only when necessary.
  47.  
  48.     blib    manipulate @INC at compile time to use MakeMaker's
  49.         uninstalled version of a package
  50.  
  51.     diagnostics force verbose warning diagnostics
  52.  
  53.     integer    compute arithmetic in integer instead of double
  54.  
  55.     less    request less of something from the compiler
  56.  
  57.     lib     manipulate @INC at compile time
  58.  
  59.     locale    use or ignore current locale for builtin operations (see
  60.         the perllocale manpage)
  61.  
  62.     ops     restrict named opcodes when compiling or running Perl
  63.         code
  64.  
  65.     overload    overload basic Perl operations
  66.  
  67.     sigtrap    enable simple signal handling
  68.  
  69.     strict    restrict unsafe constructs
  70.  
  71.     subs    predeclare sub names
  72.  
  73.     vmsish    adopt certain VMS-specific behaviors
  74.  
  75.     vars    predeclare global variable names
  76.  
  77.   Standard Modules
  78.  
  79.     Standard, bundled modules are all expected to behave in a well-
  80.     defined manner with respect to namespace pollution because they
  81.     use the Exporter module. See their own documentation for
  82.     details.
  83.  
  84.     AnyDBM_File provide framework for multiple DBMs
  85.  
  86.     AutoLoader    load functions only on demand
  87.  
  88.     AutoSplit    split a package for autoloading
  89.  
  90.     Benchmark    benchmark running times of code
  91.  
  92.     CPAN    interface to Comprehensive Perl Archive Network
  93.  
  94.     CPAN::FirstTime
  95.         create a CPAN configuration file
  96.  
  97.     CPAN::Nox    run CPAN while avoiding compiled extensions
  98.  
  99.     Carp    warn of errors (from perspective of caller)
  100.  
  101.     Class::Struct
  102.         declare struct-like datatypes
  103.  
  104.     Config    access Perl configuration information
  105.  
  106.     Cwd     get pathname of current working directory
  107.  
  108.     DB_File    access to Berkeley DB
  109.  
  110.     Devel::SelfStubber
  111.         generate stubs for a SelfLoading module
  112.  
  113.     DirHandle    supply object methods for directory handles
  114.  
  115.     DynaLoader    dynamically load C libraries into Perl code
  116.  
  117.     English    use nice English (or awk) names for ugly punctuation
  118.         variables
  119.  
  120.     Env     import environment variables
  121.  
  122.     Exporter    implements default import method for modules
  123.  
  124.     ExtUtils::Embed
  125.         utilities for embedding Perl in C/C++ applications
  126.  
  127.     ExtUtils::Install
  128.         install files from here to there
  129.  
  130.     ExtUtils::Liblist
  131.         determine libraries to use and how to use them
  132.  
  133.     ExtUtils::MM_OS2
  134.         methods to override Unix behaviour in
  135.         ExtUtils::MakeMaker
  136.  
  137.     ExtUtils::MM_Unix
  138.         methods used by ExtUtils::MakeMaker
  139.  
  140.     ExtUtils::MM_VMS
  141.         methods to override Unix behaviour in
  142.         ExtUtils::MakeMaker
  143.  
  144.     ExtUtils::MakeMaker
  145.         create an extension Makefile
  146.  
  147.     ExtUtils::Manifest
  148.         utilities to write and check a MANIFEST file
  149.  
  150.     ExtUtils::Mkbootstrap
  151.         make a bootstrap file for use by DynaLoader
  152.  
  153.     ExtUtils::Mksymlists
  154.         write linker options files for dynamic extension
  155.  
  156.     ExtUtils::testlib
  157.         add blib/* directories to @INC
  158.  
  159.     Fcntl    load the C Fcntl.h defines
  160.  
  161.     File::Basename
  162.         split a pathname into pieces
  163.  
  164.     File::CheckTree
  165.         run many filetest checks on a tree
  166.  
  167.     File::Compare
  168.         compare files or filehandles
  169.  
  170.     File::Copy    copy files or filehandles
  171.  
  172.     File::Find    traverse a file tree
  173.  
  174.     File::Path    create or remove a series of directories
  175.  
  176.     File::stat    by-name interface to Perl's builtin stat() functions
  177.  
  178.     FileCache    keep more files open than the system permits
  179.  
  180.     FileHandle    supply object methods for filehandles
  181.  
  182.     FindBin    locate directory of original perl script
  183.  
  184.     GDBM_File    access to the gdbm library
  185.  
  186.     Getopt::Long
  187.         extended processing of command line options
  188.  
  189.     Getopt::Std process single-character switches with switch clustering
  190.  
  191.     I18N::Collate
  192.         compare 8-bit scalar data according to the current
  193.         locale
  194.  
  195.     IO        load various IO modules
  196.  
  197.     IO::File    supply object methods for filehandles
  198.  
  199.     IO::Handle    supply object methods for I/O handles
  200.  
  201.     IO::Pipe    supply object methods for pipes
  202.  
  203.     IO::Seekable
  204.         supply seek based methods for I/O objects
  205.  
  206.     IO::Select    OO interface to the select system call
  207.  
  208.     IO::Socket    object interface to socket communications
  209.  
  210.     IPC::Open2    open a process for both reading and writing
  211.  
  212.     IPC::Open3    open a process for reading, writing, and error handling
  213.  
  214.     Math::BigFloat
  215.         arbitrary length float math package
  216.  
  217.     Math::BigInt
  218.         arbitrary size integer math package
  219.  
  220.     Math::Complex
  221.         complex numbers and associated mathematical
  222.         functions
  223.  
  224.     Math::Trig    simple interface to parts of Math::Complex for those who
  225.         need trigonometric functions only for real numbers
  226.  
  227.     NDBM_File    tied access to ndbm files
  228.  
  229.     Net::Ping    Hello, anybody home?
  230.  
  231.     Net::hostent
  232.         by-name interface to Perl's builtin gethost*()
  233.         functions
  234.  
  235.     Net::netent by-name interface to Perl's builtin getnet*() functions
  236.  
  237.     Net::protoent
  238.         by-name interface to Perl's builtin getproto*()
  239.         functions
  240.  
  241.     Net::servent
  242.         by-name interface to Perl's builtin getserv*()
  243.         functions
  244.  
  245.     Opcode    disable named opcodes when compiling or running perl
  246.         code
  247.  
  248.     Pod::Text    convert POD data to formatted ASCII text
  249.  
  250.     POSIX    interface to IEEE Standard 1003.1
  251.  
  252.     SDBM_File    tied access to sdbm files
  253.  
  254.     Safe    compile and execute code in restricted compartments
  255.  
  256.     Search::Dict
  257.         search for key in dictionary file
  258.  
  259.     SelectSaver save and restore selected file handle
  260.  
  261.     SelfLoader    load functions only on demand
  262.  
  263.     Shell    run shell commands transparently within perl
  264.  
  265.     Socket    load the C socket.h defines and structure manipulators
  266.  
  267.     Symbol    manipulate Perl symbols and their names
  268.  
  269.     Sys::Hostname
  270.         try every conceivable way to get hostname
  271.  
  272.     Sys::Syslog interface to the Unix syslog(3) calls
  273.  
  274.     Term::Cap    termcap interface
  275.  
  276.     Term::Complete
  277.         word completion module
  278.  
  279.     Term::ReadLine
  280.         interface to various `readline' packages
  281.  
  282.     Test::Harness
  283.         run perl standard test scripts with statistics
  284.  
  285.     Text::Abbrev
  286.         create an abbreviation table from a list
  287.  
  288.     Text::ParseWords
  289.         parse text into an array of tokens
  290.  
  291.     Text::Soundex
  292.         implementation of the Soundex Algorithm as described
  293.         by Knuth
  294.  
  295.     Text::Tabs    expand and unexpand tabs per the Unix expand(1) and
  296.         unexpand(1)
  297.  
  298.     Text::Wrap    line wrapping to form simple paragraphs
  299.  
  300.     Tie::Hash    base class definitions for tied hashes
  301.  
  302.     Tie::RefHash
  303.         base class definitions for tied hashes with
  304.         references as keys
  305.  
  306.     Tie::Scalar base class definitions for tied scalars
  307.  
  308.     Tie::SubstrHash
  309.         fixed-table-size, fixed-key-length hashing
  310.  
  311.     Time::Local efficiently compute time from local and GMT time
  312.  
  313.     Time::gmtime
  314.         by-name interface to Perl's builtin gmtime()
  315.         function
  316.  
  317.     Time::localtime
  318.         by-name interface to Perl's builtin localtime()
  319.         function
  320.  
  321.     Time::tm    internal object used by Time::gmtime and Time::localtime
  322.  
  323.     UNIVERSAL    base class for ALL classes (blessed references)
  324.  
  325.     User::grent by-name interface to Perl's builtin getgr*() functions
  326.  
  327.     User::pwent by-name interface to Perl's builtin getpw*() functions
  328.  
  329.     To find out *all* the modules installed on your system,
  330.     including those without documentation or outside the standard
  331.     release, do this:
  332.  
  333.     find `perl -e 'print "@INC"'` -name '*.pm' -print
  334.  
  335.     They should all have their own documentation installed and
  336.     accessible via your system man(1) command. If that fails, try
  337.     the *perldoc* program.
  338.  
  339.   Extension Modules
  340.  
  341.     Extension modules are written in C (or a mix of Perl and C) and
  342.     may be statically linked or in general are dynamically loaded
  343.     into Perl if and when you need them. Supported extension modules
  344.     include the Socket, Fcntl, and POSIX modules.
  345.  
  346.     Many popular C extension modules do not come bundled (at least,
  347.     not completely) due to their sizes, volatility, or simply lack
  348.     of time for adequate testing and configuration across the
  349.     multitude of platforms on which Perl was beta-tested. You are
  350.     encouraged to look for them in archie(1L), the Perl FAQ or Meta-
  351.     FAQ, the WWW page, and even with their authors before randomly
  352.     posting asking for their present condition and disposition.
  353.  
  354. CPAN
  355.     CPAN stands for the Comprehensive Perl Archive Network. This is
  356.     a globally replicated collection of all known Perl materials,
  357.     including hundreds of unbundled modules. Here are the major
  358.     categories of modules:
  359.  
  360.     *
  361.     Language Extensions and Documentation Tools
  362.     *
  363.     Development Support
  364.     *
  365.     Operating System Interfaces
  366.     *
  367.     Networking, Device Control (modems) and InterProcess Communication
  368.     *
  369.     Data Types and Data Type Utilities
  370.     *
  371.     Database Interfaces
  372.     *
  373.     User Interfaces
  374.     *
  375.     Interfaces to / Emulations of Other Programming Languages
  376.     *
  377.     File Names, File Systems and File Locking (see also File Handles)
  378.     *
  379.     String Processing, Language Text Processing, Parsing, and Searching
  380.     *
  381.     Option, Argument, Parameter, and Configuration File Processing
  382.     *
  383.     Internationalization and Locale
  384.     *
  385.     Authentication, Security, and Encryption
  386.     *
  387.     World Wide Web, HTML, HTTP, CGI, MIME
  388.     *
  389.     Server and Daemon Utilities
  390.     *
  391.     Archiving and Compression
  392.     *
  393.     Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
  394.     *
  395.     Mail and Usenet News
  396.     *
  397.     Control Flow Utilities (callbacks and exceptions etc)
  398.     *
  399.     File Handle and Input/Output Stream Utilities
  400.     *
  401.     Miscellaneous Modules
  402.     The registered CPAN sites as of this writing include the
  403.     following. You should try to choose one close to you:
  404.  
  405.     *
  406.     Africa
  407.         South Africa    ftp://ftp.is.co.za/programming/perl/CPAN/
  408.  
  409.     *
  410.     Asia
  411.         Hong Kong        ftp://ftp.hkstar.com/pub/CPAN/
  412.         Japan        ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
  413.                 ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
  414.         South Korea     ftp://ftp.nuri.net/pub/CPAN/
  415.         Taiwan        ftp://dongpo.math.ncu.edu.tw/perl/CPAN/
  416.                 ftp://ftp.wownet.net/pub2/PERL/
  417.  
  418.     *
  419.     Australasia
  420.         Australia        ftp://ftp.netinfo.com.au/pub/perl/CPAN/
  421.         New Zealand     ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/
  422.  
  423.     *
  424.     Europe
  425.         Austria        ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
  426.         Belgium        ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
  427.         Czech Republic  ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/
  428.         Denmark        ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
  429.         Finland        ftp://ftp.funet.fi/pub/languages/perl/CPAN/
  430.         France        ftp://ftp.ibp.fr/pub/perl/CPAN/
  431.                 ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/
  432.         Germany        ftp://ftp.gmd.de/packages/CPAN/
  433.                 ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/
  434.                 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
  435.                 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
  436.                 ftp://ftp.uni-erlangen.de/pub/source/Perl/CPAN/
  437.                 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
  438.         Greece        ftp://ftp.ntua.gr/pub/lang/perl/
  439.         Hungary        ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
  440.         Italy        ftp://cis.utovrm.it/CPAN/
  441.         the Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
  442.                 ftp://ftp.EU.net/packages/cpan/
  443.         Norway        ftp://ftp.uit.no/pub/languages/perl/cpan/
  444.         Poland        ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
  445.                 ftp://sunsite.icm.edu.pl/pub/CPAN/
  446.         Portugal        ftp://ftp.ci.uminho.pt/pub/lang/perl/
  447.                 ftp://ftp.telepac.pt/pub/CPAN/
  448.         Russia        ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
  449.         Slovenia        ftp://ftp.arnes.si/software/perl/CPAN/
  450.         Spain        ftp://ftp.etse.urv.es/pub/mirror/perl/
  451.                 ftp://ftp.rediris.es/mirror/CPAN/
  452.         Sweden        ftp://ftp.sunet.se/pub/lang/perl/CPAN/
  453.         UK            ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
  454.                 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
  455.                 ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/
  456.  
  457.     *
  458.     North America
  459.         Ontario        ftp://ftp.utilis.com/public/CPAN/
  460.                 ftp://enterprise.ic.gc.ca/pub/perl/CPAN/
  461.         Manitoba        ftp://theory.uwinnipeg.ca/pub/CPAN/
  462.         California        ftp://ftp.digital.com/pub/plan/perl/CPAN/
  463.                 ftp://ftp.cdrom.com/pub/perl/CPAN/
  464.         Colorado        ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
  465.         Florida        ftp://ftp.cis.ufl.edu/pub/perl/CPAN/
  466.         Illinois        ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/
  467.         Massachusetts   ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
  468.         New York        ftp://ftp.rge.com/pub/languages/perl/
  469.         North Carolina  ftp://ftp.duke.edu/pub/perl/
  470.         Oklahoma        ftp://ftp.ou.edu/mirrors/CPAN/
  471.         Oregon        http://www.perl.org/CPAN/
  472.                 ftp://ftp.orst.edu/pub/packages/CPAN/
  473.         Pennsylvania    ftp://ftp.epix.net/pub/languages/perl/
  474.         Texas        ftp://ftp.sedl.org/pub/mirrors/CPAN/
  475.                 ftp://ftp.metronet.com/pub/perl/
  476.  
  477.     *
  478.     South America
  479.         Chile        ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/
  480.  
  481.     For an up-to-date listing of CPAN sites, see
  482.     http://www.perl.com/perl/CPAN or ftp://ftp.perl.com/perl/.
  483.  
  484. Modules: Creation, Use, and Abuse
  485.     (The following section is borrowed directly from Tim Bunce's
  486.     modules file, available at your nearest CPAN site.)
  487.  
  488.     Perl implements a class using a package, but the presence of a
  489.     package doesn't imply the presence of a class. A package is just
  490.     a namespace. A class is a package that provides subroutines that
  491.     can be used as methods. A method is just a subroutine that
  492.     expects, as its first argument, either the name of a package
  493.     (for "static" methods), or a reference to something (for
  494.     "virtual" methods).
  495.  
  496.     A module is a file that (by convention) provides a class of the
  497.     same name (sans the .pm), plus an import method in that class
  498.     that can be called to fetch exported symbols. This module may
  499.     implement some of its methods by loading dynamic C or C++
  500.     objects, but that should be totally transparent to the user of
  501.     the module. Likewise, the module might set up an AUTOLOAD
  502.     function to slurp in subroutine definitions on demand, but this
  503.     is also transparent. Only the .pm file is required to exist. See
  504.     the perlsub manpage, the perltoot manpage, and the AutoLoader
  505.     manpage for details about the AUTOLOAD mechanism.
  506.  
  507.   Guidelines for Module Creation
  508.  
  509.     Do similar modules already exist in some form?
  510.     If so, please try to reuse the existing modules either in
  511.     whole or by inheriting useful features into a new class. If
  512.     this is not practical try to get together with the module
  513.     authors to work on extending or enhancing the functionality
  514.     of the existing modules. A perfect example is the plethora
  515.     of packages in perl4 for dealing with command line options.
  516.  
  517.     If you are writing a module to expand an already existing
  518.     set of modules, please coordinate with the author of the
  519.     package. It helps if you follow the same naming scheme and
  520.     module interaction scheme as the original author.
  521.  
  522.     Try to design the new module to be easy to extend and reuse.
  523.     Use blessed references. Use the two argument form of bless
  524.     to bless into the class name given as the first parameter of
  525.     the constructor, e.g.,:
  526.  
  527.      sub new {
  528.         my $class = shift;
  529.         return bless {}, $class;
  530.      }
  531.  
  532.     or even this if you'd like it to be used as either a static
  533.     or a virtual method.
  534.  
  535.      sub new {
  536.         my $self  = shift;
  537.         my $class = ref($self) || $self;
  538.         return bless {}, $class;
  539.      }
  540.  
  541.     Pass arrays as references so more parameters can be added
  542.     later (it's also faster). Convert functions into methods
  543.     where appropriate. Split large methods into smaller more
  544.     flexible ones. Inherit methods from other modules if
  545.     appropriate.
  546.  
  547.     Avoid class name tests like: `die "Invalid" unless ref $ref
  548.     eq 'FOO''. Generally you can delete the "`eq 'FOO''" part
  549.     with no harm at all. Let the objects look after themselves!
  550.     Generally, avoid hard-wired class names as far as possible.
  551.  
  552.     Avoid `$r->Class::func()' where using `@ISA=qw(... Class
  553.     ...)' and `$r->func()' would work (see the perlbot manpage
  554.     for more details).
  555.  
  556.     Use autosplit so little used or newly added functions won't
  557.     be a burden to programs which don't use them. Add test
  558.     functions to the module after __END__ either using AutoSplit
  559.     or by saying:
  560.  
  561.      eval join('',<main::DATA>) || die $@ unless caller();
  562.  
  563.     Does your module pass the 'empty subclass' test? If you say
  564.     "`@SUBCLASS::ISA = qw(YOURCLASS);'" your applications should
  565.     be able to use SUBCLASS in exactly the same way as
  566.     YOURCLASS. For example, does your application still work if
  567.     you change: `$obj = new YOURCLASS;' into: `$obj = new
  568.     SUBCLASS;' ?
  569.  
  570.     Avoid keeping any state information in your packages. It
  571.     makes it difficult for multiple other packages to use yours.
  572.     Keep state information in objects.
  573.  
  574.     Always use -w. Try to `use strict;' (or `use strict
  575.     qw(...);'). Remember that you can add `no strict qw(...);'
  576.     to individual blocks of code which need less strictness.
  577.     Always use -w. Always use -w! Follow the guidelines in the
  578.     perlstyle(1) manual.
  579.  
  580.     Some simple style guidelines
  581.     The perlstyle manual supplied with perl has many helpful
  582.     points.
  583.  
  584.     Coding style is a matter of personal taste. Many people
  585.     evolve their style over several years as they learn what
  586.     helps them write and maintain good code. Here's one set of
  587.     assorted suggestions that seem to be widely used by
  588.     experienced developers:
  589.  
  590.     Use underscores to separate words. It is generally easier to
  591.     read $var_names_like_this than $VarNamesLikeThis, especially
  592.     for non-native speakers of English. It's also a simple rule
  593.     that works consistently with VAR_NAMES_LIKE_THIS.
  594.  
  595.     Package/Module names are an exception to this rule. Perl
  596.     informally reserves lowercase module names for 'pragma'
  597.     modules like integer and strict. Other modules normally
  598.     begin with a capital letter and use mixed case with no
  599.     underscores (need to be short and portable).
  600.  
  601.     You may find it helpful to use letter case to indicate the
  602.     scope or nature of a variable. For example:
  603.  
  604.      $ALL_CAPS_HERE   constants only (beware clashes with perl vars)
  605.      $Some_Caps_Here  package-wide global/static
  606.      $no_caps_here      function scope my() or local() variables
  607.  
  608.     Function and method names seem to work best as all
  609.     lowercase. e.g., `$obj->as_string()'.
  610.  
  611.     You can use a leading underscore to indicate that a variable
  612.     or function should not be used outside the package that
  613.     defined it.
  614.  
  615.     Select what to export.
  616.     Do NOT export method names!
  617.  
  618.     Do NOT export anything else by default without a good
  619.     reason!
  620.  
  621.     Exports pollute the namespace of the module user. If you
  622.     must export try to use @EXPORT_OK in preference to @EXPORT
  623.     and avoid short or common names to reduce the risk of name
  624.     clashes.
  625.  
  626.     Generally anything not exported is still accessible from
  627.     outside the module using the ModuleName::item_name (or
  628.     `$blessed_ref->method') syntax. By convention you can use a
  629.     leading underscore on names to indicate informally that they
  630.     are 'internal' and not for public use.
  631.  
  632.     (It is actually possible to get private functions by saying:
  633.     `my $subref = sub { ... }; &$subref;'. But there's no way to
  634.     call that directly as a method, because a method must have a
  635.     name in the symbol table.)
  636.  
  637.     As a general rule, if the module is trying to be object
  638.     oriented then export nothing. If it's just a collection of
  639.     functions then @EXPORT_OK anything but use @EXPORT with
  640.     caution.
  641.  
  642.     Select a name for the module.
  643.     This name should be as descriptive, accurate, and complete
  644.     as possible. Avoid any risk of ambiguity. Always try to use
  645.     two or more whole words. Generally the name should reflect
  646.     what is special about what the module does rather than how
  647.     it does it. Please use nested module names to group
  648.     informally or categorize a module. There should be a very
  649.     good reason for a module not to have a nested name. Module
  650.     names should begin with a capital letter.
  651.  
  652.     Having 57 modules all called Sort will not make life easy
  653.     for anyone (though having 23 called Sort::Quick is only
  654.     marginally better :-). Imagine someone trying to install
  655.     your module alongside many others. If in any doubt ask for
  656.     suggestions in comp.lang.perl.misc.
  657.  
  658.     If you are developing a suite of related modules/classes
  659.     it's good practice to use nested classes with a common
  660.     prefix as this will avoid namespace clashes. For example:
  661.     Xyz::Control, Xyz::View, Xyz::Model etc. Use the modules in
  662.     this list as a naming guide.
  663.  
  664.     If adding a new module to a set, follow the original
  665.     author's standards for naming modules and the interface to
  666.     methods in those modules.
  667.  
  668.     To be portable each component of a module name should be
  669.     limited to 11 characters. If it might be used on MS-DOS then
  670.     try to ensure each is unique in the first 8 characters.
  671.     Nested modules make this easier.
  672.  
  673.     Have you got it right?
  674.     How do you know that you've made the right decisions? Have
  675.     you picked an interface design that will cause problems
  676.     later? Have you picked the most appropriate name? Do you
  677.     have any questions?
  678.  
  679.     The best way to know for sure, and pick up many helpful
  680.     suggestions, is to ask someone who knows.
  681.     Comp.lang.perl.misc is read by just about all the people who
  682.     develop modules and it's the best place to ask.
  683.  
  684.     All you need to do is post a short summary of the module,
  685.     its purpose and interfaces. A few lines on each of the main
  686.     methods is probably enough. (If you post the whole module it
  687.     might be ignored by busy people - generally the very people
  688.     you want to read it!)
  689.  
  690.     Don't worry about posting if you can't say when the module
  691.     will be ready - just say so in the message. It might be
  692.     worth inviting others to help you, they may be able to
  693.     complete it for you!
  694.  
  695.     README and other Additional Files.
  696.     It's well known that software developers usually fully
  697.     document the software they write. If, however, the world is
  698.     in urgent need of your software and there is not enough time
  699.     to write the full documentation please at least provide a
  700.     README file containing:
  701.  
  702.     *
  703.     A description of the module/package/extension etc.
  704.     *
  705.     A copyright notice - see below.
  706.     *
  707.     Prerequisites - what else you may need to have.
  708.     *
  709.     How to build it - possible changes to Makefile.PL etc.
  710.     *
  711.     How to install it.
  712.     *
  713.     Recent changes in this release, especially incompatibilities
  714.     *
  715.     Changes / enhancements you plan to make in the future.
  716.     If the README file seems to be getting too large you may
  717.     wish to split out some of the sections into separate files:
  718.     INSTALL, Copying, ToDo etc.
  719.  
  720.     Adding a Copyright Notice.
  721.         How you choose to license your work is a personal
  722.         decision. The general mechanism is to assert your
  723.         Copyright and then make a declaration of how others may
  724.         copy/use/modify your work.
  725.  
  726.         Perl, for example, is supplied with two types of
  727.         licence: The GNU GPL and The Artistic Licence (see the
  728.         files README, Copying, and Artistic). Larry has good
  729.         reasons for NOT just using the GNU GPL.
  730.  
  731.         My personal recommendation, out of respect for Larry,
  732.         Perl, and the perl community at large is to state
  733.         something simply like:
  734.  
  735.          Copyright (c) 1995 Your Name. All rights reserved.
  736.          This program is free software; you can redistribute it and/or
  737.          modify it under the same terms as Perl itself.
  738.  
  739.         This statement should at least appear in the README
  740.         file. You may also wish to include it in a Copying file
  741.         and your source files. Remember to include the other
  742.         words in addition to the Copyright.
  743.  
  744.     Give the module a version/issue/release number.
  745.         To be fully compatible with the Exporter and MakeMaker
  746.         modules you should store your module's version number in
  747.         a non-my package variable called $VERSION. This should
  748.         be a floating point number with at least two digits
  749.         after the decimal (i.e., hundredths, e.g, `$VERSION =
  750.         "0.01"'). Don't use a "1.3.2" style version. See
  751.         Exporter.pm in Perl5.001m or later for details.
  752.  
  753.         It may be handy to add a function or method to retrieve
  754.         the number. Use the number in announcements and archive
  755.         file names when releasing the module (ModuleName-
  756.         1.02.tar.Z). See perldoc ExtUtils::MakeMaker.pm for
  757.         details.
  758.  
  759.     How to release and distribute a module.
  760.         It's good idea to post an announcement of the
  761.         availability of your module (or the module itself if
  762.         small) to the comp.lang.perl.announce Usenet newsgroup.
  763.         This will at least ensure very wide once-off
  764.         distribution.
  765.  
  766.         If possible you should place the module into a major ftp
  767.         archive and include details of its location in your
  768.         announcement.
  769.  
  770.         Some notes about ftp archives: Please use a long
  771.         descriptive file name which includes the version number.
  772.         Most incoming directories will not be readable/listable,
  773.         i.e., you won't be able to see your file after uploading
  774.         it. Remember to send your email notification message as
  775.         soon as possible after uploading else your file may get
  776.         deleted automatically. Allow time for the file to be
  777.         processed and/or check the file has been processed
  778.         before announcing its location.
  779.  
  780.         FTP Archives for Perl Modules:
  781.  
  782.         Follow the instructions and links on
  783.  
  784.            http://franz.ww.tu-berlin.de/modulelist
  785.  
  786.         or upload to one of these sites:
  787.  
  788.            ftp://franz.ww.tu-berlin.de/incoming
  789.            ftp://ftp.cis.ufl.edu/incoming
  790.  
  791.         and notify <upload@franz.ww.tu-berlin.de>.
  792.  
  793.         By using the WWW interface you can ask the Upload Server
  794.         to mirror your modules from your ftp or WWW site into
  795.         your own directory on CPAN!
  796.  
  797.         Please remember to send me an updated entry for the
  798.         Module list!
  799.  
  800.     Take care when changing a released module.
  801.         Always strive to remain compatible with previous
  802.         released versions (see 2.2 above) Otherwise try to add a
  803.         mechanism to revert to the old behaviour if people rely
  804.         on it. Document incompatible changes.
  805.  
  806.   Guidelines for Converting Perl 4 Library Scripts into Modules
  807.  
  808.     There is no requirement to convert anything.
  809.     If it ain't broke, don't fix it! Perl 4 library scripts
  810.     should continue to work with no problems. You may need to
  811.     make some minor changes (like escaping non-array @'s in
  812.     double quoted strings) but there is no need to convert a .pl
  813.     file into a Module for just that.
  814.  
  815.     Consider the implications.
  816.     All the perl applications which make use of the script will
  817.     need to be changed (slightly) if the script is converted
  818.     into a module. Is it worth it unless you plan to make other
  819.     changes at the same time?
  820.  
  821.     Make the most of the opportunity.
  822.     If you are going to convert the script to a module you can
  823.     use the opportunity to redesign the interface. The
  824.     'Guidelines for Module Creation' above include many of the
  825.     issues you should consider.
  826.  
  827.     The pl2pm utility will get you started.
  828.     This utility will read *.pl files (given as parameters) and
  829.     write corresponding *.pm files. The pl2pm utilities does the
  830.     following:
  831.  
  832.     *
  833.     Adds the standard Module prologue lines
  834.     *
  835.     Converts package specifiers from ' to ::
  836.     *
  837.     Converts die(...) to croak(...)
  838.     *
  839.     Several other minor changes
  840.     Being a mechanical process pl2pm is not bullet proof. The
  841.     converted code will need careful checking, especially any
  842.     package statements. Don't delete the original .pl file till
  843.     the new .pm one works!
  844.  
  845.   Guidelines for Reusing Application Code
  846.  
  847.     Complete applications rarely belong in the Perl Module Library.
  848.     Many applications contain some perl code which could be reused.
  849.     Help save the world! Share your code in a form that makes it
  850.     easy to reuse.
  851.  
  852.     Break-out the reusable code into one or more separate module files.
  853.     Take the opportunity to reconsider and redesign the interfaces.
  854.     In some cases the 'application' can then be reduced to a small
  855.     fragment of code built on top of the reusable modules. In
  856.     these cases the application could invoked as:
  857.  
  858.          perl -e 'use Module::Name; method(@ARGV)' ...
  859.     or
  860.          perl -mModule::Name ...    (in perl5.002 or higher)
  861.  
  862. NOTE
  863.     Perl does not enforce private and public parts of its modules as
  864.     you may have been used to in other languages like C++, Ada, or
  865.     Modula-17. Perl doesn't have an infatuation with enforced
  866.     privacy. It would prefer that you stayed out of its living room
  867.     because you weren't invited, not because it has a shotgun.
  868.  
  869.     The module and its user have a contract, part of which is common
  870.     law, and part of which is "written". Part of the common law
  871.     contract is that a module doesn't pollute any namespace it
  872.     wasn't asked to. The written contract for the module (A.K.A.
  873.     documentation) may make other provisions. But then you know when
  874.     you `use RedefineTheWorld' that you're redefining the world and
  875.     willing to take the consequences.
  876.  
  877.