Add test for grep() and wantarray
[p5sagit/p5-mst-13.2.git] / pod / perlmod.pod
index e27d0f1..b7383d2 100644 (file)
@@ -39,10 +39,10 @@ It would treat package C<INNER> as a totally separate global package.
 Only identifiers starting with letters (or underscore) are stored in a
 package's symbol table.  All other symbols are kept in package C<main>,
 including all of the punctuation variables like $_.  In addition, the
-identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC and SIG are
+identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC, and SIG are
 forced to be in package C<main>, even when used for other purposes than
 their built-in one.  Note also that, if you have a package called C<m>,
-C<s> or C<y>, then you can't use the qualified form of an identifier
+C<s>, or C<y>, then you can't use the qualified form of an identifier
 because it will be interpreted instead as a pattern match, a substitution,
 or a translation.
 
@@ -62,7 +62,7 @@ temporarily switches back to the C<main> package to evaluate various
 expressions in the context of the C<main> package (or wherever you came
 from).  See L<perldebug>.
 
-See L<perlsub> for other scoping issues related to my() and local(), 
+See L<perlsub> for other scoping issues related to my() and local(),
 or L<perlref> regarding closures.
 
 =head2 Symbol Tables
@@ -119,7 +119,7 @@ Assignment to a typeglob performs an aliasing operation, i.e.,
 
     *dick = *richard;
 
-causes variables, subroutines and file handles accessible via the
+causes variables, subroutines, and file handles accessible via the
 identifier C<richard> to also be accessible via the identifier C<dick>.  If
 you want to alias only a particular variable or subroutine, you can
 assign a reference instead:
@@ -140,7 +140,7 @@ thing.
        # now use %hashsym normally, and you
        # will affect the caller's %another_hash
        my %nhash = (); # do what you want
-       return \%nhash; 
+       return \%nhash;
     }
 
 On return, the reference will overwrite the hash slot in the
@@ -208,7 +208,7 @@ and C<END> work just as they do in B<awk>, as a degenerate case.
 There is no special class syntax in Perl, but a package may function
 as a class if it provides subroutines that function as methods.  Such a
 package may also derive some of its methods from another class package
-by listing the other package name in its @ISA array.  
+by listing the other package name in its @ISA array.
 
 For more on this, see L<perlobj>.
 
@@ -225,15 +225,18 @@ symbols.  Or it can do a little of both.
 For example, to start a normal module called Fred, create
 a file called Fred.pm and put this at the start of it:
 
-    package Fred;
-    use Exporter ();
+    package      Fred;
+    use          strict;
+    use          Exporter ();
+    use          vars qw(@ISA @EXPORT @EXPORT_OK);
     @ISA       = qw(Exporter);
-    @EXPORT    = qw(func1 func2);
-    @EXPORT_OK = qw($sally @listabob %harry func3);
+    @EXPORT    = qw(&func1 &func2);
+    @EXPORT_OK = qw($sally @listabob %harry &func3);
+    use                 vars qw($sally @listabob %harry);
 
 Then go on to declare and use your variables in functions
 without any qualifications.
-See L<Exporter> and the I<Perl Modules File> for details on 
+See L<Exporter> and the I<Perl Modules File> for details on
 mechanics and style issues in module creation.
 
 Perl modules are included into your program by saying
@@ -278,7 +281,7 @@ instead of C<use>.  With require you can get into this problem:
     require Cwd;               # make Cwd:: accessible
     $here = Cwd::getcwd();     
 
-    use Cwd;                   # import names from Cwd:: 
+    use Cwd;                   # import names from Cwd::
     $here = getcwd();
 
     require Cwd;               # make Cwd:: accessible
@@ -322,14 +325,15 @@ you're redefining the world and willing to take the consequences.
 =head1 THE PERL MODULE LIBRARY
 
 A number of modules are included the Perl distribution.  These are
-described below, and all end in F<.pm>.  You may also discover files in 
+described below, and all end in F<.pm>.  You may also discover files in
 the library directory that end in either F<.pl> or F<.ph>.  These are old
 libraries supplied so that old programs that use them still run.  The
 F<.pl> files will all eventually be converted into standard modules, and
 the F<.ph> files made by B<h2ph> will probably end up as extension modules
 made by B<h2xs>.  (Some F<.ph> values may already be available through the
 POSIX module.)  The B<pl2pm> file in the distribution may help in your
-conversion, but it's just a mechanical process, so is far from bulletproof.
+conversion, but it's just a mechanical process and therefore far from 
+bulletproof.
 
 =head2 Pragmatic Modules
 
@@ -346,7 +350,7 @@ which lasts until the end of that BLOCK.
 Unlike the pragmas that effect the C<$^H> hints variable, the C<use
 vars> and C<use subs> declarations are not BLOCK-scoped.  They allow
 you to pre-declare a variables or subroutines within a particular
-<I>file</I> rather than just a block.  Such declarations are effective
+I<file> rather than just a block.  Such declarations are effective
 for the entire file for which they were declared.  You cannot rescind
 them with C<no vars> or C<no subs>.
 
@@ -354,6 +358,11 @@ The following pragmas are defined (and have their own documentation).
 
 =over 12
 
+=item blib
+
+manipulate @INC at compile time to use MakeMaker's uninstalled version
+of a package
+
 =item diagnostics
 
 force verbose warning diagnostics
@@ -370,13 +379,17 @@ request less of something from the compiler
 
 manipulate @INC at compile time
 
+=item locale
+
+use or ignore current locale for built-in operations (see L<perllocale>)
+
 =item ops
 
-restrict unsafe operations when compiling
+restrict named opcodes when compiling or running Perl code
 
 =item overload
 
-package for overloading perl operations
+overload basic Perl operations
 
 =item sigtrap
 
@@ -390,6 +403,10 @@ restrict unsafe constructs
 
 pre-declare sub names
 
+=item vmsish
+
+adopt certain VMS-specific behaviors
+
 =item vars
 
 pre-declare global variable names
@@ -420,10 +437,26 @@ split a package for autoloading
 
 benchmark running times of code
 
+=item CPAN
+
+interface to Comprehensive Perl Archive Network
+
+=item CPAN::FirstTime
+
+create a CPAN configuration file
+
+=item CPAN::Nox
+
+run CPAN while avoiding compiled extensions
+
 =item Carp
 
 warn of errors (from perspective of caller)
 
+=item Class::Template
+
+struct/member template builder
+
 =item Config
 
 access Perl configuration information
@@ -446,7 +479,7 @@ supply object methods for directory handles
 
 =item DynaLoader
 
-Dynamically load C libraries into Perl code
+dynamically load C libraries into Perl code
 
 =item English
 
@@ -462,7 +495,7 @@ implements default import method for modules
 
 =item ExtUtils::Embed
 
-Utilities for embedding Perl in C/C++ applications
+utilities for embedding Perl in C/C++ applications
 
 =item ExtUtils::Install
 
@@ -472,6 +505,18 @@ install files from here to there
 
 determine libraries to use and how to use them
 
+=item ExtUtils::MM_OS2
+
+methods to override UN*X behaviour in ExtUtils::MakeMaker
+
+=item ExtUtils::MM_Unix
+
+methods used by ExtUtils::MakeMaker
+
+=item ExtUtils::MM_VMS
+
+methods to override UN*X behaviour in ExtUtils::MakeMaker
+
 =item ExtUtils::MakeMaker
 
 create an extension Makefile
@@ -480,10 +525,6 @@ create an extension Makefile
 
 utilities to write and check a MANIFEST file
 
-=item ExtUtils::Miniperl
-
-write the C code for perlmain.c
-
 =item ExtUtils::Mkbootstrap
 
 make a bootstrap file for use by DynaLoader
@@ -492,65 +533,57 @@ make a bootstrap file for use by DynaLoader
 
 write linker options files for dynamic extension
 
-=item ExtUtils::MM_OS2
-
-methods to override UN*X behaviour in ExtUtils::MakeMaker
-
-=item ExtUtils::MM_Unix
-
-methods used by ExtUtils::MakeMaker
-
-=item ExtUtils::MM_VMS
-
-methods to override UN*X behaviour in ExtUtils::MakeMaker
-
 =item ExtUtils::testlib
 
 add blib/* directories to @INC
 
-=item Fatal
-
-replace functions with equivalents which succeed or die
-
 =item Fcntl
 
 load the C Fcntl.h defines
 
 =item File::Basename
 
-parse file specifications
-
-=item FileCache
-
-keep more files open than the system permits
+split a pathname into pieces
 
 =item File::CheckTree
 
 run many filetest checks on a tree
 
+=item File::Compare
+
+compare files or filehandles
+
 =item File::Copy
 
-Copy files or filehandles
+copy files or filehandles
 
 =item File::Find
 
 traverse a file tree
 
-=item FileHandle
-
-supply object methods for filehandles
-
 =item File::Path
 
 create or remove a series of directories
 
+=item File::stat
+
+by-name interface to Perl's built-in stat() functions
+
+=item FileCache
+
+keep more files open than the system permits
+
+=item FileHandle
+
+supply object methods for filehandles
+
 =item FindBin
 
 locate directory of original perl script
 
 =item GDBM_File
 
-access to the gdbm library.
+access to the gdbm library
 
 =item Getopt::Long
 
@@ -618,11 +651,27 @@ tied access to ndbm files
 
 =item Net::Ping
 
-check a host for upness
+Hello, anybody home?
+
+=item Net::hostent
+
+by-name interface to Perl's built-in gethost*() functions
+
+=item Net::netent
+
+by-name interface to Perl's built-in getnet*() functions
+
+=item Net::protoent
+
+by-name interface to Perl's built-in getproto*() functions
+
+=item Net::servent
+
+by-name interface to Perl's built-in getserv*() functions
 
 =item Opcode
 
-disable named opcodes when compiling perl code
+disable named opcodes when compiling or running perl code
 
 =item Pod::Text
 
@@ -630,16 +679,16 @@ convert POD data to formatted ASCII text
 
 =item POSIX
 
-interface to IEEE Std 1003.1
-
-=item Safe
-
-compile and execute code in restricted compartments
+interface to IEEE Standard 1003.1
 
 =item SDBM_File
 
 tied access to sdbm files
 
+=item Safe
+
+compile and execute code in restricted compartments
+
 =item Search::Dict
 
 search for key in dictionary file
@@ -674,7 +723,7 @@ interface to the UNIX syslog(3) calls
 
 =item Term::Cap
 
-Perl termcap interface
+termcap interface
 
 =item Term::Complete
 
@@ -682,7 +731,7 @@ word completion module
 
 =item Term::ReadLine
 
-interface to various readline packages. 
+interface to various C<readline> packages
 
 =item Test::Harness
 
@@ -698,7 +747,7 @@ parse text into an array of tokens
 
 =item Text::Soundex
 
-implementation of the Soundex Algorithm as Described by Knuth
+implementation of the Soundex Algorithm as described by Knuth
 
 =item Text::Tabs
 
@@ -712,6 +761,10 @@ line wrapping to form simple paragraphs
 
 base class definitions for tied hashes
 
+=item Tie::RefHash
+
+base class definitions for tied hashes with references as keys
+
 =item Tie::Scalar
 
 base class definitions for tied scalars
@@ -724,10 +777,30 @@ fixed-table-size, fixed-key-length hashing
 
 efficiently compute time from local and GMT time
 
+=item Time::gmtime
+
+by-name interface to Perl's built-in gmtime() function
+
+=item Time::localtime
+
+by-name interface to Perl's built-in localtime() function
+
+=item Time::tm
+
+internal object used by Time::gmtime and Time::localtime
+
 =item UNIVERSAL
 
 base class for ALL classes (blessed references)
 
+=item User::grent
+
+by-name interface to Perl's built-in getgr*() functions
+
+=item User::pwent
+
+by-name interface to Perl's built-in getpw*() functions
+
 =back
 
 To find out I<all> the modules installed on your system, including
@@ -755,13 +828,13 @@ disposition.
 =head1 CPAN
 
 CPAN stands for the Comprehensive Perl Archive Network.  This is a globally
-replicated collection of all known Perl materials, including hundreds 
+replicated collection of all known Perl materials, including hundreds
 of unbundled modules.  Here are the major categories of modules:
 
 =over
 
 =item *
-Language Extensions and Documentation Tools 
+Language Extensions and Documentation Tools
 
 =item *
 Development Support
@@ -788,16 +861,16 @@ Interfaces to / Emulations of Other Programming Languages
 File Names, File Systems and File Locking (see also File Handles)
 
 =item *
-String Processing, Language Text Processing, Parsing and Searching
+String Processing, Language Text Processing, Parsing, and Searching
 
 =item *
-Option, Argument, Parameter and Configuration File Processing
+Option, Argument, Parameter, and Configuration File Processing
 
 =item *
 Internationalization and Locale
 
 =item *
-Authentication, Security and Encryption
+Authentication, Security, and Encryption
 
 =item *
 World Wide Web, HTML, HTTP, CGI, MIME
@@ -809,7 +882,7 @@ Server and Daemon Utilities
 Archiving and Compression
 
 =item *
-Images, Pixmap and Bitmap Manipulation, Drawing and Graphing
+Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
 
 =item *
 Mail and Usenet News
@@ -898,15 +971,15 @@ ftp://ftp.is.co.za/programming/perl/CPAN/
 
 =back
 
-For an up-to-date listing of CPAN sites, 
+For an up-to-date listing of CPAN sites,
 see F<http://www.perl.com/perl/CPAN> or F<ftp://ftp.perl.com/perl/>.
 
-=head1 Modules: Creation, Use and Abuse
+=head1 Modules: Creation, Use, and Abuse
 
 (The following section is borrowed directly from Tim Bunce's modules
 file, available at your nearest CPAN site.)
 
-Perl 5 implements a class using a package, but the presence of a
+Perl implements a class using a package, but the presence of a
 package doesn't imply the presence of a class.  A package is just a
 namespace.  A class is a package that provides subroutines that can be
 used as methods.  A method is just a subroutine that expects, as its
@@ -946,7 +1019,7 @@ Use blessed references.  Use the two argument form of bless to bless
 into the class name given as the first parameter of the constructor,
 e.g.,:
 
- sub new { 
+ sub new {
        my $class = shift;
        return bless {}, $class;
  }
@@ -954,7 +1027,7 @@ e.g.,:
 or even this if you'd like it to be used as either a static
 or a virtual method.
 
- sub new { 
+ sub new {
        my $self  = shift;
        my $class = ref($self) || $self;
        return bless {}, $class;
@@ -1052,7 +1125,7 @@ then export nothing. If it's just a collection of functions then
 
 =item Select a name for the module.
 
-This name should be as descriptive, accurate and complete as
+This name should be as descriptive, accurate, and complete as
 possible.  Avoid any risk of ambiguity. Always try to use two or
 more whole words.  Generally the name should reflect what is special
 about what the module does rather than how it does it.  Please use
@@ -1142,10 +1215,10 @@ The general mechanism is to assert your Copyright and then make
 a declaration of how others may copy/use/modify your work.
 
 Perl, for example, is supplied with two types of license: The GNU
-GPL and The Artistic License (see the files README, Copying and
+GPL and The Artistic License (see the files README, Copying, and
 Artistic).  Larry has good reasons for NOT just using the GNU GPL.
 
-My personal recommendation, out of respect for Larry, Perl and the
+My personal recommendation, out of respect for Larry, Perl, and the
 perl community at large is to state something simply like:
 
  Copyright (c) 1995 Your Name. All rights reserved.
@@ -1160,7 +1233,7 @@ Remember to include the other words in addition to the Copyright.
 
 To be fully compatible with the Exporter and MakeMaker modules you
 should store your module's version number in a non-my package
-variable called $VERSION.  This should be a valid floating point 
+variable called $VERSION.  This should be a floating point
 number with at least two digits after the decimal (i.e., hundredths,
 e.g, C<$VERSION = "0.01">).  Don't use a "1.3.2" style version.
 See Exporter.pm in Perl5.001m or later for details.
@@ -1195,10 +1268,10 @@ Follow the instructions and links on
 
    http://franz.ww.tu-berlin.de/modulelist
 
-or upload to one of these sites: 
+or upload to one of these sites:
 
    ftp://franz.ww.tu-berlin.de/incoming
-   ftp://ftp.cis.ufl.edu/incoming  
+   ftp://ftp.cis.ufl.edu/incoming
 
 and notify upload@franz.ww.tu-berlin.de.
 
@@ -1289,8 +1362,7 @@ fragment of code built on top of the reusable modules. In these cases
 the application could invoked as:
 
      perl -e 'use Module::Name; method(@ARGV)' ...
-or   
+or
      perl -mModule::Name ...    (in perl5.002)
 
 =back
-