summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/pod
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/pod')
-rw-r--r--contrib/perl5/pod/Makefile286
-rw-r--r--contrib/perl5/pod/buildtoc241
-rw-r--r--contrib/perl5/pod/checkpods.PL85
-rw-r--r--contrib/perl5/pod/perl.pod319
-rw-r--r--contrib/perl5/pod/perl5004delta.pod1609
-rw-r--r--contrib/perl5/pod/perlapio.pod274
-rw-r--r--contrib/perl5/pod/perlbook.pod16
-rw-r--r--contrib/perl5/pod/perlbot.pod527
-rw-r--r--contrib/perl5/pod/perlcall.pod1959
-rw-r--r--contrib/perl5/pod/perldata.pod603
-rw-r--r--contrib/perl5/pod/perldebug.pod1661
-rw-r--r--contrib/perl5/pod/perldelta.pod919
-rw-r--r--contrib/perl5/pod/perldiag.pod3125
-rw-r--r--contrib/perl5/pod/perldsc.pod832
-rw-r--r--contrib/perl5/pod/perlembed.pod1029
-rw-r--r--contrib/perl5/pod/perlfaq.pod172
-rw-r--r--contrib/perl5/pod/perlfaq1.pod268
-rw-r--r--contrib/perl5/pod/perlfaq2.pod499
-rw-r--r--contrib/perl5/pod/perlfaq3.pod595
-rw-r--r--contrib/perl5/pod/perlfaq4.pod1358
-rw-r--r--contrib/perl5/pod/perlfaq5.pod1074
-rw-r--r--contrib/perl5/pod/perlfaq6.pod626
-rw-r--r--contrib/perl5/pod/perlfaq7.pod816
-rw-r--r--contrib/perl5/pod/perlfaq8.pod1075
-rw-r--r--contrib/perl5/pod/perlfaq9.pod552
-rw-r--r--contrib/perl5/pod/perlform.pod337
-rw-r--r--contrib/perl5/pod/perlfunc.pod4440
-rw-r--r--contrib/perl5/pod/perlguts.pod3557
-rw-r--r--contrib/perl5/pod/perlhist.pod518
-rw-r--r--contrib/perl5/pod/perlipc.pod1443
-rw-r--r--contrib/perl5/pod/perllocale.pod976
-rw-r--r--contrib/perl5/pod/perllol.pod303
-rw-r--r--contrib/perl5/pod/perlmod.pod375
-rw-r--r--contrib/perl5/pod/perlmodinstall.pod410
-rw-r--r--contrib/perl5/pod/perlmodlib.pod1102
-rw-r--r--contrib/perl5/pod/perlobj.pod541
-rw-r--r--contrib/perl5/pod/perlop.pod1724
-rw-r--r--contrib/perl5/pod/perlpod.pod286
-rw-r--r--contrib/perl5/pod/perlport.pod1461
-rw-r--r--contrib/perl5/pod/perlre.pod929
-rw-r--r--contrib/perl5/pod/perlref.pod646
-rw-r--r--contrib/perl5/pod/perlrun.pod731
-rw-r--r--contrib/perl5/pod/perlsec.pod351
-rw-r--r--contrib/perl5/pod/perlstyle.pod275
-rw-r--r--contrib/perl5/pod/perlsub.pod1149
-rw-r--r--contrib/perl5/pod/perlsyn.pod617
-rw-r--r--contrib/perl5/pod/perltie.pod876
-rw-r--r--contrib/perl5/pod/perltoc.pod5840
-rw-r--r--contrib/perl5/pod/perltoot.pod1787
-rw-r--r--contrib/perl5/pod/perltrap.pod1505
-rw-r--r--contrib/perl5/pod/perlvar.pod936
-rw-r--r--contrib/perl5/pod/perlxs.pod1348
-rw-r--r--contrib/perl5/pod/perlxstut.pod739
-rw-r--r--contrib/perl5/pod/pod2html.PL183
-rw-r--r--contrib/perl5/pod/pod2latex.PL708
-rw-r--r--contrib/perl5/pod/pod2man.PL1216
-rw-r--r--contrib/perl5/pod/pod2text.PL51
-rw-r--r--contrib/perl5/pod/roffitall284
-rwxr-xr-xcontrib/perl5/pod/rofftoc66
-rwxr-xr-xcontrib/perl5/pod/splitman46
-rwxr-xr-xcontrib/perl5/pod/splitpod60
61 files changed, 58336 insertions, 0 deletions
diff --git a/contrib/perl5/pod/Makefile b/contrib/perl5/pod/Makefile
new file mode 100644
index 0000000..9187c84
--- /dev/null
+++ b/contrib/perl5/pod/Makefile
@@ -0,0 +1,286 @@
+CONVERTERS = pod2html pod2latex pod2man pod2text checkpods
+
+HTMLROOT = / # Change this to fix cross-references in HTML
+POD2HTML = pod2html \
+ --htmlroot=$(HTMLROOT) \
+ --podroot=.. --podpath=pod:lib:ext:vms \
+ --libpods=perlfunc:perlguts:perlvar:perlrun:perlop
+
+all: $(CONVERTERS) man
+
+converters: $(CONVERTERS)
+
+PERL = ../miniperl
+REALPERL = ../perl
+
+POD = \
+ perl.pod \
+ perldelta.pod \
+ perldata.pod \
+ perlsyn.pod \
+ perlop.pod \
+ perlre.pod \
+ perlrun.pod \
+ perlfunc.pod \
+ perlvar.pod \
+ perlsub.pod \
+ perlmod.pod \
+ perlmodlib.pod \
+ perlmodinstall.pod \
+ perlform.pod \
+ perllocale.pod \
+ perlref.pod \
+ perldsc.pod \
+ perllol.pod \
+ perltoot.pod \
+ perlobj.pod \
+ perltie.pod \
+ perlbot.pod \
+ perlipc.pod \
+ perldebug.pod \
+ perldiag.pod \
+ perlsec.pod \
+ perltrap.pod \
+ perlport.pod \
+ perlstyle.pod \
+ perlpod.pod \
+ perlbook.pod \
+ perlembed.pod \
+ perlapio.pod \
+ perlxs.pod \
+ perlxstut.pod \
+ perlguts.pod \
+ perlcall.pod \
+ perlfaq.pod \
+ perlfaq1.pod \
+ perlfaq2.pod \
+ perlfaq3.pod \
+ perlfaq4.pod \
+ perlfaq5.pod \
+ perlfaq6.pod \
+ perlfaq7.pod \
+ perlfaq8.pod \
+ perlfaq9.pod \
+ perltoc.pod
+
+MAN = \
+ perl.man \
+ perldelta.man \
+ perldata.man \
+ perlsyn.man \
+ perlop.man \
+ perlre.man \
+ perlrun.man \
+ perlfunc.man \
+ perlvar.man \
+ perlsub.man \
+ perlmod.man \
+ perlmodlib.man \
+ perlmodinstall.man \
+ perlform.man \
+ perllocale.man \
+ perlref.man \
+ perldsc.man \
+ perllol.man \
+ perltoot.man \
+ perlobj.man \
+ perltie.man \
+ perlbot.man \
+ perlipc.man \
+ perldebug.man \
+ perldiag.man \
+ perlsec.man \
+ perltrap.man \
+ perlport.man \
+ perlstyle.man \
+ perlpod.man \
+ perlbook.man \
+ perlembed.man \
+ perlapio.man \
+ perlxs.man \
+ perlxstut.man \
+ perlguts.man \
+ perlcall.man \
+ perlfaq.man \
+ perlfaq1.man \
+ perlfaq2.man \
+ perlfaq3.man \
+ perlfaq4.man \
+ perlfaq5.man \
+ perlfaq6.man \
+ perlfaq7.man \
+ perlfaq8.man \
+ perlfaq9.man \
+ perltoc.man
+
+HTML = \
+ perl.html \
+ perldelta.html \
+ perldata.html \
+ perlsyn.html \
+ perlop.html \
+ perlre.html \
+ perlrun.html \
+ perlfunc.html \
+ perlvar.html \
+ perlsub.html \
+ perlmod.html \
+ perlmodlib.html \
+ perlmodinstall.html \
+ perlform.html \
+ perllocale.html \
+ perlref.html \
+ perldsc.html \
+ perllol.html \
+ perltoot.html \
+ perlobj.html \
+ perltie.html \
+ perlbot.html \
+ perlipc.html \
+ perldebug.html \
+ perldiag.html \
+ perlsec.html \
+ perltrap.html \
+ perlport.html \
+ perlstyle.html \
+ perlpod.html \
+ perlbook.html \
+ perlembed.html \
+ perlapio.html \
+ perlxs.html \
+ perlxstut.html \
+ perlguts.html \
+ perlcall.html \
+ perlfaq.html \
+ perlfaq1.html \
+ perlfaq2.html \
+ perlfaq3.html \
+ perlfaq4.html \
+ perlfaq5.html \
+ perlfaq6.html \
+ perlfaq7.html \
+ perlfaq8.html \
+ perlfaq9.html
+# not perltoc.html
+
+TEX = \
+ perl.tex \
+ perldelta.tex \
+ perldata.tex \
+ perlsyn.tex \
+ perlop.tex \
+ perlre.tex \
+ perlrun.tex \
+ perlfunc.tex \
+ perlvar.tex \
+ perlsub.tex \
+ perlmod.tex \
+ perlmodlib.tex \
+ perlmodinstall.tex \
+ perlform.tex \
+ perllocale.tex \
+ perlref.tex \
+ perldsc.tex \
+ perllol.tex \
+ perltoot.tex \
+ perlobj.tex \
+ perltie.tex \
+ perlbot.tex \
+ perlipc.tex \
+ perldebug.tex \
+ perldiag.tex \
+ perlsec.tex \
+ perltrap.tex \
+ perlport.tex \
+ perlstyle.tex \
+ perlpod.tex \
+ perlbook.tex \
+ perlembed.tex \
+ perlapio.tex \
+ perlxs.tex \
+ perlxstut.tex \
+ perlguts.tex \
+ perlcall.tex \
+ perlfaq.tex \
+ perlfaq1.tex \
+ perlfaq2.tex \
+ perlfaq3.tex \
+ perlfaq4.tex \
+ perlfaq5.tex \
+ perlfaq6.tex \
+ perlfaq7.tex \
+ perlfaq8.tex \
+ perlfaq9.tex \
+ perltoc.tex
+
+man: pod2man $(MAN)
+
+html: pod2html $(HTML)
+
+tex: pod2latex $(TEX)
+
+toc:
+ $(PERL) -I../lib buildtoc >perltoc.pod
+
+.SUFFIXES: .pm .pod
+
+.SUFFIXES: .man
+
+.pm.man: pod2man
+ $(PERL) -I../lib pod2man $*.pm >$*.man
+
+.pod.man: pod2man
+ $(PERL) -I../lib pod2man $*.pod >$*.man
+
+.SUFFIXES: .html
+
+.pm.html: pod2html
+ $(PERL) -I../lib $(POD2HTML) --infile=$*.pm --outfile=$*.html
+
+.pod.html: pod2html
+ $(PERL) -I../lib $(POD2HTML) --infile=$*.pod --outfile=$*.html
+
+.SUFFIXES: .tex
+
+.pm.tex: pod2latex
+ $(PERL) -I../lib pod2latex $*.pm
+
+.pod.tex: pod2latex
+ $(PERL) -I../lib pod2latex $*.pod
+
+clean:
+ rm -f $(MAN)
+ rm -f $(HTML)
+ rm -f $(TEX)
+ rm -f pod2html-*cache
+ rm -f *.aux *.log *.exe
+
+realclean: clean
+ rm -f $(CONVERTERS)
+
+distclean: realclean
+
+check: checkpods
+ @echo "checking..."; \
+ $(PERL) -I../lib checkpods $(POD)
+
+# Dependencies.
+pod2latex: pod2latex.PL ../lib/Config.pm
+ $(PERL) -I../lib pod2latex.PL
+
+pod2html: pod2html.PL ../lib/Config.pm
+ $(PERL) -I ../lib pod2html.PL
+
+pod2man: pod2man.PL ../lib/Config.pm
+ $(PERL) -I ../lib pod2man.PL
+
+pod2text: pod2text.PL ../lib/Config.pm
+ $(PERL) -I ../lib pod2text.PL
+
+checkpods: checkpods.PL ../lib/Config.pm
+ $(PERL) -I ../lib checkpods.PL
+
+compile: all
+ $(REALPERL) -I../lib ../utils/perlcc -regex 's/$$/.exe/' pod2latex pod2man pod2text checkpods -prog -verbose dcf -log ../compilelog;
+
+
diff --git a/contrib/perl5/pod/buildtoc b/contrib/perl5/pod/buildtoc
new file mode 100644
index 0000000..80ca2ec
--- /dev/null
+++ b/contrib/perl5/pod/buildtoc
@@ -0,0 +1,241 @@
+use File::Find;
+use Cwd;
+use Text::Wrap;
+
+sub output ($);
+
+@pods = qw(
+ perl perlfaq perlfaq1 perlfaq2 perlfaq3 perlfaq4 perlfaq5
+ perlfaq6 perlfaq7 perlfaq8 perlfaq9 perldelta perldata
+ perlsyn perlop perlre perlrun perlfunc perlvar perlsub
+ perlmod perlmodlib perlmodinstall perlform perllocale perlref perldsc
+ perllol perltoot perlobj perltie perlbot perlipc perldebug
+ perldiag perlsec perltrap perlport perlstyle perlpod perlbook
+ perlembed perlapio perlxs perlxstut perlguts perlcall
+ perlhist
+ );
+
+for (@pods) { s/$/.pod/ }
+
+$/ = '';
+@ARGV = @pods;
+
+($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
+
+ =head1 NAME
+
+ perltoc - perl documentation table of contents
+
+ =head1 DESCRIPTION
+
+ This page provides a brief table of contents for the rest of the Perl
+ documentation set. It is meant to be scanned quickly or grepped
+ through to locate the proper section you're looking for.
+
+ =head1 BASIC DOCUMENTATION
+
+EOPOD2B
+#' make emacs happy
+
+podset(@pods);
+
+find \&getpods => qw(../lib ../ext);
+
+sub getpods {
+ if (/\.p(od|m)$/) {
+ # Skip .pm files that have corresponding .pod files, and Functions.pm.
+ return if /(.*)\.pm$/ && -f "$1.pod";
+ my $file = $File::Find::name;
+ return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself
+
+ die "tut $name" if $file =~ /TUT/;
+ unless (open (F, "< $_\0")) {
+ warn "bogus <$file>: $!";
+ system "ls", "-l", $file;
+ }
+ else {
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ /^=head1\s+NAME\b/) {
+ push @modpods, $file;
+ #warn "GOOD $file\n";
+ return;
+ }
+ }
+ warn "EVIL $file\n";
+ }
+ }
+}
+
+die "no pods" unless @modpods;
+
+for (@modpods) {
+ #($name) = /(\w+)\.p(m|od)$/;
+ $name = path2modname($_);
+ if ($name =~ /^[a-z]/) {
+ push @pragmata, $_;
+ } else {
+ if ($done{$name}++) {
+ # warn "already did $_\n";
+ next;
+ }
+ push @modules, $_;
+ push @modname, $name;
+ }
+}
+
+($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
+
+
+
+ =head1 PRAGMA DOCUMENTATION
+
+EOPOD2B
+
+podset(sort @pragmata);
+
+($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
+
+
+
+ =head1 MODULE DOCUMENTATION
+
+EOPOD2B
+
+podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
+
+($_= <<EOPOD2B) =~ s/^\t//gm;
+
+
+ =head1 AUXILIARY DOCUMENTATION
+
+ Here should be listed all the extra programs' documentation, but they
+ don't all have manual pages yet:
+
+ =item a2p
+
+ =item s2p
+
+ =item find2perl
+
+ =item h2ph
+
+ =item c2ph
+
+ =item h2xs
+
+ =item xsubpp
+
+ =item pod2man
+
+ =item wrapsuid
+
+
+ =head1 AUTHOR
+
+ Larry Wall <F<larry\@wall.org>>, with the help of oodles
+ of other folks.
+
+
+EOPOD2B
+output $_;
+output "\n"; # flush $LINE
+exit;
+
+sub podset {
+ local @ARGV = @_;
+
+ while(<>) {
+ if (s/^=head1 (NAME)\s*/=head2 /) {
+ $pod = path2modname($ARGV);
+ unitem();
+ unhead2();
+ output "\n \n\n=head2 ";
+ $_ = <>;
+ if ( /^\s*$pod\b/ ) {
+ s/$pod\.pm/$pod/; # '.pm' in NAME !?
+ output $_;
+ } else {
+ s/^/$pod, /;
+ output $_;
+ }
+ next;
+ }
+ if (s/^=head1 (.*)/=item $1/) {
+ unitem(); unhead2();
+ output $_; nl(); next;
+ }
+ if (s/^=head2 (.*)/=item $1/) {
+ unitem();
+ output "=over\n\n" unless $inhead2;
+ $inhead2 = 1;
+ output $_; nl(); next;
+
+ }
+ if (s/^=item ([^=].*)\n/$1/) {
+ next if $pod eq 'perldiag';
+ s/^\s*\*\s*$// && next;
+ s/^\s*\*\s*//;
+ s/\s+$//;
+ next if /^[\d.]+$/;
+ next if $pod eq 'perlmodlib' && /^ftp:/;
+ ##print "=over\n\n" unless $initem;
+ output ", " if $initem;
+ $initem = 1;
+ s/\.$//;
+ s/^-X\b/-I<X>/;
+ output $_; next;
+ }
+ }
+}
+
+sub path2modname {
+ local $_ = shift;
+ s/\.p(m|od)$//;
+ s-.*?/(lib|ext)/--;
+ s-/-::-g;
+ s/(\w+)::\1/$1/;
+ return $_;
+}
+
+sub unhead2 {
+ if ($inhead2) {
+ output "\n\n=back\n\n";
+ }
+ $inhead2 = 0;
+ $initem = 0;
+}
+
+sub unitem {
+ if ($initem) {
+ output "\n\n";
+ ##print "\n\n=back\n\n";
+ }
+ $initem = 0;
+}
+
+sub nl {
+ output "\n";
+}
+
+my $NEWLINE; # how many newlines have we seen recently
+my $LINE; # what remains to be printed
+
+sub output ($) {
+ for (split /(\n)/, shift) {
+ if ($_ eq "\n") {
+ if ($LINE) {
+ print wrap('', '', $LINE);
+ $LINE = '';
+ }
+ if ($NEWLINE < 2) {
+ print;
+ $NEWLINE++;
+ }
+ }
+ elsif (/\S/ && length) {
+ $LINE .= $_;
+ $NEWLINE = 0;
+ }
+ }
+}
diff --git a/contrib/perl5/pod/checkpods.PL b/contrib/perl5/pod/checkpods.PL
new file mode 100644
index 0000000..92b7ae6
--- /dev/null
+++ b/contrib/perl5/pod/checkpods.PL
@@ -0,0 +1,85 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
+chdir dirname($0);
+$file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+# In the following, perl variables are not expanded during extraction.
+
+print OUT <<'!NO!SUBS!';
+# From roderick@gate.netThu Sep 5 17:19:30 1996
+# Date: Thu, 05 Sep 1996 00:11:22 -0400
+# From: Roderick Schertler <roderick@gate.net>
+# To: perl5-porters@africa.nicoh.com
+# Subject: POD lines with only spaces
+#
+# There are some places in the documentation where a POD directive is
+# ignored because the line before it contains whitespace (and so the
+# directive doesn't start a paragraph). This patch adds a way to check
+# for these to the pod Makefile (though it isn't made part of the build
+# process, which would be a good idea), and fixes those places where the
+# problem currently exists.
+#
+# Version 1.00 Original.
+# Version 1.01 Andy Dougherty <doughera@lafcol.lafayette.edu>
+# Trivial modifications to output format for easier auto-parsing
+# Broke it out as a separate function to avoid nasty
+# Make/Shell/Perl quoting problems, and also to make it easier
+# to grow. Someone will probably want to rewrite in terms of
+# some sort of Pod::Checker module. Or something. Consider this
+# a placeholder for the future.
+# Version 1.02 Roderick Schertler <roderick@argon.org>
+# Check for pod directives following any kind of unempty line, not
+# just lines of whitespace.
+
+@directive = qw(head1 head2 item over back cut pod for begin end);
+@directive{@directive} = (1) x @directive;
+
+$exit = $last_unempty = 0;
+while (<>) {
+ chomp;
+ if (/^=(\S+)/ && $directive{$1} && $last_unempty) {
+ printf "%s: line %5d, no blank line preceeding directive =%s\n",
+ $ARGV, $., $1;
+ $exit = 1;
+ }
+ $last_unempty = ($_ ne '');
+ if (eof) {
+ close(ARGV);
+ $last_unempty = 0;
+ }
+}
+exit $exit
+!NO!SUBS!
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
diff --git a/contrib/perl5/pod/perl.pod b/contrib/perl5/pod/perl.pod
new file mode 100644
index 0000000..0b9e9fa
--- /dev/null
+++ b/contrib/perl5/pod/perl.pod
@@ -0,0 +1,319 @@
+=head1 NAME
+
+perl - Practical Extraction and Report Language
+
+=head1 SYNOPSIS
+
+B<perl> S<[ B<-sTuU> ]>
+ S<[ B<-hv> ] [ B<-V>[:I<configvar>] ]>
+ S<[ B<-cw> ] [ B<-d>[:I<debugger>] ] [ B<-D>[I<number/list>] ]>
+ S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [ B<-0>[I<octal>] ]>
+ S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [ B<-M>[B<->]I<'module...'> ]>
+ S<[ B<-P> ]>
+ S<[ B<-S> ]>
+ S<[ B<-x>[I<dir>] ]>
+ S<[ B<-i>[I<extension>] ]>
+ S<[ B<-e> I<'command'> ] [ B<--> ] [ I<programfile> ] [ I<argument> ]...>
+
+For ease of access, the Perl manual has been split up into a number
+of sections:
+
+ perl Perl overview (this section)
+ perldelta Perl changes since previous version
+ perlfaq Perl frequently asked questions
+ perltoc Perl documentation table of contents
+
+ perldata Perl data structures
+ perlsyn Perl syntax
+ perlop Perl operators and precedence
+ perlre Perl regular expressions
+ perlrun Perl execution and options
+ perlfunc Perl builtin functions
+ perlvar Perl predefined variables
+ perlsub Perl subroutines
+ perlmod Perl modules: how they work
+ perlmodlib Perl modules: how to write and use
+ perlmodinstall Perl modules: how to install from CPAN
+ perlform Perl formats
+ perllocale Perl locale support
+
+ perlref Perl references
+ perldsc Perl data structures intro
+ perllol Perl data structures: lists of lists
+ perltoot Perl OO tutorial
+ perlobj Perl objects
+ perltie Perl objects hidden behind simple variables
+ perlbot Perl OO tricks and examples
+ perlipc Perl interprocess communication
+
+ perldebug Perl debugging
+ perldiag Perl diagnostic messages
+ perlsec Perl security
+ perltrap Perl traps for the unwary
+ perlport Perl portability guide
+ perlstyle Perl style guide
+
+ perlpod Perl plain old documentation
+ perlbook Perl book information
+
+ perlembed Perl ways to embed perl in your C or C++ application
+ perlapio Perl internal IO abstraction interface
+ perlxs Perl XS application programming interface
+ perlxstut Perl XS tutorial
+ perlguts Perl internal functions for those doing extensions
+ perlcall Perl calling conventions from C
+
+ perlhist Perl history records
+
+(If you're intending to read these straight through for the first time,
+the suggested order will tend to reduce the number of forward references.)
+
+By default, all of the above manpages are installed in the
+F</usr/local/man/> directory.
+
+Extensive additional documentation for Perl modules is available. The
+default configuration for perl will place this additional documentation
+in the F</usr/local/lib/perl5/man> directory (or else in the F<man>
+subdirectory of the Perl library directory). Some of this additional
+documentation is distributed standard with Perl, but you'll also find
+documentation for third-party modules there.
+
+You should be able to view Perl's documentation with your man(1)
+program by including the proper directories in the appropriate start-up
+files, or in the MANPATH environment variable. To find out where the
+configuration has installed the manpages, type:
+
+ perl -V:man.dir
+
+If the directories have a common stem, such as F</usr/local/man/man1>
+and F</usr/local/man/man3>, you need only to add that stem
+(F</usr/local/man>) to your man(1) configuration files or your MANPATH
+environment variable. If they do not share a stem, you'll have to add
+both stems.
+
+If that doesn't work for some reason, you can still use the
+supplied F<perldoc> script to view module information. You might
+also look into getting a replacement man program.
+
+If something strange has gone wrong with your program and you're not
+sure where you should look for help, try the B<-w> switch first. It
+will often point out exactly where the trouble is.
+
+=head1 DESCRIPTION
+
+Perl is a language optimized for scanning arbitrary
+text files, extracting information from those text files, and printing
+reports based on that information. It's also a good language for many
+system management tasks. The language is intended to be practical
+(easy to use, efficient, complete) rather than beautiful (tiny,
+elegant, minimal).
+
+Perl combines (in the author's opinion, anyway) some of the best
+features of C, B<sed>, B<awk>, and B<sh>, so people familiar with
+those languages should have little difficulty with it. (Language
+historians will also note some vestiges of B<csh>, Pascal, and even
+BASIC-PLUS.) Expression syntax corresponds quite closely to C
+expression syntax. Unlike most Unix utilities, Perl does not
+arbitrarily limit the size of your data--if you've got the memory,
+Perl can slurp in your whole file as a single string. Recursion is of
+unlimited depth. And the tables used by hashes (previously called
+"associative arrays") grow as necessary to prevent degraded
+performance. Perl uses sophisticated pattern matching techniques to
+scan large amounts of data very quickly. Although optimized for
+scanning text, Perl can also deal with binary data, and can make dbm
+files look like hashes. Setuid Perl scripts are safer than C programs
+through a dataflow tracing mechanism which prevents many stupid
+security holes.
+
+If you have a problem that would ordinarily use B<sed> or B<awk> or
+B<sh>, but it exceeds their capabilities or must run a little faster,
+and you don't want to write the silly thing in C, then Perl may be for
+you. There are also translators to turn your B<sed> and B<awk>
+scripts into Perl scripts.
+
+But wait, there's more...
+
+Perl version 5 is nearly a complete rewrite, and provides
+the following additional benefits:
+
+=over 5
+
+=item * Many usability enhancements
+
+It is now possible to write much more readable Perl code (even within
+regular expressions). Formerly cryptic variable names can be replaced
+by mnemonic identifiers. Error messages are more informative, and the
+optional warnings will catch many of the mistakes a novice might make.
+This cannot be stressed enough. Whenever you get mysterious behavior,
+try the B<-w> switch!!! Whenever you don't get mysterious behavior,
+try using B<-w> anyway.
+
+=item * Simplified grammar
+
+The new yacc grammar is one half the size of the old one. Many of the
+arbitrary grammar rules have been regularized. The number of reserved
+words has been cut by 2/3. Despite this, nearly all old Perl scripts
+will continue to work unchanged.
+
+=item * Lexical scoping
+
+Perl variables may now be declared within a lexical scope, like "auto"
+variables in C. Not only is this more efficient, but it contributes
+to better privacy for "programming in the large". Anonymous
+subroutines exhibit deep binding of lexical variables (closures).
+
+=item * Arbitrarily nested data structures
+
+Any scalar value, including any array element, may now contain a
+reference to any other variable or subroutine. You can easily create
+anonymous variables and subroutines. Perl manages your reference
+counts for you.
+
+=item * Modularity and reusability
+
+The Perl library is now defined in terms of modules which can be easily
+shared among various packages. A package may choose to import all or a
+portion of a module's published interface. Pragmas (that is, compiler
+directives) are defined and used by the same mechanism.
+
+=item * Object-oriented programming
+
+A package can function as a class. Dynamic multiple inheritance and
+virtual methods are supported in a straightforward manner and with very
+little new syntax. Filehandles may now be treated as objects.
+
+=item * Embeddable and Extensible
+
+Perl may now be embedded easily in your C or C++ application, and can
+either call or be called by your routines through a documented
+interface. The XS preprocessor is provided to make it easy to glue
+your C or C++ routines into Perl. Dynamic loading of modules is
+supported, and Perl itself can be made into a dynamic library.
+
+=item * POSIX compliant
+
+A major new module is the POSIX module, which provides access to all
+available POSIX routines and definitions, via object classes where
+appropriate.
+
+=item * Package constructors and destructors
+
+The new BEGIN and END blocks provide means to capture control as
+a package is being compiled, and after the program exits. As a
+degenerate case they work just like awk's BEGIN and END when you
+use the B<-p> or B<-n> switches.
+
+=item * Multiple simultaneous DBM implementations
+
+A Perl program may now access DBM, NDBM, SDBM, GDBM, and Berkeley DB
+files from the same script simultaneously. In fact, the old dbmopen
+interface has been generalized to allow any variable to be tied
+to an object class which defines its access methods.
+
+=item * Subroutine definitions may now be autoloaded
+
+In fact, the AUTOLOAD mechanism also allows you to define any arbitrary
+semantics for undefined subroutine calls. It's not for just autoloading.
+
+=item * Regular expression enhancements
+
+You can now specify nongreedy quantifiers. You can now do grouping
+without creating a backreference. You can now write regular expressions
+with embedded whitespace and comments for readability. A consistent
+extensibility mechanism has been added that is upwardly compatible with
+all old regular expressions.
+
+=item * Innumerable Unbundled Modules
+
+The Comprehensive Perl Archive Network described in L<perlmodlib>
+contains hundreds of plug-and-play modules full of reusable code.
+See F<http://www.perl.com/CPAN> for a site near you.
+
+=item * Compilability
+
+While not yet in full production mode, a working perl-to-C compiler
+does exist. It can generate portable byte code, simple C, or
+optimized C code.
+
+=back
+
+Okay, that's I<definitely> enough hype.
+
+=head1 ENVIRONMENT
+
+See L<perlrun>.
+
+=head1 AUTHOR
+
+Larry Wall <F<larry@wall.org>>, with the help of oodles of other folks.
+
+If your Perl success stories and testimonials may be of help to others
+who wish to advocate the use of Perl in their applications,
+or if you wish to simply express your gratitude to Larry and the
+Perl developers, please write to <F<perl-thanks@perl.org>>.
+
+=head1 FILES
+
+ "/tmp/perl-e$$" temporary file for -e commands
+ "@INC" locations of perl libraries
+
+=head1 SEE ALSO
+
+ a2p awk to perl translator
+
+ s2p sed to perl translator
+
+=head1 DIAGNOSTICS
+
+The B<-w> switch produces some lovely diagnostics.
+
+See L<perldiag> for explanations of all Perl's diagnostics. The C<use
+diagnostics> pragma automatically turns Perl's normally terse warnings
+and errors into these longer forms.
+
+Compilation errors will tell you the line number of the error, with an
+indication of the next token or token type that was to be examined.
+(In the case of a script passed to Perl via B<-e> switches, each
+B<-e> is counted as one line.)
+
+Setuid scripts have additional constraints that can produce error
+messages such as "Insecure dependency". See L<perlsec>.
+
+Did we mention that you should definitely consider using the B<-w>
+switch?
+
+=head1 BUGS
+
+The B<-w> switch is not mandatory.
+
+Perl is at the mercy of your machine's definitions of various
+operations such as type casting, atof(), and floating-point
+output with sprintf().
+
+If your stdio requires a seek or eof between reads and writes on a
+particular stream, so does Perl. (This doesn't apply to sysread()
+and syswrite().)
+
+While none of the built-in data types have any arbitrary size limits
+(apart from memory size), there are still a few arbitrary limits: a
+given variable name may not be longer than 255 characters, and no
+component of your PATH may be longer than 255 if you use B<-S>. A regular
+expression may not compile to more than 32767 bytes internally.
+
+You may mail your bug reports (be sure to include full configuration
+information as output by the myconfig program in the perl source tree,
+or by C<perl -V>) to <F<perlbug@perl.com>>.
+If you've succeeded in compiling perl, the perlbug script in the utils/
+subdirectory can be used to help mail in a bug report.
+
+Perl actually stands for Pathologically Eclectic Rubbish Lister, but
+don't tell anyone I said that.
+
+=head1 NOTES
+
+The Perl motto is "There's more than one way to do it." Divining
+how many more is left as an exercise to the reader.
+
+The three principal virtues of a programmer are Laziness,
+Impatience, and Hubris. See the Camel Book for why.
+
diff --git a/contrib/perl5/pod/perl5004delta.pod b/contrib/perl5/pod/perl5004delta.pod
new file mode 100644
index 0000000..f1b6c8f
--- /dev/null
+++ b/contrib/perl5/pod/perl5004delta.pod
@@ -0,0 +1,1609 @@
+=head1 NAME
+
+perldelta - what's new for perl5.004
+
+=head1 DESCRIPTION
+
+This document describes differences between the 5.003 release (as
+documented in I<Programming Perl>, second edition--the Camel Book) and
+this one.
+
+=head1 Supported Environments
+
+Perl5.004 builds out of the box on Unix, Plan 9, LynxOS, VMS, OS/2,
+QNX, AmigaOS, and Windows NT. Perl runs on Windows 95 as well, but it
+cannot be built there, for lack of a reasonable command interpreter.
+
+=head1 Core Changes
+
+Most importantly, many bugs were fixed, including several security
+problems. See the F<Changes> file in the distribution for details.
+
+=head2 List assignment to %ENV works
+
+C<%ENV = ()> and C<%ENV = @list> now work as expected (except on VMS
+where it generates a fatal error).
+
+=head2 "Can't locate Foo.pm in @INC" error now lists @INC
+
+=head2 Compilation option: Binary compatibility with 5.003
+
+There is a new Configure question that asks if you want to maintain
+binary compatibility with Perl 5.003. If you choose binary
+compatibility, you do not have to recompile your extensions, but you
+might have symbol conflicts if you embed Perl in another application,
+just as in the 5.003 release. By default, binary compatibility
+is preserved at the expense of symbol table pollution.
+
+=head2 $PERL5OPT environment variable
+
+You may now put Perl options in the $PERL5OPT environment variable.
+Unless Perl is running with taint checks, it will interpret this
+variable as if its contents had appeared on a "#!perl" line at the
+beginning of your script, except that hyphens are optional. PERL5OPT
+may only be used to set the following switches: B<-[DIMUdmw]>.
+
+=head2 Limitations on B<-M>, B<-m>, and B<-T> options
+
+The C<-M> and C<-m> options are no longer allowed on the C<#!> line of
+a script. If a script needs a module, it should invoke it with the
+C<use> pragma.
+
+The B<-T> option is also forbidden on the C<#!> line of a script,
+unless it was present on the Perl command line. Due to the way C<#!>
+works, this usually means that B<-T> must be in the first argument.
+Thus:
+
+ #!/usr/bin/perl -T -w
+
+will probably work for an executable script invoked as C<scriptname>,
+while:
+
+ #!/usr/bin/perl -w -T
+
+will probably fail under the same conditions. (Non-Unix systems will
+probably not follow this rule.) But C<perl scriptname> is guaranteed
+to fail, since then there is no chance of B<-T> being found on the
+command line before it is found on the C<#!> line.
+
+=head2 More precise warnings
+
+If you removed the B<-w> option from your Perl 5.003 scripts because it
+made Perl too verbose, we recommend that you try putting it back when
+you upgrade to Perl 5.004. Each new perl version tends to remove some
+undesirable warnings, while adding new warnings that may catch bugs in
+your scripts.
+
+=head2 Deprecated: Inherited C<AUTOLOAD> for non-methods
+
+Before Perl 5.004, C<AUTOLOAD> functions were looked up as methods
+(using the C<@ISA> hierarchy), even when the function to be autoloaded
+was called as a plain function (e.g. C<Foo::bar()>), not a method
+(e.g. C<Foo-E<gt>bar()> or C<$obj-E<gt>bar()>).
+
+Perl 5.005 will use method lookup only for methods' C<AUTOLOAD>s.
+However, there is a significant base of existing code that may be using
+the old behavior. So, as an interim step, Perl 5.004 issues an optional
+warning when a non-method uses an inherited C<AUTOLOAD>.
+
+The simple rule is: Inheritance will not work when autoloading
+non-methods. The simple fix for old code is: In any module that used to
+depend on inheriting C<AUTOLOAD> for non-methods from a base class named
+C<BaseClass>, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup.
+
+=head2 Previously deprecated %OVERLOAD is no longer usable
+
+Using %OVERLOAD to define overloading was deprecated in 5.003.
+Overloading is now defined using the overload pragma. %OVERLOAD is
+still used internally but should not be used by Perl scripts. See
+L<overload> for more details.
+
+=head2 Subroutine arguments created only when they're modified
+
+In Perl 5.004, nonexistent array and hash elements used as subroutine
+parameters are brought into existence only if they are actually
+assigned to (via C<@_>).
+
+Earlier versions of Perl vary in their handling of such arguments.
+Perl versions 5.002 and 5.003 always brought them into existence.
+Perl versions 5.000 and 5.001 brought them into existence only if
+they were not the first argument (which was almost certainly a bug).
+Earlier versions of Perl never brought them into existence.
+
+For example, given this code:
+
+ undef @a; undef %a;
+ sub show { print $_[0] };
+ sub change { $_[0]++ };
+ show($a[2]);
+ change($a{b});
+
+After this code executes in Perl 5.004, $a{b} exists but $a[2] does
+not. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed
+(but $a[2]'s value would have been undefined).
+
+=head2 Group vector changeable with C<$)>
+
+The C<$)> special variable has always (well, in Perl 5, at least)
+reflected not only the current effective group, but also the group list
+as returned by the C<getgroups()> C function (if there is one).
+However, until this release, there has not been a way to call the
+C<setgroups()> C function from Perl.
+
+In Perl 5.004, assigning to C<$)> is exactly symmetrical with examining
+it: The first number in its string value is used as the effective gid;
+if there are any numbers after the first one, they are passed to the
+C<setgroups()> C function (if there is one).
+
+=head2 Fixed parsing of $$<digit>, &$<digit>, etc.
+
+Perl versions before 5.004 misinterpreted any type marker followed by
+"$" and a digit. For example, "$$0" was incorrectly taken to mean
+"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004.
+
+However, the developers of Perl 5.004 could not fix this bug completely,
+because at least two widely-used modules depend on the old meaning of
+"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the
+old (broken) way inside strings; but it generates this message as a
+warning. And in Perl 5.005, this special treatment will cease.
+
+=head2 Fixed localization of $<digit>, $&, etc.
+
+Perl versions before 5.004 did not always properly localize the
+regex-related special variables. Perl 5.004 does localize them, as
+the documentation has always said it should. This may result in $1,
+$2, etc. no longer being set where existing programs use them.
+
+=head2 No resetting of $. on implicit close
+
+The documentation for Perl 5.0 has always stated that C<$.> is I<not>
+reset when an already-open file handle is reopened with no intervening
+call to C<close>. Due to a bug, perl versions 5.000 through 5.003
+I<did> reset C<$.> under that circumstance; Perl 5.004 does not.
+
+=head2 C<wantarray> may return undef
+
+The C<wantarray> operator returns true if a subroutine is expected to
+return a list, and false otherwise. In Perl 5.004, C<wantarray> can
+also return the undefined value if a subroutine's return value will
+not be used at all, which allows subroutines to avoid a time-consuming
+calculation of a return value if it isn't going to be used.
+
+=head2 C<eval EXPR> determines value of EXPR in scalar context
+
+Perl (version 5) used to determine the value of EXPR inconsistently,
+sometimes incorrectly using the surrounding context for the determination.
+Now, the value of EXPR (before being parsed by eval) is always determined in
+a scalar context. Once parsed, it is executed as before, by providing
+the context that the scope surrounding the eval provided. This change
+makes the behavior Perl4 compatible, besides fixing bugs resulting from
+the inconsistent behavior. This program:
+
+ @a = qw(time now is time);
+ print eval @a;
+ print '|', scalar eval @a;
+
+used to print something like "timenowis881399109|4", but now (and in perl4)
+prints "4|4".
+
+=head2 Changes to tainting checks
+
+A bug in previous versions may have failed to detect some insecure
+conditions when taint checks are turned on. (Taint checks are used
+in setuid or setgid scripts, or when explicitly turned on with the
+C<-T> invocation option.) Although it's unlikely, this may cause a
+previously-working script to now fail -- which should be construed
+as a blessing, since that indicates a potentially-serious security
+hole was just plugged.
+
+The new restrictions when tainting include:
+
+=over
+
+=item No glob() or <*>
+
+These operators may spawn the C shell (csh), which cannot be made
+safe. This restriction will be lifted in a future version of Perl
+when globbing is implemented without the use of an external program.
+
+=item No spawning if tainted $CDPATH, $ENV, $BASH_ENV
+
+These environment variables may alter the behavior of spawned programs
+(especially shells) in ways that subvert security. So now they are
+treated as dangerous, in the manner of $IFS and $PATH.
+
+=item No spawning if tainted $TERM doesn't look like a terminal name
+
+Some termcap libraries do unsafe things with $TERM. However, it would be
+unnecessarily harsh to treat all $TERM values as unsafe, since only shell
+metacharacters can cause trouble in $TERM. So a tainted $TERM is
+considered to be safe if it contains only alphanumerics, underscores,
+dashes, and colons, and unsafe if it contains other characters (including
+whitespace).
+
+=back
+
+=head2 New Opcode module and revised Safe module
+
+A new Opcode module supports the creation, manipulation and
+application of opcode masks. The revised Safe module has a new API
+and is implemented using the new Opcode module. Please read the new
+Opcode and Safe documentation.
+
+=head2 Embedding improvements
+
+In older versions of Perl it was not possible to create more than one
+Perl interpreter instance inside a single process without leaking like a
+sieve and/or crashing. The bugs that caused this behavior have all been
+fixed. However, you still must take care when embedding Perl in a C
+program. See the updated perlembed manpage for tips on how to manage
+your interpreters.
+
+=head2 Internal change: FileHandle class based on IO::* classes
+
+File handles are now stored internally as type IO::Handle. The
+FileHandle module is still supported for backwards compatibility, but
+it is now merely a front end to the IO::* modules -- specifically,
+IO::Handle, IO::Seekable, and IO::File. We suggest, but do not
+require, that you use the IO::* modules in new code.
+
+In harmony with this change, C<*GLOB{FILEHANDLE}> is now just a
+backward-compatible synonym for C<*GLOB{IO}>.
+
+=head2 Internal change: PerlIO abstraction interface
+
+It is now possible to build Perl with AT&T's sfio IO package
+instead of stdio. See L<perlapio> for more details, and
+the F<INSTALL> file for how to use it.
+
+=head2 New and changed syntax
+
+=over
+
+=item $coderef->(PARAMS)
+
+A subroutine reference may now be suffixed with an arrow and a
+(possibly empty) parameter list. This syntax denotes a call of the
+referenced subroutine, with the given parameters (if any).
+
+This new syntax follows the pattern of S<C<$hashref-E<gt>{FOO}>> and
+S<C<$aryref-E<gt>[$foo]>>: You may now write S<C<&$subref($foo)>> as
+S<C<$subref-E<gt>($foo)>>. All of these arrow terms may be chained;
+thus, S<C<&{$table-E<gt>{FOO}}($bar)>> may now be written
+S<C<$table-E<gt>{FOO}-E<gt>($bar)>>.
+
+=back
+
+=head2 New and changed builtin constants
+
+=over
+
+=item __PACKAGE__
+
+The current package name at compile time, or the undefined value if
+there is no current package (due to a C<package;> directive). Like
+C<__FILE__> and C<__LINE__>, C<__PACKAGE__> does I<not> interpolate
+into strings.
+
+=back
+
+=head2 New and changed builtin variables
+
+=over
+
+=item $^E
+
+Extended error message on some platforms. (Also known as
+$EXTENDED_OS_ERROR if you C<use English>).
+
+=item $^H
+
+The current set of syntax checks enabled by C<use strict>. See the
+documentation of C<strict> for more details. Not actually new, but
+newly documented.
+Because it is intended for internal use by Perl core components,
+there is no C<use English> long name for this variable.
+
+=item $^M
+
+By default, running out of memory it is not trappable. However, if
+compiled for this, Perl may use the contents of C<$^M> as an emergency
+pool after die()ing with this message. Suppose that your Perl were
+compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. Then
+
+ $^M = 'a' x (1<<16);
+
+would allocate a 64K buffer for use when in emergency.
+See the F<INSTALL> file for information on how to enable this option.
+As a disincentive to casual use of this advanced feature,
+there is no C<use English> long name for this variable.
+
+=back
+
+=head2 New and changed builtin functions
+
+=over
+
+=item delete on slices
+
+This now works. (e.g. C<delete @ENV{'PATH', 'MANPATH'}>)
+
+=item flock
+
+is now supported on more platforms, prefers fcntl to lockf when
+emulating, and always flushes before (un)locking.
+
+=item printf and sprintf
+
+Perl now implements these functions itself; it doesn't use the C
+library function sprintf() any more, except for floating-point
+numbers, and even then only known flags are allowed. As a result, it
+is now possible to know which conversions and flags will work, and
+what they will do.
+
+The new conversions in Perl's sprintf() are:
+
+ %i a synonym for %d
+ %p a pointer (the address of the Perl value, in hexadecimal)
+ %n special: *stores* the number of characters output so far
+ into the next variable in the parameter list
+
+The new flags that go between the C<%> and the conversion are:
+
+ # prefix octal with "0", hex with "0x"
+ h interpret integer as C type "short" or "unsigned short"
+ V interpret integer as Perl's standard integer type
+
+Also, where a number would appear in the flags, an asterisk ("*") may
+be used instead, in which case Perl uses the next item in the
+parameter list as the given number (that is, as the field width or
+precision). If a field width obtained through "*" is negative, it has
+the same effect as the '-' flag: left-justification.
+
+See L<perlfunc/sprintf> for a complete list of conversion and flags.
+
+=item keys as an lvalue
+
+As an lvalue, C<keys> allows you to increase the number of hash buckets
+allocated for the given hash. This can gain you a measure of efficiency if
+you know the hash is going to get big. (This is similar to pre-extending
+an array by assigning a larger number to $#array.) If you say
+
+ keys %hash = 200;
+
+then C<%hash> will have at least 200 buckets allocated for it. These
+buckets will be retained even if you do C<%hash = ()>; use C<undef
+%hash> if you want to free the storage while C<%hash> is still in scope.
+You can't shrink the number of buckets allocated for the hash using
+C<keys> in this way (but you needn't worry about doing this by accident,
+as trying has no effect).
+
+=item my() in Control Structures
+
+You can now use my() (with or without the parentheses) in the control
+expressions of control structures such as:
+
+ while (defined(my $line = <>)) {
+ $line = lc $line;
+ } continue {
+ print $line;
+ }
+
+ if ((my $answer = <STDIN>) =~ /^y(es)?$/i) {
+ user_agrees();
+ } elsif ($answer =~ /^n(o)?$/i) {
+ user_disagrees();
+ } else {
+ chomp $answer;
+ die "`$answer' is neither `yes' nor `no'";
+ }
+
+Also, you can declare a foreach loop control variable as lexical by
+preceding it with the word "my". For example, in:
+
+ foreach my $i (1, 2, 3) {
+ some_function();
+ }
+
+$i is a lexical variable, and the scope of $i extends to the end of
+the loop, but not beyond it.
+
+Note that you still cannot use my() on global punctuation variables
+such as $_ and the like.
+
+=item pack() and unpack()
+
+A new format 'w' represents a BER compressed integer (as defined in
+ASN.1). Its format is a sequence of one or more bytes, each of which
+provides seven bits of the total value, with the most significant
+first. Bit eight of each byte is set, except for the last byte, in
+which bit eight is clear.
+
+If 'p' or 'P' are given undef as values, they now generate a NULL
+pointer.
+
+Both pack() and unpack() now fail when their templates contain invalid
+types. (Invalid types used to be ignored.)
+
+=item sysseek()
+
+The new sysseek() operator is a variant of seek() that sets and gets the
+file's system read/write position, using the lseek(2) system call. It is
+the only reliable way to seek before using sysread() or syswrite(). Its
+return value is the new position, or the undefined value on failure.
+
+=item use VERSION
+
+If the first argument to C<use> is a number, it is treated as a version
+number instead of a module name. If the version of the Perl interpreter
+is less than VERSION, then an error message is printed and Perl exits
+immediately. Because C<use> occurs at compile time, this check happens
+immediately during the compilation process, unlike C<require VERSION>,
+which waits until runtime for the check. This is often useful if you
+need to check the current Perl version before C<use>ing library modules
+which have changed in incompatible ways from older versions of Perl.
+(We try not to do this more than we have to.)
+
+=item use Module VERSION LIST
+
+If the VERSION argument is present between Module and LIST, then the
+C<use> will call the VERSION method in class Module with the given
+version as an argument. The default VERSION method, inherited from
+the UNIVERSAL class, croaks if the given version is larger than the
+value of the variable $Module::VERSION. (Note that there is not a
+comma after VERSION!)
+
+This version-checking mechanism is similar to the one currently used
+in the Exporter module, but it is faster and can be used with modules
+that don't use the Exporter. It is the recommended method for new
+code.
+
+=item prototype(FUNCTION)
+
+Returns the prototype of a function as a string (or C<undef> if the
+function has no prototype). FUNCTION is a reference to or the name of the
+function whose prototype you want to retrieve.
+(Not actually new; just never documented before.)
+
+=item srand
+
+The default seed for C<srand>, which used to be C<time>, has been changed.
+Now it's a heady mix of difficult-to-predict system-dependent values,
+which should be sufficient for most everyday purposes.
+
+Previous to version 5.004, calling C<rand> without first calling C<srand>
+would yield the same sequence of random numbers on most or all machines.
+Now, when perl sees that you're calling C<rand> and haven't yet called
+C<srand>, it calls C<srand> with the default seed. You should still call
+C<srand> manually if your code might ever be run on a pre-5.004 system,
+of course, or if you want a seed other than the default.
+
+=item $_ as Default
+
+Functions documented in the Camel to default to $_ now in
+fact do, and all those that do are so documented in L<perlfunc>.
+
+=item C<m//gc> does not reset search position on failure
+
+The C<m//g> match iteration construct has always reset its target
+string's search position (which is visible through the C<pos> operator)
+when a match fails; as a result, the next C<m//g> match after a failure
+starts again at the beginning of the string. With Perl 5.004, this
+reset may be disabled by adding the "c" (for "continue") modifier,
+i.e. C<m//gc>. This feature, in conjunction with the C<\G> zero-width
+assertion, makes it possible to chain matches together. See L<perlop>
+and L<perlre>.
+
+=item C<m//x> ignores whitespace before ?*+{}
+
+The C<m//x> construct has always been intended to ignore all unescaped
+whitespace. However, before Perl 5.004, whitespace had the effect of
+escaping repeat modifiers like "*" or "?"; for example, C</a *b/x> was
+(mis)interpreted as C</a\*b/x>. This bug has been fixed in 5.004.
+
+=item nested C<sub{}> closures work now
+
+Prior to the 5.004 release, nested anonymous functions didn't work
+right. They do now.
+
+=item formats work right on changing lexicals
+
+Just like anonymous functions that contain lexical variables
+that change (like a lexical index variable for a C<foreach> loop),
+formats now work properly. For example, this silently failed
+before (printed only zeros), but is fine now:
+
+ my $i;
+ foreach $i ( 1 .. 10 ) {
+ write;
+ }
+ format =
+ my i is @#
+ $i
+ .
+
+However, it still fails (without a warning) if the foreach is within a
+subroutine:
+
+ my $i;
+ sub foo {
+ foreach $i ( 1 .. 10 ) {
+ write;
+ }
+ }
+ foo;
+ format =
+ my i is @#
+ $i
+ .
+
+=back
+
+=head2 New builtin methods
+
+The C<UNIVERSAL> package automatically contains the following methods that
+are inherited by all other classes:
+
+=over
+
+=item isa(CLASS)
+
+C<isa> returns I<true> if its object is blessed into a subclass of C<CLASS>
+
+C<isa> is also exportable and can be called as a sub with two arguments. This
+allows the ability to check what a reference points to. Example:
+
+ use UNIVERSAL qw(isa);
+
+ if(isa($ref, 'ARRAY')) {
+ ...
+ }
+
+=item can(METHOD)
+
+C<can> checks to see if its object has a method called C<METHOD>,
+if it does then a reference to the sub is returned; if it does not then
+I<undef> is returned.
+
+=item VERSION( [NEED] )
+
+C<VERSION> returns the version number of the class (package). If the
+NEED argument is given then it will check that the current version (as
+defined by the $VERSION variable in the given package) not less than
+NEED; it will die if this is not the case. This method is normally
+called as a class method. This method is called automatically by the
+C<VERSION> form of C<use>.
+
+ use A 1.2 qw(some imported subs);
+ # implies:
+ A->VERSION(1.2);
+
+=back
+
+B<NOTE:> C<can> directly uses Perl's internal code for method lookup, and
+C<isa> uses a very similar method and caching strategy. This may cause
+strange effects if the Perl code dynamically changes @ISA in any package.
+
+You may add other methods to the UNIVERSAL class via Perl or XS code.
+You do not need to C<use UNIVERSAL> in order to make these methods
+available to your program. This is necessary only if you wish to
+have C<isa> available as a plain subroutine in the current package.
+
+=head2 TIEHANDLE now supported
+
+See L<perltie> for other kinds of tie()s.
+
+=over
+
+=item TIEHANDLE classname, LIST
+
+This is the constructor for the class. That means it is expected to
+return an object of some sort. The reference can be used to
+hold some internal information.
+
+ sub TIEHANDLE {
+ print "<shout>\n";
+ my $i;
+ return bless \$i, shift;
+ }
+
+=item PRINT this, LIST
+
+This method will be triggered every time the tied handle is printed to.
+Beyond its self reference it also expects the list that was passed to
+the print function.
+
+ sub PRINT {
+ $r = shift;
+ $$r++;
+ return print join( $, => map {uc} @_), $\;
+ }
+
+=item PRINTF this, LIST
+
+This method will be triggered every time the tied handle is printed to
+with the C<printf()> function.
+Beyond its self reference it also expects the format and list that was
+passed to the printf function.
+
+ sub PRINTF {
+ shift;
+ my $fmt = shift;
+ print sprintf($fmt, @_)."\n";
+ }
+
+=item READ this LIST
+
+This method will be called when the handle is read from via the C<read>
+or C<sysread> functions.
+
+ sub READ {
+ $r = shift;
+ my($buf,$len,$offset) = @_;
+ print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
+ }
+
+=item READLINE this
+
+This method will be called when the handle is read from. The method
+should return undef when there is no more data.
+
+ sub READLINE {
+ $r = shift;
+ return "PRINT called $$r times\n"
+ }
+
+=item GETC this
+
+This method will be called when the C<getc> function is called.
+
+ sub GETC { print "Don't GETC, Get Perl"; return "a"; }
+
+=item DESTROY this
+
+As with the other types of ties, this method will be called when the
+tied handle is about to be destroyed. This is useful for debugging and
+possibly for cleaning up.
+
+ sub DESTROY {
+ print "</shout>\n";
+ }
+
+=back
+
+=head2 Malloc enhancements
+
+If perl is compiled with the malloc included with the perl distribution
+(that is, if C<perl -V:d_mymalloc> is 'define') then you can print
+memory statistics at runtime by running Perl thusly:
+
+ env PERL_DEBUG_MSTATS=2 perl your_script_here
+
+The value of 2 means to print statistics after compilation and on
+exit; with a value of 1, the statistics are printed only on exit.
+(If you want the statistics at an arbitrary time, you'll need to
+install the optional module Devel::Peek.)
+
+Three new compilation flags are recognized by malloc.c. (They have no
+effect if perl is compiled with system malloc().)
+
+=over
+
+=item -DPERL_EMERGENCY_SBRK
+
+If this macro is defined, running out of memory need not be a fatal
+error: a memory pool can allocated by assigning to the special
+variable C<$^M>. See L<"$^M">.
+
+=item -DPACK_MALLOC
+
+Perl memory allocation is by bucket with sizes close to powers of two.
+Because of these malloc overhead may be big, especially for data of
+size exactly a power of two. If C<PACK_MALLOC> is defined, perl uses
+a slightly different algorithm for small allocations (up to 64 bytes
+long), which makes it possible to have overhead down to 1 byte for
+allocations which are powers of two (and appear quite often).
+
+Expected memory savings (with 8-byte alignment in C<alignbytes>) is
+about 20% for typical Perl usage. Expected slowdown due to additional
+malloc overhead is in fractions of a percent (hard to measure, because
+of the effect of saved memory on speed).
+
+=item -DTWO_POT_OPTIMIZE
+
+Similarly to C<PACK_MALLOC>, this macro improves allocations of data
+with size close to a power of two; but this works for big allocations
+(starting with 16K by default). Such allocations are typical for big
+hashes and special-purpose scripts, especially image processing.
+
+On recent systems, the fact that perl requires 2M from system for 1M
+allocation will not affect speed of execution, since the tail of such
+a chunk is not going to be touched (and thus will not require real
+memory). However, it may result in a premature out-of-memory error.
+So if you will be manipulating very large blocks with sizes close to
+powers of two, it would be wise to define this macro.
+
+Expected saving of memory is 0-100% (100% in applications which
+require most memory in such 2**n chunks); expected slowdown is
+negligible.
+
+=back
+
+=head2 Miscellaneous efficiency enhancements
+
+Functions that have an empty prototype and that do nothing but return
+a fixed value are now inlined (e.g. C<sub PI () { 3.14159 }>).
+
+Each unique hash key is only allocated once, no matter how many hashes
+have an entry with that key. So even if you have 100 copies of the
+same hash, the hash keys never have to be reallocated.
+
+=head1 Support for More Operating Systems
+
+Support for the following operating systems is new in Perl 5.004.
+
+=head2 Win32
+
+Perl 5.004 now includes support for building a "native" perl under
+Windows NT, using the Microsoft Visual C++ compiler (versions 2.0
+and above) or the Borland C++ compiler (versions 5.02 and above).
+The resulting perl can be used under Windows 95 (if it
+is installed in the same directory locations as it got installed
+in Windows NT). This port includes support for perl extension
+building tools like L<MakeMaker> and L<h2xs>, so that many extensions
+available on the Comprehensive Perl Archive Network (CPAN) can now be
+readily built under Windows NT. See http://www.perl.com/ for more
+information on CPAN and F<README.win32> in the perl distribution for more
+details on how to get started with building this port.
+
+There is also support for building perl under the Cygwin32 environment.
+Cygwin32 is a set of GNU tools that make it possible to compile and run
+many UNIX programs under Windows NT by providing a mostly UNIX-like
+interface for compilation and execution. See F<README.cygwin32> in the
+perl distribution for more details on this port and how to obtain the
+Cygwin32 toolkit.
+
+=head2 Plan 9
+
+See F<README.plan9> in the perl distribution.
+
+=head2 QNX
+
+See F<README.qnx> in the perl distribution.
+
+=head2 AmigaOS
+
+See F<README.amigaos> in the perl distribution.
+
+=head1 Pragmata
+
+Six new pragmatic modules exist:
+
+=over
+
+=item use autouse MODULE => qw(sub1 sub2 sub3)
+
+Defers C<require MODULE> until someone calls one of the specified
+subroutines (which must be exported by MODULE). This pragma should be
+used with caution, and only when necessary.
+
+=item use blib
+
+=item use blib 'dir'
+
+Looks for MakeMaker-like I<'blib'> directory structure starting in
+I<dir> (or current directory) and working back up to five levels of
+parent directories.
+
+Intended for use on command line with B<-M> option as a way of testing
+arbitrary scripts against an uninstalled version of a package.
+
+=item use constant NAME => VALUE
+
+Provides a convenient interface for creating compile-time constants,
+See L<perlsub/"Constant Functions">.
+
+=item use locale
+
+Tells the compiler to enable (or disable) the use of POSIX locales for
+builtin operations.
+
+When C<use locale> is in effect, the current LC_CTYPE locale is used
+for regular expressions and case mapping; LC_COLLATE for string
+ordering; and LC_NUMERIC for numeric formating in printf and sprintf
+(but B<not> in print). LC_NUMERIC is always used in write, since
+lexical scoping of formats is problematic at best.
+
+Each C<use locale> or C<no locale> affects statements to the end of
+the enclosing BLOCK or, if not inside a BLOCK, to the end of the
+current file. Locales can be switched and queried with
+POSIX::setlocale().
+
+See L<perllocale> for more information.
+
+=item use ops
+
+Disable unsafe opcodes, or any named opcodes, when compiling Perl code.
+
+=item use vmsish
+
+Enable VMS-specific language features. Currently, there are three
+VMS-specific features available: 'status', which makes C<$?> and
+C<system> return genuine VMS status values instead of emulating POSIX;
+'exit', which makes C<exit> take a genuine VMS status value instead of
+assuming that C<exit 1> is an error; and 'time', which makes all times
+relative to the local time zone, in the VMS tradition.
+
+=back
+
+=head1 Modules
+
+=head2 Required Updates
+
+Though Perl 5.004 is compatible with almost all modules that work
+with Perl 5.003, there are a few exceptions:
+
+ Module Required Version for Perl 5.004
+ ------ -------------------------------
+ Filter Filter-1.12
+ LWP libwww-perl-5.08
+ Tk Tk400.202 (-w makes noise)
+
+Also, the majordomo mailing list program, version 1.94.1, doesn't work
+with Perl 5.004 (nor with perl 4), because it executes an invalid
+regular expression. This bug is fixed in majordomo version 1.94.2.
+
+=head2 Installation directories
+
+The I<installperl> script now places the Perl source files for
+extensions in the architecture-specific library directory, which is
+where the shared libraries for extensions have always been. This
+change is intended to allow administrators to keep the Perl 5.004
+library directory unchanged from a previous version, without running
+the risk of binary incompatibility between extensions' Perl source and
+shared libraries.
+
+=head2 Module information summary
+
+Brand new modules, arranged by topic rather than strictly
+alphabetically:
+
+ CGI.pm Web server interface ("Common Gateway Interface")
+ CGI/Apache.pm Support for Apache's Perl module
+ CGI/Carp.pm Log server errors with helpful context
+ CGI/Fast.pm Support for FastCGI (persistent server process)
+ CGI/Push.pm Support for server push
+ CGI/Switch.pm Simple interface for multiple server types
+
+ CPAN Interface to Comprehensive Perl Archive Network
+ CPAN::FirstTime Utility for creating CPAN configuration file
+ CPAN::Nox Runs CPAN while avoiding compiled extensions
+
+ IO.pm Top-level interface to IO::* classes
+ IO/File.pm IO::File extension Perl module
+ IO/Handle.pm IO::Handle extension Perl module
+ IO/Pipe.pm IO::Pipe extension Perl module
+ IO/Seekable.pm IO::Seekable extension Perl module
+ IO/Select.pm IO::Select extension Perl module
+ IO/Socket.pm IO::Socket extension Perl module
+
+ Opcode.pm Disable named opcodes when compiling Perl code
+
+ ExtUtils/Embed.pm Utilities for embedding Perl in C programs
+ ExtUtils/testlib.pm Fixes up @INC to use just-built extension
+
+ FindBin.pm Find path of currently executing program
+
+ Class/Struct.pm Declare struct-like datatypes as Perl classes
+ File/stat.pm By-name interface to Perl's builtin stat
+ Net/hostent.pm By-name interface to Perl's builtin gethost*
+ Net/netent.pm By-name interface to Perl's builtin getnet*
+ Net/protoent.pm By-name interface to Perl's builtin getproto*
+ Net/servent.pm By-name interface to Perl's builtin getserv*
+ Time/gmtime.pm By-name interface to Perl's builtin gmtime
+ Time/localtime.pm By-name interface to Perl's builtin localtime
+ Time/tm.pm Internal object for Time::{gm,local}time
+ User/grent.pm By-name interface to Perl's builtin getgr*
+ User/pwent.pm By-name interface to Perl's builtin getpw*
+
+ Tie/RefHash.pm Base class for tied hashes with references as keys
+
+ UNIVERSAL.pm Base class for *ALL* classes
+
+=head2 Fcntl
+
+New constants in the existing Fcntl modules are now supported,
+provided that your operating system happens to support them:
+
+ F_GETOWN F_SETOWN
+ O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
+ O_EXLOCK O_SHLOCK
+
+These constants are intended for use with the Perl operators sysopen()
+and fcntl() and the basic database modules like SDBM_File. For the
+exact meaning of these and other Fcntl constants please refer to your
+operating system's documentation for fcntl() and open().
+
+In addition, the Fcntl module now provides these constants for use
+with the Perl operator flock():
+
+ LOCK_SH LOCK_EX LOCK_NB LOCK_UN
+
+These constants are defined in all environments (because where there is
+no flock() system call, Perl emulates it). However, for historical
+reasons, these constants are not exported unless they are explicitly
+requested with the ":flock" tag (e.g. C<use Fcntl ':flock'>).
+
+=head2 IO
+
+The IO module provides a simple mechanism to load all of the IO modules at one
+go. Currently this includes:
+
+ IO::Handle
+ IO::Seekable
+ IO::File
+ IO::Pipe
+ IO::Socket
+
+For more information on any of these modules, please see its
+respective documentation.
+
+=head2 Math::Complex
+
+The Math::Complex module has been totally rewritten, and now supports
+more operations. These are overloaded:
+
+ + - * / ** <=> neg ~ abs sqrt exp log sin cos atan2 "" (stringify)
+
+And these functions are now exported:
+
+ pi i Re Im arg
+ log10 logn ln cbrt root
+ tan
+ csc sec cot
+ asin acos atan
+ acsc asec acot
+ sinh cosh tanh
+ csch sech coth
+ asinh acosh atanh
+ acsch asech acoth
+ cplx cplxe
+
+=head2 Math::Trig
+
+This new module provides a simpler interface to parts of Math::Complex for
+those who need trigonometric functions only for real numbers.
+
+=head2 DB_File
+
+There have been quite a few changes made to DB_File. Here are a few of
+the highlights:
+
+=over
+
+=item *
+
+Fixed a handful of bugs.
+
+=item *
+
+By public demand, added support for the standard hash function exists().
+
+=item *
+
+Made it compatible with Berkeley DB 1.86.
+
+=item *
+
+Made negative subscripts work with RECNO interface.
+
+=item *
+
+Changed the default flags from O_RDWR to O_CREAT|O_RDWR and the default
+mode from 0640 to 0666.
+
+=item *
+
+Made DB_File automatically import the open() constants (O_RDWR,
+O_CREAT etc.) from Fcntl, if available.
+
+=item *
+
+Updated documentation.
+
+=back
+
+Refer to the HISTORY section in DB_File.pm for a complete list of
+changes. Everything after DB_File 1.01 has been added since 5.003.
+
+=head2 Net::Ping
+
+Major rewrite - support added for both udp echo and real icmp pings.
+
+=head2 Object-oriented overrides for builtin operators
+
+Many of the Perl builtins returning lists now have
+object-oriented overrides. These are:
+
+ File::stat
+ Net::hostent
+ Net::netent
+ Net::protoent
+ Net::servent
+ Time::gmtime
+ Time::localtime
+ User::grent
+ User::pwent
+
+For example, you can now say
+
+ use File::stat;
+ use User::pwent;
+ $his = (stat($filename)->st_uid == pwent($whoever)->pw_uid);
+
+=head1 Utility Changes
+
+=head2 pod2html
+
+=over
+
+=item Sends converted HTML to standard output
+
+The I<pod2html> utility included with Perl 5.004 is entirely new.
+By default, it sends the converted HTML to its standard output,
+instead of writing it to a file like Perl 5.003's I<pod2html> did.
+Use the B<--outfile=FILENAME> option to write to a file.
+
+=back
+
+=head2 xsubpp
+
+=over
+
+=item C<void> XSUBs now default to returning nothing
+
+Due to a documentation/implementation bug in previous versions of
+Perl, XSUBs with a return type of C<void> have actually been
+returning one value. Usually that value was the GV for the XSUB,
+but sometimes it was some already freed or reused value, which would
+sometimes lead to program failure.
+
+In Perl 5.004, if an XSUB is declared as returning C<void>, it
+actually returns no value, i.e. an empty list (though there is a
+backward-compatibility exception; see below). If your XSUB really
+does return an SV, you should give it a return type of C<SV *>.
+
+For backward compatibility, I<xsubpp> tries to guess whether a
+C<void> XSUB is really C<void> or if it wants to return an C<SV *>.
+It does so by examining the text of the XSUB: if I<xsubpp> finds
+what looks like an assignment to C<ST(0)>, it assumes that the
+XSUB's return type is really C<SV *>.
+
+=back
+
+=head1 C Language API Changes
+
+=over
+
+=item C<gv_fetchmethod> and C<perl_call_sv>
+
+The C<gv_fetchmethod> function finds a method for an object, just like
+in Perl 5.003. The GV it returns may be a method cache entry.
+However, in Perl 5.004, method cache entries are not visible to users;
+therefore, they can no longer be passed directly to C<perl_call_sv>.
+Instead, you should use the C<GvCV> macro on the GV to extract its CV,
+and pass the CV to C<perl_call_sv>.
+
+The most likely symptom of passing the result of C<gv_fetchmethod> to
+C<perl_call_sv> is Perl's producing an "Undefined subroutine called"
+error on the I<second> call to a given method (since there is no cache
+on the first call).
+
+=item C<perl_eval_pv>
+
+A new function handy for eval'ing strings of Perl code inside C code.
+This function returns the value from the eval statement, which can
+be used instead of fetching globals from the symbol table. See
+L<perlguts>, L<perlembed> and L<perlcall> for details and examples.
+
+=item Extended API for manipulating hashes
+
+Internal handling of hash keys has changed. The old hashtable API is
+still fully supported, and will likely remain so. The additions to the
+API allow passing keys as C<SV*>s, so that C<tied> hashes can be given
+real scalars as keys rather than plain strings (nontied hashes still
+can only use strings as keys). New extensions must use the new hash
+access functions and macros if they wish to use C<SV*> keys. These
+additions also make it feasible to manipulate C<HE*>s (hash entries),
+which can be more efficient. See L<perlguts> for details.
+
+=back
+
+=head1 Documentation Changes
+
+Many of the base and library pods were updated. These
+new pods are included in section 1:
+
+=over
+
+=item L<perldelta>
+
+This document.
+
+=item L<perlfaq>
+
+Frequently asked questions.
+
+=item L<perllocale>
+
+Locale support (internationalization and localization).
+
+=item L<perltoot>
+
+Tutorial on Perl OO programming.
+
+=item L<perlapio>
+
+Perl internal IO abstraction interface.
+
+=item L<perlmodlib>
+
+Perl module library and recommended practice for module creation.
+Extracted from L<perlmod> (which is much smaller as a result).
+
+=item L<perldebug>
+
+Although not new, this has been massively updated.
+
+=item L<perlsec>
+
+Although not new, this has been massively updated.
+
+=back
+
+=head1 New Diagnostics
+
+Several new conditions will trigger warnings that were
+silent before. Some only affect certain platforms.
+The following new warnings and errors outline these.
+These messages are classified as follows (listed in
+increasing order of desperation):
+
+ (W) A warning (optional).
+ (D) A deprecation (optional).
+ (S) A severe warning (mandatory).
+ (F) A fatal error (trappable).
+ (P) An internal error you should never see (trappable).
+ (X) A very fatal error (nontrappable).
+ (A) An alien error message (not generated by Perl).
+
+=over
+
+=item "my" variable %s masks earlier declaration in same scope
+
+(W) A lexical variable has been redeclared in the same scope, effectively
+eliminating all access to the previous instance. This is almost always
+a typographical error. Note that the earlier variable will still exist
+until the end of the scope or until all closure referents to it are
+destroyed.
+
+=item %s argument is not a HASH element or slice
+
+(F) The argument to delete() must be either a hash element, such as
+
+ $foo{$bar}
+ $ref->[12]->{"susie"}
+
+or a hash slice, such as
+
+ @foo{$bar, $baz, $xyzzy}
+ @{$ref->[12]}{"susie", "queue"}
+
+=item Allocation too large: %lx
+
+(X) You can't allocate more than 64K on an MS-DOS machine.
+
+=item Allocation too large
+
+(F) You can't allocate more than 2^31+"small amount" bytes.
+
+=item Applying %s to %s will act on scalar(%s)
+
+(W) The pattern match (//), substitution (s///), and transliteration (tr///)
+operators work on scalar values. If you apply one of them to an array
+or a hash, it will convert the array or hash to a scalar value -- the
+length of an array, or the population info of a hash -- and then work on
+that scalar value. This is probably not what you meant to do. See
+L<perlfunc/grep> and L<perlfunc/map> for alternatives.
+
+=item Attempt to free nonexistent shared string
+
+(P) Perl maintains a reference counted internal table of strings to
+optimize the storage and access of hash keys and other strings. This
+indicates someone tried to decrement the reference count of a string
+that can no longer be found in the table.
+
+=item Attempt to use reference as lvalue in substr
+
+(W) You supplied a reference as the first argument to substr() used
+as an lvalue, which is pretty strange. Perhaps you forgot to
+dereference it first. See L<perlfunc/substr>.
+
+=item Bareword "%s" refers to nonexistent package
+
+(W) You used a qualified bareword of the form C<Foo::>, but
+the compiler saw no other uses of that namespace before that point.
+Perhaps you need to predeclare a package?
+
+=item Can't redefine active sort subroutine %s
+
+(F) Perl optimizes the internal handling of sort subroutines and keeps
+pointers into them. You tried to redefine one such sort subroutine when it
+was currently active, which is not allowed. If you really want to do
+this, you should write C<sort { &func } @x> instead of C<sort func @x>.
+
+=item Can't use bareword ("%s") as %s ref while "strict refs" in use
+
+(F) Only hard references are allowed by "strict refs". Symbolic references
+are disallowed. See L<perlref>.
+
+=item Cannot resolve method `%s' overloading `%s' in package `%s'
+
+(P) Internal error trying to resolve overloading specified by a method
+name (as opposed to a subroutine reference).
+
+=item Constant subroutine %s redefined
+
+(S) You redefined a subroutine which had previously been eligible for
+inlining. See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Constant subroutine %s undefined
+
+(S) You undefined a subroutine which had previously been eligible for
+inlining. See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Copy method did not return a reference
+
+(F) The method which overloads "=" is buggy. See L<overload/Copy Constructor>.
+
+=item Died
+
+(F) You passed die() an empty string (the equivalent of C<die "">) or
+you called it with no args and both C<$@> and C<$_> were empty.
+
+=item Exiting pseudo-block via %s
+
+(W) You are exiting a rather special block construct (like a sort block or
+subroutine) by unconventional means, such as a goto, or a loop control
+statement. See L<perlfunc/sort>.
+
+=item Identifier too long
+
+(F) Perl limits identifiers (names for variables, functions, etc.) to
+252 characters for simple names, somewhat more for compound names (like
+C<$A::B>). You've exceeded Perl's limits. Future versions of Perl are
+likely to eliminate these arbitrary limitations.
+
+=item Illegal character %s (carriage return)
+
+(F) A carriage return character was found in the input. This is an
+error, and not a warning, because carriage return characters can break
+multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).
+
+=item Illegal switch in PERL5OPT: %s
+
+(X) The PERL5OPT environment variable may only be used to set the
+following switches: B<-[DIMUdmw]>.
+
+=item Integer overflow in hex number
+
+(S) The literal hex number you have specified is too big for your
+architecture. On a 32-bit architecture the largest hex literal is
+0xFFFFFFFF.
+
+=item Integer overflow in octal number
+
+(S) The literal octal number you have specified is too big for your
+architecture. On a 32-bit architecture the largest octal literal is
+037777777777.
+
+=item internal error: glob failed
+
+(P) Something went wrong with the external program(s) used for C<glob>
+and C<E<lt>*.cE<gt>>. This may mean that your csh (C shell) is
+broken. If so, you should change all of the csh-related variables in
+config.sh: If you have tcsh, make the variables refer to it as if it
+were csh (e.g. C<full_csh='/usr/bin/tcsh'>); otherwise, make them all
+empty (except that C<d_csh> should be C<'undef'>) so that Perl will
+think csh is missing. In either case, after editing config.sh, run
+C<./Configure -S> and rebuild Perl.
+
+=item Invalid conversion in %s: "%s"
+
+(W) Perl does not understand the given format conversion.
+See L<perlfunc/sprintf>.
+
+=item Invalid type in pack: '%s'
+
+(F) The given character is not a valid pack type. See L<perlfunc/pack>.
+
+=item Invalid type in unpack: '%s'
+
+(F) The given character is not a valid unpack type. See L<perlfunc/unpack>.
+
+=item Name "%s::%s" used only once: possible typo
+
+(W) Typographical errors often show up as unique variable names.
+If you had a good reason for having a unique name, then just mention
+it again somehow to suppress the message (the C<use vars> pragma is
+provided for just this purpose).
+
+=item Null picture in formline
+
+(F) The first argument to formline must be a valid format picture
+specification. It was found to be empty, which probably means you
+supplied it an uninitialized value. See L<perlform>.
+
+=item Offset outside string
+
+(F) You tried to do a read/write/send/recv operation with an offset
+pointing outside the buffer. This is difficult to imagine.
+The sole exception to this is that C<sysread()>ing past the buffer
+will extend the buffer and zero pad the new area.
+
+=item Out of memory!
+
+(X|F) The malloc() function returned 0, indicating there was insufficient
+remaining memory (or virtual memory) to satisfy the request.
+
+The request was judged to be small, so the possibility to trap it
+depends on the way Perl was compiled. By default it is not trappable.
+However, if compiled for this, Perl may use the contents of C<$^M> as
+an emergency pool after die()ing with this message. In this case the
+error is trappable I<once>.
+
+=item Out of memory during request for %s
+
+(F) The malloc() function returned 0, indicating there was insufficient
+remaining memory (or virtual memory) to satisfy the request. However,
+the request was judged large enough (compile-time default is 64K), so
+a possibility to shut down by trapping this error is granted.
+
+=item panic: frexp
+
+(P) The library function frexp() failed, making printf("%f") impossible.
+
+=item Possible attempt to put comments in qw() list
+
+(W) qw() lists contain items separated by whitespace; as with literal
+strings, comment characters are not ignored, but are instead treated
+as literal data. (You may have used different delimiters than the
+parentheses shown here; braces are also frequently used.)
+
+You probably wrote something like this:
+
+ @list = qw(
+ a # a comment
+ b # another comment
+ );
+
+when you should have written this:
+
+ @list = qw(
+ a
+ b
+ );
+
+If you really want comments, build your list the
+old-fashioned way, with quotes and commas:
+
+ @list = (
+ 'a', # a comment
+ 'b', # another comment
+ );
+
+=item Possible attempt to separate words with commas
+
+(W) qw() lists contain items separated by whitespace; therefore commas
+aren't needed to separate the items. (You may have used different
+delimiters than the parentheses shown here; braces are also frequently
+used.)
+
+You probably wrote something like this:
+
+ qw! a, b, c !;
+
+which puts literal commas into some of the list items. Write it without
+commas if you don't want them to appear in your data:
+
+ qw! a b c !;
+
+=item Scalar value @%s{%s} better written as $%s{%s}
+
+(W) You've used a hash slice (indicated by @) to select a single element of
+a hash. Generally it's better to ask for a scalar value (indicated by $).
+The difference is that C<$foo{&bar}> always behaves like a scalar, both when
+assigning to it and when evaluating its argument, while C<@foo{&bar}> behaves
+like a list when you assign to it, and provides a list context to its
+subscript, which can do weird things if you're expecting only one subscript.
+
+=item Stub found while resolving method `%s' overloading `%s' in package `%s'
+
+(P) Overloading resolution over @ISA tree may be broken by importing stubs.
+Stubs should never be implicitely created, but explicit calls to C<can>
+may break this.
+
+=item Too late for "B<-T>" option
+
+(X) The #! line (or local equivalent) in a Perl script contains the
+B<-T> option, but Perl was not invoked with B<-T> in its argument
+list. This is an error because, by the time Perl discovers a B<-T> in
+a script, it's too late to properly taint everything from the
+environment. So Perl gives up.
+
+=item untie attempted while %d inner references still exist
+
+(W) A copy of the object returned from C<tie> (or C<tied>) was still
+valid when C<untie> was called.
+
+=item Unrecognized character %s
+
+(F) The Perl parser has no idea what to do with the specified character
+in your Perl script (or eval). Perhaps you tried to run a compressed
+script, a binary program, or a directory as a Perl program.
+
+=item Unsupported function fork
+
+(F) Your version of executable does not support forking.
+
+Note that under some systems, like OS/2, there may be different flavors of
+Perl executables, some of which may support fork, some not. Try changing
+the name you call Perl by to C<perl_>, C<perl__>, and so on.
+
+=item Use of "$$<digit>" to mean "${$}<digit>" is deprecated
+
+(D) Perl versions before 5.004 misinterpreted any type marker followed
+by "$" and a digit. For example, "$$0" was incorrectly taken to mean
+"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004.
+
+However, the developers of Perl 5.004 could not fix this bug completely,
+because at least two widely-used modules depend on the old meaning of
+"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the
+old (broken) way inside strings; but it generates this message as a
+warning. And in Perl 5.005, this special treatment will cease.
+
+=item Value of %s can be "0"; test with defined()
+
+(W) In a conditional expression, you used <HANDLE>, <*> (glob), C<each()>,
+or C<readdir()> as a boolean value. Each of these constructs can return a
+value of "0"; that would make the conditional expression false, which is
+probably not what you intended. When using these constructs in conditional
+expressions, test their values with the C<defined> operator.
+
+=item Variable "%s" may be unavailable
+
+(W) An inner (nested) I<anonymous> subroutine is inside a I<named>
+subroutine, and outside that is another subroutine; and the anonymous
+(innermost) subroutine is referencing a lexical variable defined in
+the outermost subroutine. For example:
+
+ sub outermost { my $a; sub middle { sub { $a } } }
+
+If the anonymous subroutine is called or referenced (directly or
+indirectly) from the outermost subroutine, it will share the variable
+as you would expect. But if the anonymous subroutine is called or
+referenced when the outermost subroutine is not active, it will see
+the value of the shared variable as it was before and during the
+*first* call to the outermost subroutine, which is probably not what
+you want.
+
+In these circumstances, it is usually best to make the middle
+subroutine anonymous, using the C<sub {}> syntax. Perl has specific
+support for shared variables in nested anonymous subroutines; a named
+subroutine in between interferes with this feature.
+
+=item Variable "%s" will not stay shared
+
+(W) An inner (nested) I<named> subroutine is referencing a lexical
+variable defined in an outer subroutine.
+
+When the inner subroutine is called, it will probably see the value of
+the outer subroutine's variable as it was before and during the
+*first* call to the outer subroutine; in this case, after the first
+call to the outer subroutine is complete, the inner and outer
+subroutines will no longer share a common value for the variable. In
+other words, the variable will no longer be shared.
+
+Furthermore, if the outer subroutine is anonymous and references a
+lexical variable outside itself, then the outer and inner subroutines
+will I<never> share the given variable.
+
+This problem can usually be solved by making the inner subroutine
+anonymous, using the C<sub {}> syntax. When inner anonymous subs that
+reference variables in outer subroutines are called or referenced,
+they are automatically rebound to the current values of such
+variables.
+
+=item Warning: something's wrong
+
+(W) You passed warn() an empty string (the equivalent of C<warn "">) or
+you called it with no args and C<$_> was empty.
+
+=item Ill-formed logical name |%s| in prime_env_iter
+
+(W) A warning peculiar to VMS. A logical name was encountered when preparing
+to iterate over %ENV which violates the syntactic rules governing logical
+names. Since it cannot be translated normally, it is skipped, and will not
+appear in %ENV. This may be a benign occurrence, as some software packages
+might directly modify logical name tables and introduce nonstandard names,
+or it may indicate that a logical name table has been corrupted.
+
+=item Got an error from DosAllocMem
+
+(P) An error peculiar to OS/2. Most probably you're using an obsolete
+version of Perl, and this should not happen anyway.
+
+=item Malformed PERLLIB_PREFIX
+
+(F) An error peculiar to OS/2. PERLLIB_PREFIX should be of the form
+
+ prefix1;prefix2
+
+or
+
+ prefix1 prefix2
+
+with nonempty prefix1 and prefix2. If C<prefix1> is indeed a prefix
+of a builtin library search path, prefix2 is substituted. The error
+may appear if components are not found, or are too long. See
+"PERLLIB_PREFIX" in F<README.os2>.
+
+=item PERL_SH_DIR too long
+
+(F) An error peculiar to OS/2. PERL_SH_DIR is the directory to find the
+C<sh>-shell in. See "PERL_SH_DIR" in F<README.os2>.
+
+=item Process terminated by SIG%s
+
+(W) This is a standard message issued by OS/2 applications, while *nix
+applications die in silence. It is considered a feature of the OS/2
+port. One can easily disable this by appropriate sighandlers, see
+L<perlipc/"Signals">. See also "Process terminated by SIGTERM/SIGINT"
+in F<README.os2>.
+
+=back
+
+=head1 BUGS
+
+If you find what you think is a bug, you might check the headers of
+recently posted articles in the comp.lang.perl.misc newsgroup.
+There may also be information at http://www.perl.com/perl/, the Perl
+Home Page.
+
+If you believe you have an unreported bug, please run the B<perlbug>
+program included with your release. Make sure you trim your bug down
+to a tiny but sufficient test case. Your bug report, along with the
+output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
+analysed by the Perl porting team.
+
+=head1 SEE ALSO
+
+The F<Changes> file for exhaustive details on what changed.
+
+The F<INSTALL> file for how to build Perl. This file has been
+significantly updated for 5.004, so even veteran users should
+look through it.
+
+The F<README> file for general stuff.
+
+The F<Copying> file for copyright information.
+
+=head1 HISTORY
+
+Constructed by Tom Christiansen, grabbing material with permission
+from innumerable contributors, with kibitzing by more than a few Perl
+porters.
+
+Last update: Wed May 14 11:14:09 EDT 1997
diff --git a/contrib/perl5/pod/perlapio.pod b/contrib/perl5/pod/perlapio.pod
new file mode 100644
index 0000000..90475a9
--- /dev/null
+++ b/contrib/perl5/pod/perlapio.pod
@@ -0,0 +1,274 @@
+=head1 NAME
+
+perlapio - perl's IO abstraction interface.
+
+=head1 SYNOPSIS
+
+ PerlIO *PerlIO_stdin(void);
+ PerlIO *PerlIO_stdout(void);
+ PerlIO *PerlIO_stderr(void);
+
+ PerlIO *PerlIO_open(const char *,const char *);
+ int PerlIO_close(PerlIO *);
+
+ int PerlIO_stdoutf(const char *,...)
+ int PerlIO_puts(PerlIO *,const char *);
+ int PerlIO_putc(PerlIO *,int);
+ int PerlIO_write(PerlIO *,const void *,size_t);
+ int PerlIO_printf(PerlIO *, const char *,...);
+ int PerlIO_vprintf(PerlIO *, const char *, va_list);
+ int PerlIO_flush(PerlIO *);
+
+ int PerlIO_eof(PerlIO *);
+ int PerlIO_error(PerlIO *);
+ void PerlIO_clearerr(PerlIO *);
+
+ int PerlIO_getc(PerlIO *);
+ int PerlIO_ungetc(PerlIO *,int);
+ int PerlIO_read(PerlIO *,void *,size_t);
+
+ int PerlIO_fileno(PerlIO *);
+ PerlIO *PerlIO_fdopen(int, const char *);
+ PerlIO *PerlIO_importFILE(FILE *, int flags);
+ FILE *PerlIO_exportFILE(PerlIO *, int flags);
+ FILE *PerlIO_findFILE(PerlIO *);
+ void PerlIO_releaseFILE(PerlIO *,FILE *);
+
+ void PerlIO_setlinebuf(PerlIO *);
+
+ long PerlIO_tell(PerlIO *);
+ int PerlIO_seek(PerlIO *,off_t,int);
+ int PerlIO_getpos(PerlIO *,Fpos_t *)
+ int PerlIO_setpos(PerlIO *,Fpos_t *)
+ void PerlIO_rewind(PerlIO *);
+
+ int PerlIO_has_base(PerlIO *);
+ int PerlIO_has_cntptr(PerlIO *);
+ int PerlIO_fast_gets(PerlIO *);
+ int PerlIO_canset_cnt(PerlIO *);
+
+ char *PerlIO_get_ptr(PerlIO *);
+ int PerlIO_get_cnt(PerlIO *);
+ void PerlIO_set_cnt(PerlIO *,int);
+ void PerlIO_set_ptrcnt(PerlIO *,char *,int);
+ char *PerlIO_get_base(PerlIO *);
+ int PerlIO_get_bufsiz(PerlIO *);
+
+=head1 DESCRIPTION
+
+Perl's source code should use the above functions instead of those
+defined in ANSI C's I<stdio.h>. The perl headers will C<#define> them to
+the I/O mechanism selected at Configure time.
+
+The functions are modeled on those in I<stdio.h>, but parameter order
+has been "tidied up a little".
+
+=over 4
+
+=item B<PerlIO *>
+
+This takes the place of FILE *. Like FILE * it should be treated as
+opaque (it is probably safe to assume it is a pointer to something).
+
+=item B<PerlIO_stdin()>, B<PerlIO_stdout()>, B<PerlIO_stderr()>
+
+Use these rather than C<stdin>, C<stdout>, C<stderr>. They are written
+to look like "function calls" rather than variables because this makes
+it easier to I<make them> function calls if platform cannot export data
+to loaded modules, or if (say) different "threads" might have different
+values.
+
+=item B<PerlIO_open(path, mode)>, B<PerlIO_fdopen(fd,mode)>
+
+These correspond to fopen()/fdopen() arguments are the same.
+
+=item B<PerlIO_printf(f,fmt,...)>, B<PerlIO_vprintf(f,fmt,a)>
+
+These are fprintf()/vfprintf() equivalents.
+
+=item B<PerlIO_stdoutf(fmt,...)>
+
+This is printf() equivalent. printf is #defined to this function,
+so it is (currently) legal to use C<printf(fmt,...)> in perl sources.
+
+=item B<PerlIO_read(f,buf,count)>, B<PerlIO_write(f,buf,count)>
+
+These correspond to fread() and fwrite(). Note that arguments
+are different, there is only one "count" and order has
+"file" first.
+
+=item B<PerlIO_close(f)>
+
+=item B<PerlIO_puts(f,s)>, B<PerlIO_putc(f,c)>
+
+These correspond to fputs() and fputc().
+Note that arguments have been revised to have "file" first.
+
+=item B<PerlIO_ungetc(f,c)>
+
+This corresponds to ungetc().
+Note that arguments have been revised to have "file" first.
+
+=item B<PerlIO_getc(f)>
+
+This corresponds to getc().
+
+=item B<PerlIO_eof(f)>
+
+This corresponds to feof().
+
+=item B<PerlIO_error(f)>
+
+This corresponds to ferror().
+
+=item B<PerlIO_fileno(f)>
+
+This corresponds to fileno(), note that on some platforms,
+the meaning of "fileno" may not match Unix.
+
+=item B<PerlIO_clearerr(f)>
+
+This corresponds to clearerr(), i.e., clears 'eof' and 'error'
+flags for the "stream".
+
+=item B<PerlIO_flush(f)>
+
+This corresponds to fflush().
+
+=item B<PerlIO_tell(f)>
+
+This corresponds to ftell().
+
+=item B<PerlIO_seek(f,o,w)>
+
+This corresponds to fseek().
+
+=item B<PerlIO_getpos(f,p)>, B<PerlIO_setpos(f,p)>
+
+These correspond to fgetpos() and fsetpos(). If platform does not
+have the stdio calls then they are implemented in terms of PerlIO_tell()
+and PerlIO_seek().
+
+=item B<PerlIO_rewind(f)>
+
+This corresponds to rewind(). Note may be redefined
+in terms of PerlIO_seek() at some point.
+
+=item B<PerlIO_tmpfile()>
+
+This corresponds to tmpfile(), i.e., returns an anonymous
+PerlIO which will automatically be deleted when closed.
+
+=back
+
+=head2 Co-existence with stdio
+
+There is outline support for co-existence of PerlIO with stdio.
+Obviously if PerlIO is implemented in terms of stdio there is
+no problem. However if perlio is implemented on top of (say) sfio
+then mechanisms must exist to create a FILE * which can be passed
+to library code which is going to use stdio calls.
+
+=over 4
+
+=item B<PerlIO_importFILE(f,flags)>
+
+Used to get a PerlIO * from a FILE *.
+May need additional arguments, interface under review.
+
+=item B<PerlIO_exportFILE(f,flags)>
+
+Given an PerlIO * return a 'native' FILE * suitable for
+passing to code expecting to be compiled and linked with
+ANSI C I<stdio.h>.
+
+The fact that such a FILE * has been 'exported' is recorded,
+and may affect future PerlIO operations on the original
+PerlIO *.
+
+=item B<PerlIO_findFILE(f)>
+
+Returns previously 'exported' FILE * (if any).
+Place holder until interface is fully defined.
+
+=item B<PerlIO_releaseFILE(p,f)>
+
+Calling PerlIO_releaseFILE informs PerlIO that all use
+of FILE * is complete. It is removed from list of 'exported'
+FILE *s, and associated PerlIO * should revert to original
+behaviour.
+
+=item B<PerlIO_setlinebuf(f)>
+
+This corresponds to setlinebuf(). Use is deprecated pending
+further discussion. (Perl core uses it I<only> when "dumping";
+it has nothing to do with $| auto-flush.)
+
+=back
+
+In addition to user API above there is an "implementation" interface
+which allows perl to get at internals of PerlIO.
+The following calls correspond to the various FILE_xxx macros determined
+by Configure. This section is really of interest to only those
+concerned with detailed perl-core behaviour or implementing a
+PerlIO mapping.
+
+=over 4
+
+=item B<PerlIO_has_cntptr(f)>
+
+Implementation can return pointer to current position in the "buffer" and
+a count of bytes available in the buffer.
+
+=item B<PerlIO_get_ptr(f)>
+
+Return pointer to next readable byte in buffer.
+
+=item B<PerlIO_get_cnt(f)>
+
+Return count of readable bytes in the buffer.
+
+=item B<PerlIO_canset_cnt(f)>
+
+Implementation can adjust its idea of number of
+bytes in the buffer.
+
+=item B<PerlIO_fast_gets(f)>
+
+Implementation has all the interfaces required to
+allow perl's fast code to handle <FILE> mechanism.
+
+ PerlIO_fast_gets(f) = PerlIO_has_cntptr(f) && \
+ PerlIO_canset_cnt(f) && \
+ `Can set pointer into buffer'
+
+=item B<PerlIO_set_ptrcnt(f,p,c)>
+
+Set pointer into buffer, and a count of bytes still in the
+buffer. Should be used only to set
+pointer to within range implied by previous calls
+to C<PerlIO_get_ptr> and C<PerlIO_get_cnt>.
+
+=item B<PerlIO_set_cnt(f,c)>
+
+Obscure - set count of bytes in the buffer. Deprecated.
+Currently used in only doio.c to force count < -1 to -1.
+Perhaps should be PerlIO_set_empty or similar.
+This call may actually do nothing if "count" is deduced from pointer
+and a "limit".
+
+=item B<PerlIO_has_base(f)>
+
+Implementation has a buffer, and can return pointer
+to whole buffer and its size. Used by perl for B<-T> / B<-B> tests.
+Other uses would be very obscure...
+
+=item B<PerlIO_get_base(f)>
+
+Return I<start> of buffer.
+
+=item B<PerlIO_get_bufsiz(f)>
+
+Return I<total size> of buffer.
+
+=back
diff --git a/contrib/perl5/pod/perlbook.pod b/contrib/perl5/pod/perlbook.pod
new file mode 100644
index 0000000..76763cd
--- /dev/null
+++ b/contrib/perl5/pod/perlbook.pod
@@ -0,0 +1,16 @@
+=head1 NAME
+
+perlbook - Perl book information
+
+=head1 DESCRIPTION
+
+The Camel Book, officially known as I<Programming Perl, Second Edition>,
+by Larry Wall et al, is the definitive reference work covering nearly
+all of Perl. You can order it and other Perl books from O'Reilly &
+Associates, 1-800-998-9938. Local/overseas is +1 707 829 0515. If you
+can locate an O'Reilly order form, you can also fax to +1 707 829 0104.
+If you're web-connected, you can even mosey on over to http://www.ora.com/
+for an online order form.
+
+Other Perl books from various publishers and authors
+can be found listed in L<perlfaq3>.
diff --git a/contrib/perl5/pod/perlbot.pod b/contrib/perl5/pod/perlbot.pod
new file mode 100644
index 0000000..bc4e4da
--- /dev/null
+++ b/contrib/perl5/pod/perlbot.pod
@@ -0,0 +1,527 @@
+=head1 NAME
+
+perlbot - Bag'o Object Tricks (the BOT)
+
+=head1 DESCRIPTION
+
+The following collection of tricks and hints is intended to whet curious
+appetites about such things as the use of instance variables and the
+mechanics of object and class relationships. The reader is encouraged to
+consult relevant textbooks for discussion of Object Oriented definitions and
+methodology. This is not intended as a tutorial for object-oriented
+programming or as a comprehensive guide to Perl's object oriented features,
+nor should it be construed as a style guide.
+
+The Perl motto still holds: There's more than one way to do it.
+
+=head1 OO SCALING TIPS
+
+=over 5
+
+=item 1
+
+Do not attempt to verify the type of $self. That'll break if the class is
+inherited, when the type of $self is valid but its package isn't what you
+expect. See rule 5.
+
+=item 2
+
+If an object-oriented (OO) or indirect-object (IO) syntax was used, then the
+object is probably the correct type and there's no need to become paranoid
+about it. Perl isn't a paranoid language anyway. If people subvert the OO
+or IO syntax then they probably know what they're doing and you should let
+them do it. See rule 1.
+
+=item 3
+
+Use the two-argument form of bless(). Let a subclass use your constructor.
+See L<INHERITING A CONSTRUCTOR>.
+
+=item 4
+
+The subclass is allowed to know things about its immediate superclass, the
+superclass is allowed to know nothing about a subclass.
+
+=item 5
+
+Don't be trigger happy with inheritance. A "using", "containing", or
+"delegation" relationship (some sort of aggregation, at least) is often more
+appropriate. See L<OBJECT RELATIONSHIPS>, L<USING RELATIONSHIP WITH SDBM>,
+and L<"DELEGATION">.
+
+=item 6
+
+The object is the namespace. Make package globals accessible via the
+object. This will remove the guess work about the symbol's home package.
+See L<CLASS CONTEXT AND THE OBJECT>.
+
+=item 7
+
+IO syntax is certainly less noisy, but it is also prone to ambiguities that
+can cause difficult-to-find bugs. Allow people to use the sure-thing OO
+syntax, even if you don't like it.
+
+=item 8
+
+Do not use function-call syntax on a method. You're going to be bitten
+someday. Someone might move that method into a superclass and your code
+will be broken. On top of that you're feeding the paranoia in rule 2.
+
+=item 9
+
+Don't assume you know the home package of a method. You're making it
+difficult for someone to override that method. See L<THINKING OF CODE REUSE>.
+
+=back
+
+=head1 INSTANCE VARIABLES
+
+An anonymous array or anonymous hash can be used to hold instance
+variables. Named parameters are also demonstrated.
+
+ package Foo;
+
+ sub new {
+ my $type = shift;
+ my %params = @_;
+ my $self = {};
+ $self->{'High'} = $params{'High'};
+ $self->{'Low'} = $params{'Low'};
+ bless $self, $type;
+ }
+
+
+ package Bar;
+
+ sub new {
+ my $type = shift;
+ my %params = @_;
+ my $self = [];
+ $self->[0] = $params{'Left'};
+ $self->[1] = $params{'Right'};
+ bless $self, $type;
+ }
+
+ package main;
+
+ $a = Foo->new( 'High' => 42, 'Low' => 11 );
+ print "High=$a->{'High'}\n";
+ print "Low=$a->{'Low'}\n";
+
+ $b = Bar->new( 'Left' => 78, 'Right' => 40 );
+ print "Left=$b->[0]\n";
+ print "Right=$b->[1]\n";
+
+=head1 SCALAR INSTANCE VARIABLES
+
+An anonymous scalar can be used when only one instance variable is needed.
+
+ package Foo;
+
+ sub new {
+ my $type = shift;
+ my $self;
+ $self = shift;
+ bless \$self, $type;
+ }
+
+ package main;
+
+ $a = Foo->new( 42 );
+ print "a=$$a\n";
+
+
+=head1 INSTANCE VARIABLE INHERITANCE
+
+This example demonstrates how one might inherit instance variables from a
+superclass for inclusion in the new class. This requires calling the
+superclass's constructor and adding one's own instance variables to the new
+object.
+
+ package Bar;
+
+ sub new {
+ my $type = shift;
+ my $self = {};
+ $self->{'buz'} = 42;
+ bless $self, $type;
+ }
+
+ package Foo;
+ @ISA = qw( Bar );
+
+ sub new {
+ my $type = shift;
+ my $self = Bar->new;
+ $self->{'biz'} = 11;
+ bless $self, $type;
+ }
+
+ package main;
+
+ $a = Foo->new;
+ print "buz = ", $a->{'buz'}, "\n";
+ print "biz = ", $a->{'biz'}, "\n";
+
+
+
+=head1 OBJECT RELATIONSHIPS
+
+The following demonstrates how one might implement "containing" and "using"
+relationships between objects.
+
+ package Bar;
+
+ sub new {
+ my $type = shift;
+ my $self = {};
+ $self->{'buz'} = 42;
+ bless $self, $type;
+ }
+
+ package Foo;
+
+ sub new {
+ my $type = shift;
+ my $self = {};
+ $self->{'Bar'} = Bar->new;
+ $self->{'biz'} = 11;
+ bless $self, $type;
+ }
+
+ package main;
+
+ $a = Foo->new;
+ print "buz = ", $a->{'Bar'}->{'buz'}, "\n";
+ print "biz = ", $a->{'biz'}, "\n";
+
+
+
+=head1 OVERRIDING SUPERCLASS METHODS
+
+The following example demonstrates how to override a superclass method and
+then call the overridden method. The B<SUPER> pseudo-class allows the
+programmer to call an overridden superclass method without actually knowing
+where that method is defined.
+
+ package Buz;
+ sub goo { print "here's the goo\n" }
+
+ package Bar; @ISA = qw( Buz );
+ sub google { print "google here\n" }
+
+ package Baz;
+ sub mumble { print "mumbling\n" }
+
+ package Foo;
+ @ISA = qw( Bar Baz );
+
+ sub new {
+ my $type = shift;
+ bless [], $type;
+ }
+ sub grr { print "grumble\n" }
+ sub goo {
+ my $self = shift;
+ $self->SUPER::goo();
+ }
+ sub mumble {
+ my $self = shift;
+ $self->SUPER::mumble();
+ }
+ sub google {
+ my $self = shift;
+ $self->SUPER::google();
+ }
+
+ package main;
+
+ $foo = Foo->new;
+ $foo->mumble;
+ $foo->grr;
+ $foo->goo;
+ $foo->google;
+
+
+=head1 USING RELATIONSHIP WITH SDBM
+
+This example demonstrates an interface for the SDBM class. This creates a
+"using" relationship between the SDBM class and the new class Mydbm.
+
+ package Mydbm;
+
+ require SDBM_File;
+ require Tie::Hash;
+ @ISA = qw( Tie::Hash );
+
+ sub TIEHASH {
+ my $type = shift;
+ my $ref = SDBM_File->new(@_);
+ bless {'dbm' => $ref}, $type;
+ }
+ sub FETCH {
+ my $self = shift;
+ my $ref = $self->{'dbm'};
+ $ref->FETCH(@_);
+ }
+ sub STORE {
+ my $self = shift;
+ if (defined $_[0]){
+ my $ref = $self->{'dbm'};
+ $ref->STORE(@_);
+ } else {
+ die "Cannot STORE an undefined key in Mydbm\n";
+ }
+ }
+
+ package main;
+ use Fcntl qw( O_RDWR O_CREAT );
+
+ tie %foo, "Mydbm", "Sdbm", O_RDWR|O_CREAT, 0640;
+ $foo{'bar'} = 123;
+ print "foo-bar = $foo{'bar'}\n";
+
+ tie %bar, "Mydbm", "Sdbm2", O_RDWR|O_CREAT, 0640;
+ $bar{'Cathy'} = 456;
+ print "bar-Cathy = $bar{'Cathy'}\n";
+
+=head1 THINKING OF CODE REUSE
+
+One strength of Object-Oriented languages is the ease with which old code
+can use new code. The following examples will demonstrate first how one can
+hinder code reuse and then how one can promote code reuse.
+
+This first example illustrates a class which uses a fully-qualified method
+call to access the "private" method BAZ(). The second example will show
+that it is impossible to override the BAZ() method.
+
+ package FOO;
+
+ sub new {
+ my $type = shift;
+ bless {}, $type;
+ }
+ sub bar {
+ my $self = shift;
+ $self->FOO::private::BAZ;
+ }
+
+ package FOO::private;
+
+ sub BAZ {
+ print "in BAZ\n";
+ }
+
+ package main;
+
+ $a = FOO->new;
+ $a->bar;
+
+Now we try to override the BAZ() method. We would like FOO::bar() to call
+GOOP::BAZ(), but this cannot happen because FOO::bar() explicitly calls
+FOO::private::BAZ().
+
+ package FOO;
+
+ sub new {
+ my $type = shift;
+ bless {}, $type;
+ }
+ sub bar {
+ my $self = shift;
+ $self->FOO::private::BAZ;
+ }
+
+ package FOO::private;
+
+ sub BAZ {
+ print "in BAZ\n";
+ }
+
+ package GOOP;
+ @ISA = qw( FOO );
+ sub new {
+ my $type = shift;
+ bless {}, $type;
+ }
+
+ sub BAZ {
+ print "in GOOP::BAZ\n";
+ }
+
+ package main;
+
+ $a = GOOP->new;
+ $a->bar;
+
+To create reusable code we must modify class FOO, flattening class
+FOO::private. The next example shows a reusable class FOO which allows the
+method GOOP::BAZ() to be used in place of FOO::BAZ().
+
+ package FOO;
+
+ sub new {
+ my $type = shift;
+ bless {}, $type;
+ }
+ sub bar {
+ my $self = shift;
+ $self->BAZ;
+ }
+
+ sub BAZ {
+ print "in BAZ\n";
+ }
+
+ package GOOP;
+ @ISA = qw( FOO );
+
+ sub new {
+ my $type = shift;
+ bless {}, $type;
+ }
+ sub BAZ {
+ print "in GOOP::BAZ\n";
+ }
+
+ package main;
+
+ $a = GOOP->new;
+ $a->bar;
+
+=head1 CLASS CONTEXT AND THE OBJECT
+
+Use the object to solve package and class context problems. Everything a
+method needs should be available via the object or should be passed as a
+parameter to the method.
+
+A class will sometimes have static or global data to be used by the
+methods. A subclass may want to override that data and replace it with new
+data. When this happens the superclass may not know how to find the new
+copy of the data.
+
+This problem can be solved by using the object to define the context of the
+method. Let the method look in the object for a reference to the data. The
+alternative is to force the method to go hunting for the data ("Is it in my
+class, or in a subclass? Which subclass?"), and this can be inconvenient
+and will lead to hackery. It is better just to let the object tell the
+method where that data is located.
+
+ package Bar;
+
+ %fizzle = ( 'Password' => 'XYZZY' );
+
+ sub new {
+ my $type = shift;
+ my $self = {};
+ $self->{'fizzle'} = \%fizzle;
+ bless $self, $type;
+ }
+
+ sub enter {
+ my $self = shift;
+
+ # Don't try to guess if we should use %Bar::fizzle
+ # or %Foo::fizzle. The object already knows which
+ # we should use, so just ask it.
+ #
+ my $fizzle = $self->{'fizzle'};
+
+ print "The word is ", $fizzle->{'Password'}, "\n";
+ }
+
+ package Foo;
+ @ISA = qw( Bar );
+
+ %fizzle = ( 'Password' => 'Rumple' );
+
+ sub new {
+ my $type = shift;
+ my $self = Bar->new;
+ $self->{'fizzle'} = \%fizzle;
+ bless $self, $type;
+ }
+
+ package main;
+
+ $a = Bar->new;
+ $b = Foo->new;
+ $a->enter;
+ $b->enter;
+
+=head1 INHERITING A CONSTRUCTOR
+
+An inheritable constructor should use the second form of bless() which allows
+blessing directly into a specified class. Notice in this example that the
+object will be a BAR not a FOO, even though the constructor is in class FOO.
+
+ package FOO;
+
+ sub new {
+ my $type = shift;
+ my $self = {};
+ bless $self, $type;
+ }
+
+ sub baz {
+ print "in FOO::baz()\n";
+ }
+
+ package BAR;
+ @ISA = qw(FOO);
+
+ sub baz {
+ print "in BAR::baz()\n";
+ }
+
+ package main;
+
+ $a = BAR->new;
+ $a->baz;
+
+=head1 DELEGATION
+
+Some classes, such as SDBM_File, cannot be effectively subclassed because
+they create foreign objects. Such a class can be extended with some sort of
+aggregation technique such as the "using" relationship mentioned earlier or
+by delegation.
+
+The following example demonstrates delegation using an AUTOLOAD() function to
+perform message-forwarding. This will allow the Mydbm object to behave
+exactly like an SDBM_File object. The Mydbm class could now extend the
+behavior by adding custom FETCH() and STORE() methods, if this is desired.
+
+ package Mydbm;
+
+ require SDBM_File;
+ require Tie::Hash;
+ @ISA = qw(Tie::Hash);
+
+ sub TIEHASH {
+ my $type = shift;
+ my $ref = SDBM_File->new(@_);
+ bless {'delegate' => $ref};
+ }
+
+ sub AUTOLOAD {
+ my $self = shift;
+
+ # The Perl interpreter places the name of the
+ # message in a variable called $AUTOLOAD.
+
+ # DESTROY messages should never be propagated.
+ return if $AUTOLOAD =~ /::DESTROY$/;
+
+ # Remove the package name.
+ $AUTOLOAD =~ s/^Mydbm:://;
+
+ # Pass the message to the delegate.
+ $self->{'delegate'}->$AUTOLOAD(@_);
+ }
+
+ package main;
+ use Fcntl qw( O_RDWR O_CREAT );
+
+ tie %foo, "Mydbm", "adbm", O_RDWR|O_CREAT, 0640;
+ $foo{'bar'} = 123;
+ print "foo-bar = $foo{'bar'}\n";
diff --git a/contrib/perl5/pod/perlcall.pod b/contrib/perl5/pod/perlcall.pod
new file mode 100644
index 0000000..c239cfe
--- /dev/null
+++ b/contrib/perl5/pod/perlcall.pod
@@ -0,0 +1,1959 @@
+=head1 NAME
+
+perlcall - Perl calling conventions from C
+
+=head1 DESCRIPTION
+
+The purpose of this document is to show you how to call Perl subroutines
+directly from C, i.e., how to write I<callbacks>.
+
+Apart from discussing the C interface provided by Perl for writing
+callbacks the document uses a series of examples to show how the
+interface actually works in practice. In addition some techniques for
+coding callbacks are covered.
+
+Examples where callbacks are necessary include
+
+=over 5
+
+=item * An Error Handler
+
+You have created an XSUB interface to an application's C API.
+
+A fairly common feature in applications is to allow you to define a C
+function that will be called whenever something nasty occurs. What we
+would like is to be able to specify a Perl subroutine that will be
+called instead.
+
+=item * An Event Driven Program
+
+The classic example of where callbacks are used is when writing an
+event driven program like for an X windows application. In this case
+you register functions to be called whenever specific events occur,
+e.g., a mouse button is pressed, the cursor moves into a window or a
+menu item is selected.
+
+=back
+
+Although the techniques described here are applicable when embedding
+Perl in a C program, this is not the primary goal of this document.
+There are other details that must be considered and are specific to
+embedding Perl. For details on embedding Perl in C refer to
+L<perlembed>.
+
+Before you launch yourself head first into the rest of this document,
+it would be a good idea to have read the following two documents -
+L<perlxs> and L<perlguts>.
+
+=head1 THE PERL_CALL FUNCTIONS
+
+Although this stuff is easier to explain using examples, you first need
+be aware of a few important definitions.
+
+Perl has a number of C functions that allow you to call Perl
+subroutines. They are
+
+ I32 perl_call_sv(SV* sv, I32 flags) ;
+ I32 perl_call_pv(char *subname, I32 flags) ;
+ I32 perl_call_method(char *methname, I32 flags) ;
+ I32 perl_call_argv(char *subname, I32 flags, register char **argv) ;
+
+The key function is I<perl_call_sv>. All the other functions are
+fairly simple wrappers which make it easier to call Perl subroutines in
+special cases. At the end of the day they will all call I<perl_call_sv>
+to invoke the Perl subroutine.
+
+All the I<perl_call_*> functions have a C<flags> parameter which is
+used to pass a bit mask of options to Perl. This bit mask operates
+identically for each of the functions. The settings available in the
+bit mask are discussed in L<FLAG VALUES>.
+
+Each of the functions will now be discussed in turn.
+
+=over 5
+
+=item B<perl_call_sv>
+
+I<perl_call_sv> takes two parameters, the first, C<sv>, is an SV*.
+This allows you to specify the Perl subroutine to be called either as a
+C string (which has first been converted to an SV) or a reference to a
+subroutine. The section, I<Using perl_call_sv>, shows how you can make
+use of I<perl_call_sv>.
+
+=item B<perl_call_pv>
+
+The function, I<perl_call_pv>, is similar to I<perl_call_sv> except it
+expects its first parameter to be a C char* which identifies the Perl
+subroutine you want to call, e.g., C<perl_call_pv("fred", 0)>. If the
+subroutine you want to call is in another package, just include the
+package name in the string, e.g., C<"pkg::fred">.
+
+=item B<perl_call_method>
+
+The function I<perl_call_method> is used to call a method from a Perl
+class. The parameter C<methname> corresponds to the name of the method
+to be called. Note that the class that the method belongs to is passed
+on the Perl stack rather than in the parameter list. This class can be
+either the name of the class (for a static method) or a reference to an
+object (for a virtual method). See L<perlobj> for more information on
+static and virtual methods and L<Using perl_call_method> for an example
+of using I<perl_call_method>.
+
+=item B<perl_call_argv>
+
+I<perl_call_argv> calls the Perl subroutine specified by the C string
+stored in the C<subname> parameter. It also takes the usual C<flags>
+parameter. The final parameter, C<argv>, consists of a NULL terminated
+list of C strings to be passed as parameters to the Perl subroutine.
+See I<Using perl_call_argv>.
+
+=back
+
+All the functions return an integer. This is a count of the number of
+items returned by the Perl subroutine. The actual items returned by the
+subroutine are stored on the Perl stack.
+
+As a general rule you should I<always> check the return value from
+these functions. Even if you are expecting only a particular number of
+values to be returned from the Perl subroutine, there is nothing to
+stop someone from doing something unexpected - don't say you haven't
+been warned.
+
+=head1 FLAG VALUES
+
+The C<flags> parameter in all the I<perl_call_*> functions is a bit mask
+which can consist of any combination of the symbols defined below,
+OR'ed together.
+
+
+=head2 G_VOID
+
+Calls the Perl subroutine in a void context.
+
+This flag has 2 effects:
+
+=over 5
+
+=item 1.
+
+It indicates to the subroutine being called that it is executing in
+a void context (if it executes I<wantarray> the result will be the
+undefined value).
+
+=item 2.
+
+It ensures that nothing is actually returned from the subroutine.
+
+=back
+
+The value returned by the I<perl_call_*> function indicates how many
+items have been returned by the Perl subroutine - in this case it will
+be 0.
+
+
+=head2 G_SCALAR
+
+Calls the Perl subroutine in a scalar context. This is the default
+context flag setting for all the I<perl_call_*> functions.
+
+This flag has 2 effects:
+
+=over 5
+
+=item 1.
+
+It indicates to the subroutine being called that it is executing in a
+scalar context (if it executes I<wantarray> the result will be false).
+
+=item 2.
+
+It ensures that only a scalar is actually returned from the subroutine.
+The subroutine can, of course, ignore the I<wantarray> and return a
+list anyway. If so, then only the last element of the list will be
+returned.
+
+=back
+
+The value returned by the I<perl_call_*> function indicates how many
+items have been returned by the Perl subroutine - in this case it will
+be either 0 or 1.
+
+If 0, then you have specified the G_DISCARD flag.
+
+If 1, then the item actually returned by the Perl subroutine will be
+stored on the Perl stack - the section I<Returning a Scalar> shows how
+to access this value on the stack. Remember that regardless of how
+many items the Perl subroutine returns, only the last one will be
+accessible from the stack - think of the case where only one value is
+returned as being a list with only one element. Any other items that
+were returned will not exist by the time control returns from the
+I<perl_call_*> function. The section I<Returning a list in a scalar
+context> shows an example of this behavior.
+
+
+=head2 G_ARRAY
+
+Calls the Perl subroutine in a list context.
+
+As with G_SCALAR, this flag has 2 effects:
+
+=over 5
+
+=item 1.
+
+It indicates to the subroutine being called that it is executing in an
+array context (if it executes I<wantarray> the result will be true).
+
+
+=item 2.
+
+It ensures that all items returned from the subroutine will be
+accessible when control returns from the I<perl_call_*> function.
+
+=back
+
+The value returned by the I<perl_call_*> function indicates how many
+items have been returned by the Perl subroutine.
+
+If 0, then you have specified the G_DISCARD flag.
+
+If not 0, then it will be a count of the number of items returned by
+the subroutine. These items will be stored on the Perl stack. The
+section I<Returning a list of values> gives an example of using the
+G_ARRAY flag and the mechanics of accessing the returned items from the
+Perl stack.
+
+=head2 G_DISCARD
+
+By default, the I<perl_call_*> functions place the items returned from
+by the Perl subroutine on the stack. If you are not interested in
+these items, then setting this flag will make Perl get rid of them
+automatically for you. Note that it is still possible to indicate a
+context to the Perl subroutine by using either G_SCALAR or G_ARRAY.
+
+If you do not set this flag then it is I<very> important that you make
+sure that any temporaries (i.e., parameters passed to the Perl
+subroutine and values returned from the subroutine) are disposed of
+yourself. The section I<Returning a Scalar> gives details of how to
+dispose of these temporaries explicitly and the section I<Using Perl to
+dispose of temporaries> discusses the specific circumstances where you
+can ignore the problem and let Perl deal with it for you.
+
+=head2 G_NOARGS
+
+Whenever a Perl subroutine is called using one of the I<perl_call_*>
+functions, it is assumed by default that parameters are to be passed to
+the subroutine. If you are not passing any parameters to the Perl
+subroutine, you can save a bit of time by setting this flag. It has
+the effect of not creating the C<@_> array for the Perl subroutine.
+
+Although the functionality provided by this flag may seem
+straightforward, it should be used only if there is a good reason to do
+so. The reason for being cautious is that even if you have specified
+the G_NOARGS flag, it is still possible for the Perl subroutine that
+has been called to think that you have passed it parameters.
+
+In fact, what can happen is that the Perl subroutine you have called
+can access the C<@_> array from a previous Perl subroutine. This will
+occur when the code that is executing the I<perl_call_*> function has
+itself been called from another Perl subroutine. The code below
+illustrates this
+
+ sub fred
+ { print "@_\n" }
+
+ sub joe
+ { &fred }
+
+ &joe(1,2,3) ;
+
+This will print
+
+ 1 2 3
+
+What has happened is that C<fred> accesses the C<@_> array which
+belongs to C<joe>.
+
+
+=head2 G_EVAL
+
+It is possible for the Perl subroutine you are calling to terminate
+abnormally, e.g., by calling I<die> explicitly or by not actually
+existing. By default, when either of these events occurs, the
+process will terminate immediately. If you want to trap this
+type of event, specify the G_EVAL flag. It will put an I<eval { }>
+around the subroutine call.
+
+Whenever control returns from the I<perl_call_*> function you need to
+check the C<$@> variable as you would in a normal Perl script.
+
+The value returned from the I<perl_call_*> function is dependent on
+what other flags have been specified and whether an error has
+occurred. Here are all the different cases that can occur:
+
+=over 5
+
+=item *
+
+If the I<perl_call_*> function returns normally, then the value
+returned is as specified in the previous sections.
+
+=item *
+
+If G_DISCARD is specified, the return value will always be 0.
+
+=item *
+
+If G_ARRAY is specified I<and> an error has occurred, the return value
+will always be 0.
+
+=item *
+
+If G_SCALAR is specified I<and> an error has occurred, the return value
+will be 1 and the value on the top of the stack will be I<undef>. This
+means that if you have already detected the error by checking C<$@> and
+you want the program to continue, you must remember to pop the I<undef>
+from the stack.
+
+=back
+
+See I<Using G_EVAL> for details on using G_EVAL.
+
+=head2 G_KEEPERR
+
+You may have noticed that using the G_EVAL flag described above will
+B<always> clear the C<$@> variable and set it to a string describing
+the error iff there was an error in the called code. This unqualified
+resetting of C<$@> can be problematic in the reliable identification of
+errors using the C<eval {}> mechanism, because the possibility exists
+that perl will call other code (end of block processing code, for
+example) between the time the error causes C<$@> to be set within
+C<eval {}>, and the subsequent statement which checks for the value of
+C<$@> gets executed in the user's script.
+
+This scenario will mostly be applicable to code that is meant to be
+called from within destructors, asynchronous callbacks, signal
+handlers, C<__DIE__> or C<__WARN__> hooks, and C<tie> functions. In
+such situations, you will not want to clear C<$@> at all, but simply to
+append any new errors to any existing value of C<$@>.
+
+The G_KEEPERR flag is meant to be used in conjunction with G_EVAL in
+I<perl_call_*> functions that are used to implement such code. This flag
+has no effect when G_EVAL is not used.
+
+When G_KEEPERR is used, any errors in the called code will be prefixed
+with the string "\t(in cleanup)", and appended to the current value
+of C<$@>.
+
+The G_KEEPERR flag was introduced in Perl version 5.002.
+
+See I<Using G_KEEPERR> for an example of a situation that warrants the
+use of this flag.
+
+=head2 Determining the Context
+
+As mentioned above, you can determine the context of the currently
+executing subroutine in Perl with I<wantarray>. The equivalent test
+can be made in C by using the C<GIMME_V> macro, which returns
+C<G_ARRAY> if you have been called in an array context, C<G_SCALAR> if
+in a scalar context, or C<G_VOID> if in a void context (i.e. the
+return value will not be used). An older version of this macro is
+called C<GIMME>; in a void context it returns C<G_SCALAR> instead of
+C<G_VOID>. An example of using the C<GIMME_V> macro is shown in
+section I<Using GIMME_V>.
+
+=head1 KNOWN PROBLEMS
+
+This section outlines all known problems that exist in the
+I<perl_call_*> functions.
+
+=over 5
+
+=item 1.
+
+If you are intending to make use of both the G_EVAL and G_SCALAR flags
+in your code, use a version of Perl greater than 5.000. There is a bug
+in version 5.000 of Perl which means that the combination of these two
+flags will not work as described in the section I<FLAG VALUES>.
+
+Specifically, if the two flags are used when calling a subroutine and
+that subroutine does not call I<die>, the value returned by
+I<perl_call_*> will be wrong.
+
+
+=item 2.
+
+In Perl 5.000 and 5.001 there is a problem with using I<perl_call_*> if
+the Perl sub you are calling attempts to trap a I<die>.
+
+The symptom of this problem is that the called Perl sub will continue
+to completion, but whenever it attempts to pass control back to the
+XSUB, the program will immediately terminate.
+
+For example, say you want to call this Perl sub
+
+ sub fred
+ {
+ eval { die "Fatal Error" ; }
+ print "Trapped error: $@\n"
+ if $@ ;
+ }
+
+via this XSUB
+
+ void
+ Call_fred()
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_pv("fred", G_DISCARD|G_NOARGS) ;
+ fprintf(stderr, "back in Call_fred\n") ;
+
+When C<Call_fred> is executed it will print
+
+ Trapped error: Fatal Error
+
+As control never returns to C<Call_fred>, the C<"back in Call_fred">
+string will not get printed.
+
+To work around this problem, you can either upgrade to Perl 5.002 or
+higher, or use the G_EVAL flag with I<perl_call_*> as shown below
+
+ void
+ Call_fred()
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_pv("fred", G_EVAL|G_DISCARD|G_NOARGS) ;
+ fprintf(stderr, "back in Call_fred\n") ;
+
+=back
+
+
+
+=head1 EXAMPLES
+
+Enough of the definition talk, let's have a few examples.
+
+Perl provides many macros to assist in accessing the Perl stack.
+Wherever possible, these macros should always be used when interfacing
+to Perl internals. We hope this should make the code less vulnerable
+to any changes made to Perl in the future.
+
+Another point worth noting is that in the first series of examples I
+have made use of only the I<perl_call_pv> function. This has been done
+to keep the code simpler and ease you into the topic. Wherever
+possible, if the choice is between using I<perl_call_pv> and
+I<perl_call_sv>, you should always try to use I<perl_call_sv>. See
+I<Using perl_call_sv> for details.
+
+=head2 No Parameters, Nothing returned
+
+This first trivial example will call a Perl subroutine, I<PrintUID>, to
+print out the UID of the process.
+
+ sub PrintUID
+ {
+ print "UID is $<\n" ;
+ }
+
+and here is a C function to call it
+
+ static void
+ call_PrintUID()
+ {
+ dSP ;
+
+ PUSHMARK(SP) ;
+ perl_call_pv("PrintUID", G_DISCARD|G_NOARGS) ;
+ }
+
+Simple, eh.
+
+A few points to note about this example.
+
+=over 5
+
+=item 1.
+
+Ignore C<dSP> and C<PUSHMARK(SP)> for now. They will be discussed in
+the next example.
+
+=item 2.
+
+We aren't passing any parameters to I<PrintUID> so G_NOARGS can be
+specified.
+
+=item 3.
+
+We aren't interested in anything returned from I<PrintUID>, so
+G_DISCARD is specified. Even if I<PrintUID> was changed to
+return some value(s), having specified G_DISCARD will mean that they
+will be wiped by the time control returns from I<perl_call_pv>.
+
+=item 4.
+
+As I<perl_call_pv> is being used, the Perl subroutine is specified as a
+C string. In this case the subroutine name has been 'hard-wired' into the
+code.
+
+=item 5.
+
+Because we specified G_DISCARD, it is not necessary to check the value
+returned from I<perl_call_pv>. It will always be 0.
+
+=back
+
+=head2 Passing Parameters
+
+Now let's make a slightly more complex example. This time we want to
+call a Perl subroutine, C<LeftString>, which will take 2 parameters - a
+string (C<$s>) and an integer (C<$n>). The subroutine will simply
+print the first C<$n> characters of the string.
+
+So the Perl subroutine would look like this
+
+ sub LeftString
+ {
+ my($s, $n) = @_ ;
+ print substr($s, 0, $n), "\n" ;
+ }
+
+The C function required to call I<LeftString> would look like this.
+
+ static void
+ call_LeftString(a, b)
+ char * a ;
+ int b ;
+ {
+ dSP ;
+
+ ENTER ;
+ SAVETMPS ;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSVpv(a, 0)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ perl_call_pv("LeftString", G_DISCARD);
+
+ FREETMPS ;
+ LEAVE ;
+ }
+
+Here are a few notes on the C function I<call_LeftString>.
+
+=over 5
+
+=item 1.
+
+Parameters are passed to the Perl subroutine using the Perl stack.
+This is the purpose of the code beginning with the line C<dSP> and
+ending with the line C<PUTBACK>. The C<dSP> declares a local copy
+of the stack pointer. This local copy should B<always> be accessed
+as C<SP>.
+
+=item 2.
+
+If you are going to put something onto the Perl stack, you need to know
+where to put it. This is the purpose of the macro C<dSP> - it declares
+and initializes a I<local> copy of the Perl stack pointer.
+
+All the other macros which will be used in this example require you to
+have used this macro.
+
+The exception to this rule is if you are calling a Perl subroutine
+directly from an XSUB function. In this case it is not necessary to
+use the C<dSP> macro explicitly - it will be declared for you
+automatically.
+
+=item 3.
+
+Any parameters to be pushed onto the stack should be bracketed by the
+C<PUSHMARK> and C<PUTBACK> macros. The purpose of these two macros, in
+this context, is to count the number of parameters you are
+pushing automatically. Then whenever Perl is creating the C<@_> array for the
+subroutine, it knows how big to make it.
+
+The C<PUSHMARK> macro tells Perl to make a mental note of the current
+stack pointer. Even if you aren't passing any parameters (like the
+example shown in the section I<No Parameters, Nothing returned>) you
+must still call the C<PUSHMARK> macro before you can call any of the
+I<perl_call_*> functions - Perl still needs to know that there are no
+parameters.
+
+The C<PUTBACK> macro sets the global copy of the stack pointer to be
+the same as our local copy. If we didn't do this I<perl_call_pv>
+wouldn't know where the two parameters we pushed were - remember that
+up to now all the stack pointer manipulation we have done is with our
+local copy, I<not> the global copy.
+
+=item 4.
+
+The only flag specified this time is G_DISCARD. Because we are passing 2
+parameters to the Perl subroutine this time, we have not specified
+G_NOARGS.
+
+=item 5.
+
+Next, we come to XPUSHs. This is where the parameters actually get
+pushed onto the stack. In this case we are pushing a string and an
+integer.
+
+See L<perlguts/"XSUBs and the Argument Stack"> for details
+on how the XPUSH macros work.
+
+=item 6.
+
+Because we created temporary values (by means of sv_2mortal() calls)
+we will have to tidy up the Perl stack and dispose of mortal SVs.
+
+This is the purpose of
+
+ ENTER ;
+ SAVETMPS ;
+
+at the start of the function, and
+
+ FREETMPS ;
+ LEAVE ;
+
+at the end. The C<ENTER>/C<SAVETMPS> pair creates a boundary for any
+temporaries we create. This means that the temporaries we get rid of
+will be limited to those which were created after these calls.
+
+The C<FREETMPS>/C<LEAVE> pair will get rid of any values returned by
+the Perl subroutine (see next example), plus it will also dump the
+mortal SVs we have created. Having C<ENTER>/C<SAVETMPS> at the
+beginning of the code makes sure that no other mortals are destroyed.
+
+Think of these macros as working a bit like using C<{> and C<}> in Perl
+to limit the scope of local variables.
+
+See the section I<Using Perl to dispose of temporaries> for details of
+an alternative to using these macros.
+
+=item 7.
+
+Finally, I<LeftString> can now be called via the I<perl_call_pv>
+function.
+
+=back
+
+=head2 Returning a Scalar
+
+Now for an example of dealing with the items returned from a Perl
+subroutine.
+
+Here is a Perl subroutine, I<Adder>, that takes 2 integer parameters
+and simply returns their sum.
+
+ sub Adder
+ {
+ my($a, $b) = @_ ;
+ $a + $b ;
+ }
+
+Because we are now concerned with the return value from I<Adder>, the C
+function required to call it is now a bit more complex.
+
+ static void
+ call_Adder(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ int count ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(a)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ count = perl_call_pv("Adder", G_SCALAR);
+
+ SPAGAIN ;
+
+ if (count != 1)
+ croak("Big trouble\n") ;
+
+ printf ("The sum of %d and %d is %d\n", a, b, POPi) ;
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+
+Points to note this time are
+
+=over 5
+
+=item 1.
+
+The only flag specified this time was G_SCALAR. That means the C<@_>
+array will be created and that the value returned by I<Adder> will
+still exist after the call to I<perl_call_pv>.
+
+=item 2.
+
+The purpose of the macro C<SPAGAIN> is to refresh the local copy of the
+stack pointer. This is necessary because it is possible that the memory
+allocated to the Perl stack has been reallocated whilst in the
+I<perl_call_pv> call.
+
+If you are making use of the Perl stack pointer in your code you must
+always refresh the local copy using SPAGAIN whenever you make use
+of the I<perl_call_*> functions or any other Perl internal function.
+
+=item 3.
+
+Although only a single value was expected to be returned from I<Adder>,
+it is still good practice to check the return code from I<perl_call_pv>
+anyway.
+
+Expecting a single value is not quite the same as knowing that there
+will be one. If someone modified I<Adder> to return a list and we
+didn't check for that possibility and take appropriate action the Perl
+stack would end up in an inconsistent state. That is something you
+I<really> don't want to happen ever.
+
+=item 4.
+
+The C<POPi> macro is used here to pop the return value from the stack.
+In this case we wanted an integer, so C<POPi> was used.
+
+
+Here is the complete list of POP macros available, along with the types
+they return.
+
+ POPs SV
+ POPp pointer
+ POPn double
+ POPi integer
+ POPl long
+
+=item 5.
+
+The final C<PUTBACK> is used to leave the Perl stack in a consistent
+state before exiting the function. This is necessary because when we
+popped the return value from the stack with C<POPi> it updated only our
+local copy of the stack pointer. Remember, C<PUTBACK> sets the global
+stack pointer to be the same as our local copy.
+
+=back
+
+
+=head2 Returning a list of values
+
+Now, let's extend the previous example to return both the sum of the
+parameters and the difference.
+
+Here is the Perl subroutine
+
+ sub AddSubtract
+ {
+ my($a, $b) = @_ ;
+ ($a+$b, $a-$b) ;
+ }
+
+and this is the C function
+
+ static void
+ call_AddSubtract(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ int count ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(a)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ count = perl_call_pv("AddSubtract", G_ARRAY);
+
+ SPAGAIN ;
+
+ if (count != 2)
+ croak("Big trouble\n") ;
+
+ printf ("%d - %d = %d\n", a, b, POPi) ;
+ printf ("%d + %d = %d\n", a, b, POPi) ;
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+
+If I<call_AddSubtract> is called like this
+
+ call_AddSubtract(7, 4) ;
+
+then here is the output
+
+ 7 - 4 = 3
+ 7 + 4 = 11
+
+Notes
+
+=over 5
+
+=item 1.
+
+We wanted array context, so G_ARRAY was used.
+
+=item 2.
+
+Not surprisingly C<POPi> is used twice this time because we were
+retrieving 2 values from the stack. The important thing to note is that
+when using the C<POP*> macros they come off the stack in I<reverse>
+order.
+
+=back
+
+=head2 Returning a list in a scalar context
+
+Say the Perl subroutine in the previous section was called in a scalar
+context, like this
+
+ static void
+ call_AddSubScalar(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ int count ;
+ int i ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(a)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ count = perl_call_pv("AddSubtract", G_SCALAR);
+
+ SPAGAIN ;
+
+ printf ("Items Returned = %d\n", count) ;
+
+ for (i = 1 ; i <= count ; ++i)
+ printf ("Value %d = %d\n", i, POPi) ;
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+
+The other modification made is that I<call_AddSubScalar> will print the
+number of items returned from the Perl subroutine and their value (for
+simplicity it assumes that they are integer). So if
+I<call_AddSubScalar> is called
+
+ call_AddSubScalar(7, 4) ;
+
+then the output will be
+
+ Items Returned = 1
+ Value 1 = 3
+
+In this case the main point to note is that only the last item in the
+list is returned from the subroutine, I<AddSubtract> actually made it back to
+I<call_AddSubScalar>.
+
+
+=head2 Returning Data from Perl via the parameter list
+
+It is also possible to return values directly via the parameter list -
+whether it is actually desirable to do it is another matter entirely.
+
+The Perl subroutine, I<Inc>, below takes 2 parameters and increments
+each directly.
+
+ sub Inc
+ {
+ ++ $_[0] ;
+ ++ $_[1] ;
+ }
+
+and here is a C function to call it.
+
+ static void
+ call_Inc(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ int count ;
+ SV * sva ;
+ SV * svb ;
+
+ ENTER ;
+ SAVETMPS;
+
+ sva = sv_2mortal(newSViv(a)) ;
+ svb = sv_2mortal(newSViv(b)) ;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sva);
+ XPUSHs(svb);
+ PUTBACK ;
+
+ count = perl_call_pv("Inc", G_DISCARD);
+
+ if (count != 0)
+ croak ("call_Inc: expected 0 values from 'Inc', got %d\n",
+ count) ;
+
+ printf ("%d + 1 = %d\n", a, SvIV(sva)) ;
+ printf ("%d + 1 = %d\n", b, SvIV(svb)) ;
+
+ FREETMPS ;
+ LEAVE ;
+ }
+
+To be able to access the two parameters that were pushed onto the stack
+after they return from I<perl_call_pv> it is necessary to make a note
+of their addresses - thus the two variables C<sva> and C<svb>.
+
+The reason this is necessary is that the area of the Perl stack which
+held them will very likely have been overwritten by something else by
+the time control returns from I<perl_call_pv>.
+
+
+
+
+=head2 Using G_EVAL
+
+Now an example using G_EVAL. Below is a Perl subroutine which computes
+the difference of its 2 parameters. If this would result in a negative
+result, the subroutine calls I<die>.
+
+ sub Subtract
+ {
+ my ($a, $b) = @_ ;
+
+ die "death can be fatal\n" if $a < $b ;
+
+ $a - $b ;
+ }
+
+and some C to call it
+
+ static void
+ call_Subtract(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ int count ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(a)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ count = perl_call_pv("Subtract", G_EVAL|G_SCALAR);
+
+ SPAGAIN ;
+
+ /* Check the eval first */
+ if (SvTRUE(ERRSV))
+ {
+ printf ("Uh oh - %s\n", SvPV(ERRSV, PL_na)) ;
+ POPs ;
+ }
+ else
+ {
+ if (count != 1)
+ croak("call_Subtract: wanted 1 value from 'Subtract', got %d\n",
+ count) ;
+
+ printf ("%d - %d = %d\n", a, b, POPi) ;
+ }
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+
+If I<call_Subtract> is called thus
+
+ call_Subtract(4, 5)
+
+the following will be printed
+
+ Uh oh - death can be fatal
+
+Notes
+
+=over 5
+
+=item 1.
+
+We want to be able to catch the I<die> so we have used the G_EVAL
+flag. Not specifying this flag would mean that the program would
+terminate immediately at the I<die> statement in the subroutine
+I<Subtract>.
+
+=item 2.
+
+The code
+
+ if (SvTRUE(ERRSV))
+ {
+ printf ("Uh oh - %s\n", SvPV(ERRSV, PL_na)) ;
+ POPs ;
+ }
+
+is the direct equivalent of this bit of Perl
+
+ print "Uh oh - $@\n" if $@ ;
+
+C<PL_errgv> is a perl global of type C<GV *> that points to the
+symbol table entry containing the error. C<ERRSV> therefore
+refers to the C equivalent of C<$@>.
+
+=item 3.
+
+Note that the stack is popped using C<POPs> in the block where
+C<SvTRUE(ERRSV)> is true. This is necessary because whenever a
+I<perl_call_*> function invoked with G_EVAL|G_SCALAR returns an error,
+the top of the stack holds the value I<undef>. Because we want the
+program to continue after detecting this error, it is essential that
+the stack is tidied up by removing the I<undef>.
+
+=back
+
+
+=head2 Using G_KEEPERR
+
+Consider this rather facetious example, where we have used an XS
+version of the call_Subtract example above inside a destructor:
+
+ package Foo;
+ sub new { bless {}, $_[0] }
+ sub Subtract {
+ my($a,$b) = @_;
+ die "death can be fatal" if $a < $b ;
+ $a - $b;
+ }
+ sub DESTROY { call_Subtract(5, 4); }
+ sub foo { die "foo dies"; }
+
+ package main;
+ eval { Foo->new->foo };
+ print "Saw: $@" if $@; # should be, but isn't
+
+This example will fail to recognize that an error occurred inside the
+C<eval {}>. Here's why: the call_Subtract code got executed while perl
+was cleaning up temporaries when exiting the eval block, and because
+call_Subtract is implemented with I<perl_call_pv> using the G_EVAL
+flag, it promptly reset C<$@>. This results in the failure of the
+outermost test for C<$@>, and thereby the failure of the error trap.
+
+Appending the G_KEEPERR flag, so that the I<perl_call_pv> call in
+call_Subtract reads:
+
+ count = perl_call_pv("Subtract", G_EVAL|G_SCALAR|G_KEEPERR);
+
+will preserve the error and restore reliable error handling.
+
+=head2 Using perl_call_sv
+
+In all the previous examples I have 'hard-wired' the name of the Perl
+subroutine to be called from C. Most of the time though, it is more
+convenient to be able to specify the name of the Perl subroutine from
+within the Perl script.
+
+Consider the Perl code below
+
+ sub fred
+ {
+ print "Hello there\n" ;
+ }
+
+ CallSubPV("fred") ;
+
+Here is a snippet of XSUB which defines I<CallSubPV>.
+
+ void
+ CallSubPV(name)
+ char * name
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_pv(name, G_DISCARD|G_NOARGS) ;
+
+That is fine as far as it goes. The thing is, the Perl subroutine
+can be specified as only a string. For Perl 4 this was adequate,
+but Perl 5 allows references to subroutines and anonymous subroutines.
+This is where I<perl_call_sv> is useful.
+
+The code below for I<CallSubSV> is identical to I<CallSubPV> except
+that the C<name> parameter is now defined as an SV* and we use
+I<perl_call_sv> instead of I<perl_call_pv>.
+
+ void
+ CallSubSV(name)
+ SV * name
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_sv(name, G_DISCARD|G_NOARGS) ;
+
+Because we are using an SV to call I<fred> the following can all be used
+
+ CallSubSV("fred") ;
+ CallSubSV(\&fred) ;
+ $ref = \&fred ;
+ CallSubSV($ref) ;
+ CallSubSV( sub { print "Hello there\n" } ) ;
+
+As you can see, I<perl_call_sv> gives you much greater flexibility in
+how you can specify the Perl subroutine.
+
+You should note that if it is necessary to store the SV (C<name> in the
+example above) which corresponds to the Perl subroutine so that it can
+be used later in the program, it not enough just to store a copy of the
+pointer to the SV. Say the code above had been like this
+
+ static SV * rememberSub ;
+
+ void
+ SaveSub1(name)
+ SV * name
+ CODE:
+ rememberSub = name ;
+
+ void
+ CallSavedSub1()
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_sv(rememberSub, G_DISCARD|G_NOARGS) ;
+
+The reason this is wrong is that by the time you come to use the
+pointer C<rememberSub> in C<CallSavedSub1>, it may or may not still refer
+to the Perl subroutine that was recorded in C<SaveSub1>. This is
+particularly true for these cases
+
+ SaveSub1(\&fred) ;
+ CallSavedSub1() ;
+
+ SaveSub1( sub { print "Hello there\n" } ) ;
+ CallSavedSub1() ;
+
+By the time each of the C<SaveSub1> statements above have been executed,
+the SV*s which corresponded to the parameters will no longer exist.
+Expect an error message from Perl of the form
+
+ Can't use an undefined value as a subroutine reference at ...
+
+for each of the C<CallSavedSub1> lines.
+
+Similarly, with this code
+
+ $ref = \&fred ;
+ SaveSub1($ref) ;
+ $ref = 47 ;
+ CallSavedSub1() ;
+
+you can expect one of these messages (which you actually get is dependent on
+the version of Perl you are using)
+
+ Not a CODE reference at ...
+ Undefined subroutine &main::47 called ...
+
+The variable C<$ref> may have referred to the subroutine C<fred>
+whenever the call to C<SaveSub1> was made but by the time
+C<CallSavedSub1> gets called it now holds the number C<47>. Because we
+saved only a pointer to the original SV in C<SaveSub1>, any changes to
+C<$ref> will be tracked by the pointer C<rememberSub>. This means that
+whenever C<CallSavedSub1> gets called, it will attempt to execute the
+code which is referenced by the SV* C<rememberSub>. In this case
+though, it now refers to the integer C<47>, so expect Perl to complain
+loudly.
+
+A similar but more subtle problem is illustrated with this code
+
+ $ref = \&fred ;
+ SaveSub1($ref) ;
+ $ref = \&joe ;
+ CallSavedSub1() ;
+
+This time whenever C<CallSavedSub1> get called it will execute the Perl
+subroutine C<joe> (assuming it exists) rather than C<fred> as was
+originally requested in the call to C<SaveSub1>.
+
+To get around these problems it is necessary to take a full copy of the
+SV. The code below shows C<SaveSub2> modified to do that
+
+ static SV * keepSub = (SV*)NULL ;
+
+ void
+ SaveSub2(name)
+ SV * name
+ CODE:
+ /* Take a copy of the callback */
+ if (keepSub == (SV*)NULL)
+ /* First time, so create a new SV */
+ keepSub = newSVsv(name) ;
+ else
+ /* Been here before, so overwrite */
+ SvSetSV(keepSub, name) ;
+
+ void
+ CallSavedSub2()
+ CODE:
+ PUSHMARK(SP) ;
+ perl_call_sv(keepSub, G_DISCARD|G_NOARGS) ;
+
+To avoid creating a new SV every time C<SaveSub2> is called,
+the function first checks to see if it has been called before. If not,
+then space for a new SV is allocated and the reference to the Perl
+subroutine, C<name> is copied to the variable C<keepSub> in one
+operation using C<newSVsv>. Thereafter, whenever C<SaveSub2> is called
+the existing SV, C<keepSub>, is overwritten with the new value using
+C<SvSetSV>.
+
+=head2 Using perl_call_argv
+
+Here is a Perl subroutine which prints whatever parameters are passed
+to it.
+
+ sub PrintList
+ {
+ my(@list) = @_ ;
+
+ foreach (@list) { print "$_\n" }
+ }
+
+and here is an example of I<perl_call_argv> which will call
+I<PrintList>.
+
+ static char * words[] = {"alpha", "beta", "gamma", "delta", NULL} ;
+
+ static void
+ call_PrintList()
+ {
+ dSP ;
+
+ perl_call_argv("PrintList", G_DISCARD, words) ;
+ }
+
+Note that it is not necessary to call C<PUSHMARK> in this instance.
+This is because I<perl_call_argv> will do it for you.
+
+=head2 Using perl_call_method
+
+Consider the following Perl code
+
+ {
+ package Mine ;
+
+ sub new
+ {
+ my($type) = shift ;
+ bless [@_]
+ }
+
+ sub Display
+ {
+ my ($self, $index) = @_ ;
+ print "$index: $$self[$index]\n" ;
+ }
+
+ sub PrintID
+ {
+ my($class) = @_ ;
+ print "This is Class $class version 1.0\n" ;
+ }
+ }
+
+It implements just a very simple class to manage an array. Apart from
+the constructor, C<new>, it declares methods, one static and one
+virtual. The static method, C<PrintID>, prints out simply the class
+name and a version number. The virtual method, C<Display>, prints out a
+single element of the array. Here is an all Perl example of using it.
+
+ $a = new Mine ('red', 'green', 'blue') ;
+ $a->Display(1) ;
+ PrintID Mine;
+
+will print
+
+ 1: green
+ This is Class Mine version 1.0
+
+Calling a Perl method from C is fairly straightforward. The following
+things are required
+
+=over 5
+
+=item *
+
+a reference to the object for a virtual method or the name of the class
+for a static method.
+
+=item *
+
+the name of the method.
+
+=item *
+
+any other parameters specific to the method.
+
+=back
+
+Here is a simple XSUB which illustrates the mechanics of calling both
+the C<PrintID> and C<Display> methods from C.
+
+ void
+ call_Method(ref, method, index)
+ SV * ref
+ char * method
+ int index
+ CODE:
+ PUSHMARK(SP);
+ XPUSHs(ref);
+ XPUSHs(sv_2mortal(newSViv(index))) ;
+ PUTBACK;
+
+ perl_call_method(method, G_DISCARD) ;
+
+ void
+ call_PrintID(class, method)
+ char * class
+ char * method
+ CODE:
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSVpv(class, 0))) ;
+ PUTBACK;
+
+ perl_call_method(method, G_DISCARD) ;
+
+
+So the methods C<PrintID> and C<Display> can be invoked like this
+
+ $a = new Mine ('red', 'green', 'blue') ;
+ call_Method($a, 'Display', 1) ;
+ call_PrintID('Mine', 'PrintID') ;
+
+The only thing to note is that in both the static and virtual methods,
+the method name is not passed via the stack - it is used as the first
+parameter to I<perl_call_method>.
+
+=head2 Using GIMME_V
+
+Here is a trivial XSUB which prints the context in which it is
+currently executing.
+
+ void
+ PrintContext()
+ CODE:
+ I32 gimme = GIMME_V;
+ if (gimme == G_VOID)
+ printf ("Context is Void\n") ;
+ else if (gimme == G_SCALAR)
+ printf ("Context is Scalar\n") ;
+ else
+ printf ("Context is Array\n") ;
+
+and here is some Perl to test it
+
+ PrintContext ;
+ $a = PrintContext ;
+ @a = PrintContext ;
+
+The output from that will be
+
+ Context is Void
+ Context is Scalar
+ Context is Array
+
+=head2 Using Perl to dispose of temporaries
+
+In the examples given to date, any temporaries created in the callback
+(i.e., parameters passed on the stack to the I<perl_call_*> function or
+values returned via the stack) have been freed by one of these methods
+
+=over 5
+
+=item *
+
+specifying the G_DISCARD flag with I<perl_call_*>.
+
+=item *
+
+explicitly disposed of using the C<ENTER>/C<SAVETMPS> -
+C<FREETMPS>/C<LEAVE> pairing.
+
+=back
+
+There is another method which can be used, namely letting Perl do it
+for you automatically whenever it regains control after the callback
+has terminated. This is done by simply not using the
+
+ ENTER ;
+ SAVETMPS ;
+ ...
+ FREETMPS ;
+ LEAVE ;
+
+sequence in the callback (and not, of course, specifying the G_DISCARD
+flag).
+
+If you are going to use this method you have to be aware of a possible
+memory leak which can arise under very specific circumstances. To
+explain these circumstances you need to know a bit about the flow of
+control between Perl and the callback routine.
+
+The examples given at the start of the document (an error handler and
+an event driven program) are typical of the two main sorts of flow
+control that you are likely to encounter with callbacks. There is a
+very important distinction between them, so pay attention.
+
+In the first example, an error handler, the flow of control could be as
+follows. You have created an interface to an external library.
+Control can reach the external library like this
+
+ perl --> XSUB --> external library
+
+Whilst control is in the library, an error condition occurs. You have
+previously set up a Perl callback to handle this situation, so it will
+get executed. Once the callback has finished, control will drop back to
+Perl again. Here is what the flow of control will be like in that
+situation
+
+ perl --> XSUB --> external library
+ ...
+ error occurs
+ ...
+ external library --> perl_call --> perl
+ |
+ perl <-- XSUB <-- external library <-- perl_call <----+
+
+After processing of the error using I<perl_call_*> is completed,
+control reverts back to Perl more or less immediately.
+
+In the diagram, the further right you go the more deeply nested the
+scope is. It is only when control is back with perl on the extreme
+left of the diagram that you will have dropped back to the enclosing
+scope and any temporaries you have left hanging around will be freed.
+
+In the second example, an event driven program, the flow of control
+will be more like this
+
+ perl --> XSUB --> event handler
+ ...
+ event handler --> perl_call --> perl
+ |
+ event handler <-- perl_call <----+
+ ...
+ event handler --> perl_call --> perl
+ |
+ event handler <-- perl_call <----+
+ ...
+ event handler --> perl_call --> perl
+ |
+ event handler <-- perl_call <----+
+
+In this case the flow of control can consist of only the repeated
+sequence
+
+ event handler --> perl_call --> perl
+
+for practically the complete duration of the program. This means that
+control may I<never> drop back to the surrounding scope in Perl at the
+extreme left.
+
+So what is the big problem? Well, if you are expecting Perl to tidy up
+those temporaries for you, you might be in for a long wait. For Perl
+to dispose of your temporaries, control must drop back to the
+enclosing scope at some stage. In the event driven scenario that may
+never happen. This means that as time goes on, your program will
+create more and more temporaries, none of which will ever be freed. As
+each of these temporaries consumes some memory your program will
+eventually consume all the available memory in your system - kapow!
+
+So here is the bottom line - if you are sure that control will revert
+back to the enclosing Perl scope fairly quickly after the end of your
+callback, then it isn't absolutely necessary to dispose explicitly of
+any temporaries you may have created. Mind you, if you are at all
+uncertain about what to do, it doesn't do any harm to tidy up anyway.
+
+
+=head2 Strategies for storing Callback Context Information
+
+
+Potentially one of the trickiest problems to overcome when designing a
+callback interface can be figuring out how to store the mapping between
+the C callback function and the Perl equivalent.
+
+To help understand why this can be a real problem first consider how a
+callback is set up in an all C environment. Typically a C API will
+provide a function to register a callback. This will expect a pointer
+to a function as one of its parameters. Below is a call to a
+hypothetical function C<register_fatal> which registers the C function
+to get called when a fatal error occurs.
+
+ register_fatal(cb1) ;
+
+The single parameter C<cb1> is a pointer to a function, so you must
+have defined C<cb1> in your code, say something like this
+
+ static void
+ cb1()
+ {
+ printf ("Fatal Error\n") ;
+ exit(1) ;
+ }
+
+Now change that to call a Perl subroutine instead
+
+ static SV * callback = (SV*)NULL;
+
+ static void
+ cb1()
+ {
+ dSP ;
+
+ PUSHMARK(SP) ;
+
+ /* Call the Perl sub to process the callback */
+ perl_call_sv(callback, G_DISCARD) ;
+ }
+
+
+ void
+ register_fatal(fn)
+ SV * fn
+ CODE:
+ /* Remember the Perl sub */
+ if (callback == (SV*)NULL)
+ callback = newSVsv(fn) ;
+ else
+ SvSetSV(callback, fn) ;
+
+ /* register the callback with the external library */
+ register_fatal(cb1) ;
+
+where the Perl equivalent of C<register_fatal> and the callback it
+registers, C<pcb1>, might look like this
+
+ # Register the sub pcb1
+ register_fatal(\&pcb1) ;
+
+ sub pcb1
+ {
+ die "I'm dying...\n" ;
+ }
+
+The mapping between the C callback and the Perl equivalent is stored in
+the global variable C<callback>.
+
+This will be adequate if you ever need to have only one callback
+registered at any time. An example could be an error handler like the
+code sketched out above. Remember though, repeated calls to
+C<register_fatal> will replace the previously registered callback
+function with the new one.
+
+Say for example you want to interface to a library which allows asynchronous
+file i/o. In this case you may be able to register a callback whenever
+a read operation has completed. To be of any use we want to be able to
+call separate Perl subroutines for each file that is opened. As it
+stands, the error handler example above would not be adequate as it
+allows only a single callback to be defined at any time. What we
+require is a means of storing the mapping between the opened file and
+the Perl subroutine we want to be called for that file.
+
+Say the i/o library has a function C<asynch_read> which associates a C
+function C<ProcessRead> with a file handle C<fh> - this assumes that it
+has also provided some routine to open the file and so obtain the file
+handle.
+
+ asynch_read(fh, ProcessRead)
+
+This may expect the C I<ProcessRead> function of this form
+
+ void
+ ProcessRead(fh, buffer)
+ int fh ;
+ char * buffer ;
+ {
+ ...
+ }
+
+To provide a Perl interface to this library we need to be able to map
+between the C<fh> parameter and the Perl subroutine we want called. A
+hash is a convenient mechanism for storing this mapping. The code
+below shows a possible implementation
+
+ static HV * Mapping = (HV*)NULL ;
+
+ void
+ asynch_read(fh, callback)
+ int fh
+ SV * callback
+ CODE:
+ /* If the hash doesn't already exist, create it */
+ if (Mapping == (HV*)NULL)
+ Mapping = newHV() ;
+
+ /* Save the fh -> callback mapping */
+ hv_store(Mapping, (char*)&fh, sizeof(fh), newSVsv(callback), 0) ;
+
+ /* Register with the C Library */
+ asynch_read(fh, asynch_read_if) ;
+
+and C<asynch_read_if> could look like this
+
+ static void
+ asynch_read_if(fh, buffer)
+ int fh ;
+ char * buffer ;
+ {
+ dSP ;
+ SV ** sv ;
+
+ /* Get the callback associated with fh */
+ sv = hv_fetch(Mapping, (char*)&fh , sizeof(fh), FALSE) ;
+ if (sv == (SV**)NULL)
+ croak("Internal error...\n") ;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(fh))) ;
+ XPUSHs(sv_2mortal(newSVpv(buffer, 0))) ;
+ PUTBACK ;
+
+ /* Call the Perl sub */
+ perl_call_sv(*sv, G_DISCARD) ;
+ }
+
+For completeness, here is C<asynch_close>. This shows how to remove
+the entry from the hash C<Mapping>.
+
+ void
+ asynch_close(fh)
+ int fh
+ CODE:
+ /* Remove the entry from the hash */
+ (void) hv_delete(Mapping, (char*)&fh, sizeof(fh), G_DISCARD) ;
+
+ /* Now call the real asynch_close */
+ asynch_close(fh) ;
+
+So the Perl interface would look like this
+
+ sub callback1
+ {
+ my($handle, $buffer) = @_ ;
+ }
+
+ # Register the Perl callback
+ asynch_read($fh, \&callback1) ;
+
+ asynch_close($fh) ;
+
+The mapping between the C callback and Perl is stored in the global
+hash C<Mapping> this time. Using a hash has the distinct advantage that
+it allows an unlimited number of callbacks to be registered.
+
+What if the interface provided by the C callback doesn't contain a
+parameter which allows the file handle to Perl subroutine mapping? Say
+in the asynchronous i/o package, the callback function gets passed only
+the C<buffer> parameter like this
+
+ void
+ ProcessRead(buffer)
+ char * buffer ;
+ {
+ ...
+ }
+
+Without the file handle there is no straightforward way to map from the
+C callback to the Perl subroutine.
+
+In this case a possible way around this problem is to predefine a
+series of C functions to act as the interface to Perl, thus
+
+ #define MAX_CB 3
+ #define NULL_HANDLE -1
+ typedef void (*FnMap)() ;
+
+ struct MapStruct {
+ FnMap Function ;
+ SV * PerlSub ;
+ int Handle ;
+ } ;
+
+ static void fn1() ;
+ static void fn2() ;
+ static void fn3() ;
+
+ static struct MapStruct Map [MAX_CB] =
+ {
+ { fn1, NULL, NULL_HANDLE },
+ { fn2, NULL, NULL_HANDLE },
+ { fn3, NULL, NULL_HANDLE }
+ } ;
+
+ static void
+ Pcb(index, buffer)
+ int index ;
+ char * buffer ;
+ {
+ dSP ;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSVpv(buffer, 0))) ;
+ PUTBACK ;
+
+ /* Call the Perl sub */
+ perl_call_sv(Map[index].PerlSub, G_DISCARD) ;
+ }
+
+ static void
+ fn1(buffer)
+ char * buffer ;
+ {
+ Pcb(0, buffer) ;
+ }
+
+ static void
+ fn2(buffer)
+ char * buffer ;
+ {
+ Pcb(1, buffer) ;
+ }
+
+ static void
+ fn3(buffer)
+ char * buffer ;
+ {
+ Pcb(2, buffer) ;
+ }
+
+ void
+ array_asynch_read(fh, callback)
+ int fh
+ SV * callback
+ CODE:
+ int index ;
+ int null_index = MAX_CB ;
+
+ /* Find the same handle or an empty entry */
+ for (index = 0 ; index < MAX_CB ; ++index)
+ {
+ if (Map[index].Handle == fh)
+ break ;
+
+ if (Map[index].Handle == NULL_HANDLE)
+ null_index = index ;
+ }
+
+ if (index == MAX_CB && null_index == MAX_CB)
+ croak ("Too many callback functions registered\n") ;
+
+ if (index == MAX_CB)
+ index = null_index ;
+
+ /* Save the file handle */
+ Map[index].Handle = fh ;
+
+ /* Remember the Perl sub */
+ if (Map[index].PerlSub == (SV*)NULL)
+ Map[index].PerlSub = newSVsv(callback) ;
+ else
+ SvSetSV(Map[index].PerlSub, callback) ;
+
+ asynch_read(fh, Map[index].Function) ;
+
+ void
+ array_asynch_close(fh)
+ int fh
+ CODE:
+ int index ;
+
+ /* Find the file handle */
+ for (index = 0; index < MAX_CB ; ++ index)
+ if (Map[index].Handle == fh)
+ break ;
+
+ if (index == MAX_CB)
+ croak ("could not close fh %d\n", fh) ;
+
+ Map[index].Handle = NULL_HANDLE ;
+ SvREFCNT_dec(Map[index].PerlSub) ;
+ Map[index].PerlSub = (SV*)NULL ;
+
+ asynch_close(fh) ;
+
+In this case the functions C<fn1>, C<fn2>, and C<fn3> are used to
+remember the Perl subroutine to be called. Each of the functions holds
+a separate hard-wired index which is used in the function C<Pcb> to
+access the C<Map> array and actually call the Perl subroutine.
+
+There are some obvious disadvantages with this technique.
+
+Firstly, the code is considerably more complex than with the previous
+example.
+
+Secondly, there is a hard-wired limit (in this case 3) to the number of
+callbacks that can exist simultaneously. The only way to increase the
+limit is by modifying the code to add more functions and then
+recompiling. None the less, as long as the number of functions is
+chosen with some care, it is still a workable solution and in some
+cases is the only one available.
+
+To summarize, here are a number of possible methods for you to consider
+for storing the mapping between C and the Perl callback
+
+=over 5
+
+=item 1. Ignore the problem - Allow only 1 callback
+
+For a lot of situations, like interfacing to an error handler, this may
+be a perfectly adequate solution.
+
+=item 2. Create a sequence of callbacks - hard wired limit
+
+If it is impossible to tell from the parameters passed back from the C
+callback what the context is, then you may need to create a sequence of C
+callback interface functions, and store pointers to each in an array.
+
+=item 3. Use a parameter to map to the Perl callback
+
+A hash is an ideal mechanism to store the mapping between C and Perl.
+
+=back
+
+
+=head2 Alternate Stack Manipulation
+
+
+Although I have made use of only the C<POP*> macros to access values
+returned from Perl subroutines, it is also possible to bypass these
+macros and read the stack using the C<ST> macro (See L<perlxs> for a
+full description of the C<ST> macro).
+
+Most of the time the C<POP*> macros should be adequate, the main
+problem with them is that they force you to process the returned values
+in sequence. This may not be the most suitable way to process the
+values in some cases. What we want is to be able to access the stack in
+a random order. The C<ST> macro as used when coding an XSUB is ideal
+for this purpose.
+
+The code below is the example given in the section I<Returning a list
+of values> recoded to use C<ST> instead of C<POP*>.
+
+ static void
+ call_AddSubtract2(a, b)
+ int a ;
+ int b ;
+ {
+ dSP ;
+ I32 ax ;
+ int count ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs(sv_2mortal(newSViv(a)));
+ XPUSHs(sv_2mortal(newSViv(b)));
+ PUTBACK ;
+
+ count = perl_call_pv("AddSubtract", G_ARRAY);
+
+ SPAGAIN ;
+ SP -= count ;
+ ax = (SP - PL_stack_base) + 1 ;
+
+ if (count != 2)
+ croak("Big trouble\n") ;
+
+ printf ("%d + %d = %d\n", a, b, SvIV(ST(0))) ;
+ printf ("%d - %d = %d\n", a, b, SvIV(ST(1))) ;
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
+ }
+
+Notes
+
+=over 5
+
+=item 1.
+
+Notice that it was necessary to define the variable C<ax>. This is
+because the C<ST> macro expects it to exist. If we were in an XSUB it
+would not be necessary to define C<ax> as it is already defined for
+you.
+
+=item 2.
+
+The code
+
+ SPAGAIN ;
+ SP -= count ;
+ ax = (SP - PL_stack_base) + 1 ;
+
+sets the stack up so that we can use the C<ST> macro.
+
+=item 3.
+
+Unlike the original coding of this example, the returned
+values are not accessed in reverse order. So C<ST(0)> refers to the
+first value returned by the Perl subroutine and C<ST(count-1)>
+refers to the last.
+
+=back
+
+=head2 Creating and calling an anonymous subroutine in C
+
+As we've already shown, C<perl_call_sv> can be used to invoke an
+anonymous subroutine. However, our example showed how Perl script
+invoking an XSUB to preform this operation. Let's see how it can be
+done inside our C code:
+
+ ...
+
+ SV *cvrv = perl_eval_pv("sub { print 'You will not find me cluttering any namespace!' }", TRUE);
+
+ ...
+
+ perl_call_sv(cvrv, G_VOID|G_NOARGS);
+
+C<perl_eval_pv> is used to compile the anonymous subroutine, which
+will be the return value as well (read more about C<perl_eval_pv> in
+L<perlguts/perl_eval_pv>). Once this code reference is in hand, it
+can be mixed in with all the previous examples we've shown.
+
+=head1 SEE ALSO
+
+L<perlxs>, L<perlguts>, L<perlembed>
+
+=head1 AUTHOR
+
+Paul Marquess <F<pmarquess@bfsec.bt.co.uk>>
+
+Special thanks to the following people who assisted in the creation of
+the document.
+
+Jeff Okamoto, Tim Bunce, Nick Gianniotis, Steve Kelem, Gurusamy Sarathy
+and Larry Wall.
+
+=head1 DATE
+
+Version 1.3, 14th Apr 1997
diff --git a/contrib/perl5/pod/perldata.pod b/contrib/perl5/pod/perldata.pod
new file mode 100644
index 0000000..58c1123
--- /dev/null
+++ b/contrib/perl5/pod/perldata.pod
@@ -0,0 +1,603 @@
+=head1 NAME
+
+perldata - Perl data types
+
+=head1 DESCRIPTION
+
+=head2 Variable names
+
+Perl has three data structures: scalars, arrays of scalars, and
+associative arrays of scalars, known as "hashes". Normal arrays are
+indexed by number, starting with 0. (Negative subscripts count from
+the end.) Hash arrays are indexed by string.
+
+Values are usually referred to by name (or through a named reference).
+The first character of the name tells you to what sort of data
+structure it refers. The rest of the name tells you the particular
+value to which it refers. Most often, it consists of a single
+I<identifier>, that is, a string beginning with a letter or underscore,
+and containing letters, underscores, and digits. In some cases, it
+may be a chain of identifiers, separated by C<::> (or by C<'>, but
+that's deprecated); all but the last are interpreted as names of
+packages, to locate the namespace in which to look
+up the final identifier (see L<perlmod/Packages> for details).
+It's possible to substitute for a simple identifier an expression
+that produces a reference to the value at runtime; this is
+described in more detail below, and in L<perlref>.
+
+There are also special variables whose names don't follow these
+rules, so that they don't accidentally collide with one of your
+normal variables. Strings that match parenthesized parts of a
+regular expression are saved under names containing only digits after
+the C<$> (see L<perlop> and L<perlre>). In addition, several special
+variables that provide windows into the inner working of Perl have names
+containing punctuation characters (see L<perlvar>).
+
+Scalar values are always named with '$', even when referring to a scalar
+that is part of an array. It works like the English word "the". Thus
+we have:
+
+ $days # the simple scalar value "days"
+ $days[28] # the 29th element of array @days
+ $days{'Feb'} # the 'Feb' value from hash %days
+ $#days # the last index of array @days
+
+but entire arrays or array slices are denoted by '@', which works much like
+the word "these" or "those":
+
+ @days # ($days[0], $days[1],... $days[n])
+ @days[3,4,5] # same as @days[3..5]
+ @days{'a','c'} # same as ($days{'a'},$days{'c'})
+
+and entire hashes are denoted by '%':
+
+ %days # (key1, val1, key2, val2 ...)
+
+In addition, subroutines are named with an initial '&', though this is
+optional when it's otherwise unambiguous (just as "do" is often
+redundant in English). Symbol table entries can be named with an
+initial '*', but you don't really care about that yet.
+
+Every variable type has its own namespace. You can, without fear of
+conflict, use the same name for a scalar variable, an array, or a hash
+(or, for that matter, a filehandle, a subroutine name, or a label).
+This means that $foo and @foo are two different variables. It also
+means that C<$foo[1]> is a part of @foo, not a part of $foo. This may
+seem a bit weird, but that's okay, because it is weird.
+
+Because variable and array references always start with '$', '@', or '%',
+the "reserved" words aren't in fact reserved with respect to variable
+names. (They ARE reserved with respect to labels and filehandles,
+however, which don't have an initial special character. You can't have
+a filehandle named "log", for instance. Hint: you could say
+C<open(LOG,'logfile')> rather than C<open(log,'logfile')>. Using uppercase
+filehandles also improves readability and protects you from conflict
+with future reserved words.) Case I<IS> significant--"FOO", "Foo", and
+"foo" are all different names. Names that start with a letter or
+underscore may also contain digits and underscores.
+
+It is possible to replace such an alphanumeric name with an expression
+that returns a reference to an object of that type. For a description
+of this, see L<perlref>.
+
+Names that start with a digit may contain only more digits. Names
+that do not start with a letter, underscore, or digit are limited to
+one character, e.g., C<$%> or C<$$>. (Most of these one character names
+have a predefined significance to Perl. For instance, C<$$> is the
+current process id.)
+
+=head2 Context
+
+The interpretation of operations and values in Perl sometimes depends
+on the requirements of the context around the operation or value.
+There are two major contexts: scalar and list. Certain operations
+return list values in contexts wanting a list, and scalar values
+otherwise. (If this is true of an operation it will be mentioned in
+the documentation for that operation.) In other words, Perl overloads
+certain operations based on whether the expected return value is
+singular or plural. (Some words in English work this way, like "fish"
+and "sheep".)
+
+In a reciprocal fashion, an operation provides either a scalar or a
+list context to each of its arguments. For example, if you say
+
+ int( <STDIN> )
+
+the integer operation provides a scalar context for the E<lt>STDINE<gt>
+operator, which responds by reading one line from STDIN and passing it
+back to the integer operation, which will then find the integer value
+of that line and return that. If, on the other hand, you say
+
+ sort( <STDIN> )
+
+then the sort operation provides a list context for E<lt>STDINE<gt>, which
+will proceed to read every line available up to the end of file, and
+pass that list of lines back to the sort routine, which will then
+sort those lines and return them as a list to whatever the context
+of the sort was.
+
+Assignment is a little bit special in that it uses its left argument to
+determine the context for the right argument. Assignment to a scalar
+evaluates the righthand side in a scalar context, while assignment to
+an array or array slice evaluates the righthand side in a list
+context. Assignment to a list also evaluates the righthand side in a
+list context.
+
+User defined subroutines may choose to care whether they are being
+called in a scalar or list context, but most subroutines do not
+need to care, because scalars are automatically interpolated into
+lists. See L<perlfunc/wantarray>.
+
+=head2 Scalar values
+
+All data in Perl is a scalar or an array of scalars or a hash of scalars.
+Scalar variables may contain various kinds of singular data, such as
+numbers, strings, and references. In general, conversion from one form to
+another is transparent. (A scalar may not contain multiple values, but
+may contain a reference to an array or hash containing multiple values.)
+Because of the automatic conversion of scalars, operations, and functions
+that return scalars don't need to care (and, in fact, can't care) whether
+the context is looking for a string or a number.
+
+Scalars aren't necessarily one thing or another. There's no place to
+declare a scalar variable to be of type "string", or of type "number", or
+type "filehandle", or anything else. Perl is a contextually polymorphic
+language whose scalars can be strings, numbers, or references (which
+includes objects). While strings and numbers are considered pretty
+much the same thing for nearly all purposes, references are strongly-typed
+uncastable pointers with builtin reference-counting and destructor
+invocation.
+
+A scalar value is interpreted as TRUE in the Boolean sense if it is not
+the null string or the number 0 (or its string equivalent, "0"). The
+Boolean context is just a special kind of scalar context.
+
+There are actually two varieties of null scalars: defined and
+undefined. Undefined null scalars are returned when there is no real
+value for something, such as when there was an error, or at end of
+file, or when you refer to an uninitialized variable or element of an
+array. An undefined null scalar may become defined the first time you
+use it as if it were defined, but prior to that you can use the
+defined() operator to determine whether the value is defined or not.
+
+To find out whether a given string is a valid nonzero number, it's usually
+enough to test it against both numeric 0 and also lexical "0" (although
+this will cause B<-w> noises). That's because strings that aren't
+numbers count as 0, just as they do in B<awk>:
+
+ if ($str == 0 && $str ne "0") {
+ warn "That doesn't look like a number";
+ }
+
+That's usually preferable because otherwise you won't treat IEEE notations
+like C<NaN> or C<Infinity> properly. At other times you might prefer to
+use the POSIX::strtod function or a regular expression to check whether
+data is numeric. See L<perlre> for details on regular expressions.
+
+ warn "has nondigits" if /\D/;
+ warn "not a natural number" unless /^\d+$/; # rejects -3
+ warn "not an integer" unless /^-?\d+$/; # rejects +3
+ warn "not an integer" unless /^[+-]?\d+$/;
+ warn "not a decimal number" unless /^-?\d+\.?\d*$/; # rejects .2
+ warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
+ warn "not a C float"
+ unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
+
+The length of an array is a scalar value. You may find the length of
+array @days by evaluating C<$#days>, as in B<csh>. (Actually, it's not
+the length of the array, it's the subscript of the last element, because
+there is (ordinarily) a 0th element.) Assigning to C<$#days> changes the
+length of the array. Shortening an array by this method destroys
+intervening values. Lengthening an array that was previously shortened
+I<NO LONGER> recovers the values that were in those elements. (It used to
+in Perl 4, but we had to break this to make sure destructors were
+called when expected.) You can also gain some miniscule measure of efficiency by
+pre-extending an array that is going to get big. (You can also extend
+an array by assigning to an element that is off the end of the array.)
+You can truncate an array down to nothing by assigning the null list ()
+to it. The following are equivalent:
+
+ @whatever = ();
+ $#whatever = -1;
+
+If you evaluate a named array in a scalar context, it returns the length of
+the array. (Note that this is not true of lists, which return the
+last value, like the C comma operator, nor of built-in functions, which return
+whatever they feel like returning.) The following is always true:
+
+ scalar(@whatever) == $#whatever - $[ + 1;
+
+Version 5 of Perl changed the semantics of C<$[>: files that don't set
+the value of C<$[> no longer need to worry about whether another
+file changed its value. (In other words, use of C<$[> is deprecated.)
+So in general you can assume that
+
+ scalar(@whatever) == $#whatever + 1;
+
+Some programmers choose to use an explicit conversion so nothing's
+left to doubt:
+
+ $element_count = scalar(@whatever);
+
+If you evaluate a hash in a scalar context, it returns a value that is
+true if and only if the hash contains any key/value pairs. (If there
+are any key/value pairs, the value returned is a string consisting of
+the number of used buckets and the number of allocated buckets, separated
+by a slash. This is pretty much useful only to find out whether Perl's
+(compiled in) hashing algorithm is performing poorly on your data set.
+For example, you stick 10,000 things in a hash, but evaluating %HASH in
+scalar context reveals "1/16", which means only one out of sixteen buckets
+has been touched, and presumably contains all 10,000 of your items. This
+isn't supposed to happen.)
+
+You can preallocate space for a hash by assigning to the keys() function.
+This rounds up the allocated bucked to the next power of two:
+
+ keys(%users) = 1000; # allocate 1024 buckets
+
+=head2 Scalar value constructors
+
+Numeric literals are specified in any of the customary floating point or
+integer formats:
+
+ 12345
+ 12345.67
+ .23E-10
+ 0xffff # hex
+ 0377 # octal
+ 4_294_967_296 # underline for legibility
+
+String literals are usually delimited by either single or double
+quotes. They work much like shell quotes: double-quoted string
+literals are subject to backslash and variable substitution;
+single-quoted strings are not (except for "C<\'>" and "C<\\>").
+The usual Unix backslash rules apply for making characters such as
+newline, tab, etc., as well as some more exotic forms. See
+L<perlop/Quote and Quotelike Operators> for a list.
+
+Octal or hex representations in string literals (e.g. '0xffff') are not
+automatically converted to their integer representation. The hex() and
+oct() functions make these conversions for you. See L<perlfunc/hex> and
+L<perlfunc/oct> for more details.
+
+You can also embed newlines directly in your strings, i.e., they can end
+on a different line than they begin. This is nice, but if you forget
+your trailing quote, the error will not be reported until Perl finds
+another line containing the quote character, which may be much further
+on in the script. Variable substitution inside strings is limited to
+scalar variables, arrays, and array slices. (In other words,
+names beginning with $ or @, followed by an optional bracketed
+expression as a subscript.) The following code segment prints out "The
+price is $Z<>100."
+
+ $Price = '$100'; # not interpreted
+ print "The price is $Price.\n"; # interpreted
+
+As in some shells, you can put curly brackets around the name to
+delimit it from following alphanumerics. In fact, an identifier
+within such curlies is forced to be a string, as is any single
+identifier within a hash subscript. Our earlier example,
+
+ $days{'Feb'}
+
+can be written as
+
+ $days{Feb}
+
+and the quotes will be assumed automatically. But anything more complicated
+in the subscript will be interpreted as an expression.
+
+Note that a
+single-quoted string must be separated from a preceding word by a
+space, because single quote is a valid (though deprecated) character in
+a variable name (see L<perlmod/Packages>).
+
+Three special literals are __FILE__, __LINE__, and __PACKAGE__, which
+represent the current filename, line number, and package name at that
+point in your program. They may be used only as separate tokens; they
+will not be interpolated into strings. If there is no current package
+(due to an empty C<package;> directive), __PACKAGE__ is the undefined value.
+
+The tokens __END__ and __DATA__ may be used to indicate the logical end
+of the script before the actual end of file. Any following text is
+ignored, but may be read via a DATA filehandle: main::DATA for __END__,
+or PACKNAME::DATA (where PACKNAME is the current package) for __DATA__.
+The two control characters ^D and ^Z are synonyms for __END__ (or
+__DATA__ in a module). See L<SelfLoader> for more description of
+__DATA__, and an example of its use. Note that you cannot read from the
+DATA filehandle in a BEGIN block: the BEGIN block is executed as soon as
+it is seen (during compilation), at which point the corresponding
+__DATA__ (or __END__) token has not yet been seen.
+
+A word that has no other interpretation in the grammar will
+be treated as if it were a quoted string. These are known as
+"barewords". As with filehandles and labels, a bareword that consists
+entirely of lowercase letters risks conflict with future reserved
+words, and if you use the B<-w> switch, Perl will warn you about any
+such words. Some people may wish to outlaw barewords entirely. If you
+say
+
+ use strict 'subs';
+
+then any bareword that would NOT be interpreted as a subroutine call
+produces a compile-time error instead. The restriction lasts to the
+end of the enclosing block. An inner block may countermand this
+by saying C<no strict 'subs'>.
+
+Array variables are interpolated into double-quoted strings by joining all
+the elements of the array with the delimiter specified in the C<$">
+variable (C<$LIST_SEPARATOR> in English), space by default. The following
+are equivalent:
+
+ $temp = join($",@ARGV);
+ system "echo $temp";
+
+ system "echo @ARGV";
+
+Within search patterns (which also undergo double-quotish substitution)
+there is a bad ambiguity: Is C</$foo[bar]/> to be interpreted as
+C</${foo}[bar]/> (where C<[bar]> is a character class for the regular
+expression) or as C</${foo[bar]}/> (where C<[bar]> is the subscript to array
+@foo)? If @foo doesn't otherwise exist, then it's obviously a
+character class. If @foo exists, Perl takes a good guess about C<[bar]>,
+and is almost always right. If it does guess wrong, or if you're just
+plain paranoid, you can force the correct interpretation with curly
+brackets as above.
+
+A line-oriented form of quoting is based on the shell "here-doc"
+syntax. Following a C<E<lt>E<lt>> you specify a string to terminate
+the quoted material, and all lines following the current line down to
+the terminating string are the value of the item. The terminating
+string may be either an identifier (a word), or some quoted text. If
+quoted, the type of quotes you use determines the treatment of the
+text, just as in regular quoting. An unquoted identifier works like
+double quotes. There must be no space between the C<E<lt>E<lt>> and
+the identifier. (If you put a space it will be treated as a null
+identifier, which is valid, and matches the first empty line.) The
+terminating string must appear by itself (unquoted and with no
+surrounding whitespace) on the terminating line.
+
+ print <<EOF;
+ The price is $Price.
+ EOF
+
+ print <<"EOF"; # same as above
+ The price is $Price.
+ EOF
+
+ print <<`EOC`; # execute commands
+ echo hi there
+ echo lo there
+ EOC
+
+ print <<"foo", <<"bar"; # you can stack them
+ I said foo.
+ foo
+ I said bar.
+ bar
+
+ myfunc(<<"THIS", 23, <<'THAT');
+ Here's a line
+ or two.
+ THIS
+ and here's another.
+ THAT
+
+Just don't forget that you have to put a semicolon on the end
+to finish the statement, as Perl doesn't know you're not going to
+try to do this:
+
+ print <<ABC
+ 179231
+ ABC
+ + 20;
+
+
+=head2 List value constructors
+
+List values are denoted by separating individual values by commas
+(and enclosing the list in parentheses where precedence requires it):
+
+ (LIST)
+
+In a context not requiring a list value, the value of the list
+literal is the value of the final element, as with the C comma operator.
+For example,
+
+ @foo = ('cc', '-E', $bar);
+
+assigns the entire list value to array foo, but
+
+ $foo = ('cc', '-E', $bar);
+
+assigns the value of variable bar to variable foo. Note that the value
+of an actual array in a scalar context is the length of the array; the
+following assigns the value 3 to $foo:
+
+ @foo = ('cc', '-E', $bar);
+ $foo = @foo; # $foo gets 3
+
+You may have an optional comma before the closing parenthesis of a
+list literal, so that you can say:
+
+ @foo = (
+ 1,
+ 2,
+ 3,
+ );
+
+LISTs do automatic interpolation of sublists. That is, when a LIST is
+evaluated, each element of the list is evaluated in a list context, and
+the resulting list value is interpolated into LIST just as if each
+individual element were a member of LIST. Thus arrays and hashes lose their
+identity in a LIST--the list
+
+ (@foo,@bar,&SomeSub,%glarch)
+
+contains all the elements of @foo followed by all the elements of @bar,
+followed by all the elements returned by the subroutine named SomeSub
+called in a list context, followed by the key/value pairs of %glarch.
+To make a list reference that does I<NOT> interpolate, see L<perlref>.
+
+The null list is represented by (). Interpolating it in a list
+has no effect. Thus ((),(),()) is equivalent to (). Similarly,
+interpolating an array with no elements is the same as if no
+array had been interpolated at that point.
+
+A list value may also be subscripted like a normal array. You must
+put the list in parentheses to avoid ambiguity. For example:
+
+ # Stat returns list value.
+ $time = (stat($file))[8];
+
+ # SYNTAX ERROR HERE.
+ $time = stat($file)[8]; # OOPS, FORGOT PARENTHESES
+
+ # Find a hex digit.
+ $hexdigit = ('a','b','c','d','e','f')[$digit-10];
+
+ # A "reverse comma operator".
+ return (pop(@foo),pop(@foo))[0];
+
+You may assign to C<undef> in a list. This is useful for throwing
+away some of the return values of a function:
+
+ ($dev, $ino, undef, undef, $uid, $gid) = stat($file);
+
+Lists may be assigned to if and only if each element of the list
+is legal to assign to:
+
+ ($a, $b, $c) = (1, 2, 3);
+
+ ($map{'red'}, $map{'blue'}, $map{'green'}) = (0x00f, 0x0f0, 0xf00);
+
+Array assignment in a scalar context returns the number of elements
+produced by the expression on the right side of the assignment:
+
+ $x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
+ $x = (($foo,$bar) = f()); # set $x to f()'s return count
+
+This is very handy when you want to do a list assignment in a Boolean
+context, because most list functions return a null list when finished,
+which when assigned produces a 0, which is interpreted as FALSE.
+
+The final element may be an array or a hash:
+
+ ($a, $b, @rest) = split;
+ my($a, $b, %rest) = @_;
+
+You can actually put an array or hash anywhere in the list, but the first one
+in the list will soak up all the values, and anything after it will get
+a null value. This may be useful in a local() or my().
+
+A hash literal contains pairs of values to be interpreted
+as a key and a value:
+
+ # same as map assignment above
+ %map = ('red',0x00f,'blue',0x0f0,'green',0xf00);
+
+While literal lists and named arrays are usually interchangeable, that's
+not the case for hashes. Just because you can subscript a list value like
+a normal array does not mean that you can subscript a list value as a
+hash. Likewise, hashes included as parts of other lists (including
+parameters lists and return lists from functions) always flatten out into
+key/value pairs. That's why it's good to use references sometimes.
+
+It is often more readable to use the C<=E<gt>> operator between key/value
+pairs. The C<=E<gt>> operator is mostly just a more visually distinctive
+synonym for a comma, but it also arranges for its left-hand operand to be
+interpreted as a string--if it's a bareword that would be a legal identifier.
+This makes it nice for initializing hashes:
+
+ %map = (
+ red => 0x00f,
+ blue => 0x0f0,
+ green => 0xf00,
+ );
+
+or for initializing hash references to be used as records:
+
+ $rec = {
+ witch => 'Mable the Merciless',
+ cat => 'Fluffy the Ferocious',
+ date => '10/31/1776',
+ };
+
+or for using call-by-named-parameter to complicated functions:
+
+ $field = $query->radio_group(
+ name => 'group_name',
+ values => ['eenie','meenie','minie'],
+ default => 'meenie',
+ linebreak => 'true',
+ labels => \%labels
+ );
+
+Note that just because a hash is initialized in that order doesn't
+mean that it comes out in that order. See L<perlfunc/sort> for examples
+of how to arrange for an output ordering.
+
+=head2 Typeglobs and Filehandles
+
+Perl uses an internal type called a I<typeglob> to hold an entire
+symbol table entry. The type prefix of a typeglob is a C<*>, because
+it represents all types. This used to be the preferred way to
+pass arrays and hashes by reference into a function, but now that
+we have real references, this is seldom needed.
+
+The main use of typeglobs in modern Perl is create symbol table aliases.
+This assignment:
+
+ *this = *that;
+
+makes $this an alias for $that, @this an alias for @that, %this an alias
+for %that, &this an alias for &that, etc. Much safer is to use a reference.
+This:
+
+ local *Here::blue = \$There::green;
+
+temporarily makes $Here::blue an alias for $There::green, but doesn't
+make @Here::blue an alias for @There::green, or %Here::blue an alias for
+%There::green, etc. See L<perlmod/"Symbol Tables"> for more examples
+of this. Strange though this may seem, this is the basis for the whole
+module import/export system.
+
+Another use for typeglobs is to to pass filehandles into a function or
+to create new filehandles. If you need to use a typeglob to save away
+a filehandle, do it this way:
+
+ $fh = *STDOUT;
+
+or perhaps as a real reference, like this:
+
+ $fh = \*STDOUT;
+
+See L<perlsub> for examples of using these as indirect filehandles
+in functions.
+
+Typeglobs are also a way to create a local filehandle using the local()
+operator. These last until their block is exited, but may be passed back.
+For example:
+
+ sub newopen {
+ my $path = shift;
+ local *FH; # not my!
+ open (FH, $path) or return undef;
+ return *FH;
+ }
+ $fh = newopen('/etc/passwd');
+
+Now that we have the *foo{THING} notation, typeglobs aren't used as much
+for filehandle manipulations, although they're still needed to pass brand
+new file and directory handles into or out of functions. That's because
+*HANDLE{IO} only works if HANDLE has already been used as a handle.
+In other words, *FH can be used to create new symbol table entries,
+but *foo{THING} cannot.
+
+Another way to create anonymous filehandles is with the IO::Handle
+module and its ilk. These modules have the advantage of not hiding
+different types of the same name during the local(). See the bottom of
+L<perlfunc/open()> for an example.
+
+See L<perlref>, L<perlsub>, and L<perlmod/"Symbol Tables"> for more
+discussion on typeglobs and the *foo{THING} syntax.
diff --git a/contrib/perl5/pod/perldebug.pod b/contrib/perl5/pod/perldebug.pod
new file mode 100644
index 0000000..7a6e814
--- /dev/null
+++ b/contrib/perl5/pod/perldebug.pod
@@ -0,0 +1,1661 @@
+=head1 NAME
+
+perldebug - Perl debugging
+
+=head1 DESCRIPTION
+
+First of all, have you tried using the B<-w> switch?
+
+=head1 The Perl Debugger
+
+"As soon as we started programming, we found to our
+surprise that it wasn't as easy to get programs right
+as we had thought. Debugging had to be discovered.
+I can remember the exact instant when I realized that
+a large part of my life from then on was going to be
+spent in finding mistakes in my own programs."
+
+I< --Maurice Wilkes, 1949>
+
+If you invoke Perl with the B<-d> switch, your script runs under the
+Perl source debugger. This works like an interactive Perl
+environment, prompting for debugger commands that let you examine
+source code, set breakpoints, get stack backtraces, change the values of
+variables, etc. This is so convenient that you often fire up
+the debugger all by itself just to test out Perl constructs
+interactively to see what they do. For example:
+
+ perl -d -e 42
+
+In Perl, the debugger is not a separate program as it usually is in the
+typical compiled environment. Instead, the B<-d> flag tells the compiler
+to insert source information into the parse trees it's about to hand off
+to the interpreter. That means your code must first compile correctly
+for the debugger to work on it. Then when the interpreter starts up, it
+preloads a Perl library file containing the debugger itself.
+
+The program will halt I<right before> the first run-time executable
+statement (but see below regarding compile-time statements) and ask you
+to enter a debugger command. Contrary to popular expectations, whenever
+the debugger halts and shows you a line of code, it always displays the
+line it's I<about> to execute, rather than the one it has just executed.
+
+Any command not recognized by the debugger is directly executed
+(C<eval>'d) as Perl code in the current package. (The debugger uses the
+DB package for its own state information.)
+
+Leading white space before a command would cause the debugger to think
+it's I<NOT> a debugger command but for Perl, so be careful not to do
+that.
+
+=head2 Debugger Commands
+
+The debugger understands the following commands:
+
+=over 12
+
+=item h [command]
+
+Prints out a help message.
+
+If you supply another debugger command as an argument to the C<h> command,
+it prints out the description for just that command. The special
+argument of C<h h> produces a more compact help listing, designed to fit
+together on one screen.
+
+If the output of the C<h> command (or any command, for that matter) scrolls
+past your screen, either precede the command with a leading pipe symbol so
+it's run through your pager, as in
+
+ DB> |h
+
+You may change the pager which is used via C<O pager=...> command.
+
+=item p expr
+
+Same as C<print {$DB::OUT} expr> in the current package. In particular,
+because this is just Perl's own B<print> function, this means that nested
+data structures and objects are not dumped, unlike with the C<x> command.
+
+The C<DB::OUT> filehandle is opened to F</dev/tty>, regardless of
+where STDOUT may be redirected to.
+
+=item x expr
+
+Evaluates its expression in list context and dumps out the result
+in a pretty-printed fashion. Nested data structures are printed out
+recursively, unlike the C<print> function.
+
+The details of printout are governed by multiple C<O>ptions.
+
+=item V [pkg [vars]]
+
+Display all (or some) variables in package (defaulting to the C<main>
+package) using a data pretty-printer (hashes show their keys and values so
+you see what's what, control characters are made printable, etc.). Make
+sure you don't put the type specifier (like C<$>) there, just the symbol
+names, like this:
+
+ V DB filename line
+
+Use C<~pattern> and C<!pattern> for positive and negative regexps.
+
+Nested data structures are printed out in a legible fashion, unlike
+the C<print> function.
+
+The details of printout are governed by multiple C<O>ptions.
+
+=item X [vars]
+
+Same as C<V currentpackage [vars]>.
+
+=item T
+
+Produce a stack backtrace. See below for details on its output.
+
+=item s [expr]
+
+Single step. Executes until it reaches the beginning of another
+statement, descending into subroutine calls. If an expression is
+supplied that includes function calls, it too will be single-stepped.
+
+=item n [expr]
+
+Next. Executes over subroutine calls, until it reaches the beginning
+of the next statement. If an expression is supplied that includes
+function calls, those functions will be executed with stops before
+each statement.
+
+=item E<lt>CRE<gt>
+
+Repeat last C<n> or C<s> command.
+
+=item c [line|sub]
+
+Continue, optionally inserting a one-time-only breakpoint
+at the specified line or subroutine.
+
+=item l
+
+List next window of lines.
+
+=item l min+incr
+
+List C<incr+1> lines starting at C<min>.
+
+=item l min-max
+
+List lines C<min> through C<max>. C<l -> is synonymous to C<->.
+
+=item l line
+
+List a single line.
+
+=item l subname
+
+List first window of lines from subroutine.
+
+=item -
+
+List previous window of lines.
+
+=item w [line]
+
+List window (a few lines) around the current line.
+
+=item .
+
+Return debugger pointer to the last-executed line and
+print it out.
+
+=item f filename
+
+Switch to viewing a different file or eval statement. If C<filename>
+is not a full filename as found in values of %INC, it is considered as
+a regexp.
+
+=item /pattern/
+
+Search forwards for pattern; final / is optional.
+
+=item ?pattern?
+
+Search backwards for pattern; final ? is optional.
+
+=item L
+
+List all breakpoints and actions.
+
+=item S [[!]pattern]
+
+List subroutine names [not] matching pattern.
+
+=item t
+
+Toggle trace mode (see also C<AutoTrace> C<O>ption).
+
+=item t expr
+
+Trace through execution of expr. For example:
+
+ $ perl -de 42
+ Stack dump during die enabled outside of evals.
+
+ Loading DB routines from perl5db.pl patch level 0.94
+ Emacs support available.
+
+ Enter h or `h h' for help.
+
+ main::(-e:1): 0
+ DB<1> sub foo { 14 }
+
+ DB<2> sub bar { 3 }
+
+ DB<3> t print foo() * bar()
+ main::((eval 172):3): print foo() + bar();
+ main::foo((eval 168):2):
+ main::bar((eval 170):2):
+ 42
+
+or, with the C<O>ption C<frame=2> set,
+
+ DB<4> O f=2
+ frame = '2'
+ DB<5> t print foo() * bar()
+ 3: foo() * bar()
+ entering main::foo
+ 2: sub foo { 14 };
+ exited main::foo
+ entering main::bar
+ 2: sub bar { 3 };
+ exited main::bar
+ 42
+
+=item b [line] [condition]
+
+Set a breakpoint. If line is omitted, sets a breakpoint on the line
+that is about to be executed. If a condition is specified, it's
+evaluated each time the statement is reached and a breakpoint is taken
+only if the condition is true. Breakpoints may be set on only lines
+that begin an executable statement. Conditions don't use B<if>:
+
+ b 237 $x > 30
+ b 237 ++$count237 < 11
+ b 33 /pattern/i
+
+=item b subname [condition]
+
+Set a breakpoint at the first line of the named subroutine.
+
+=item b postpone subname [condition]
+
+Set breakpoint at first line of subroutine after it is compiled.
+
+=item b load filename
+
+Set breakpoint at the first executed line of the file. Filename should
+be a full name as found in values of %INC.
+
+=item b compile subname
+
+Sets breakpoint at the first statement executed after the subroutine
+is compiled.
+
+=item d [line]
+
+Delete a breakpoint at the specified line. If line is omitted, deletes
+the breakpoint on the line that is about to be executed.
+
+=item D
+
+Delete all installed breakpoints.
+
+=item a [line] command
+
+Set an action to be done before the line is executed.
+The sequence of steps taken by the debugger is
+
+ 1. check for a breakpoint at this line
+ 2. print the line if necessary (tracing)
+ 3. do any actions associated with that line
+ 4. prompt user if at a breakpoint or in single-step
+ 5. evaluate line
+
+For example, this will print out $foo every time line
+53 is passed:
+
+ a 53 print "DB FOUND $foo\n"
+
+=item A
+
+Delete all installed actions.
+
+=item W [expr]
+
+Add a global watch-expression.
+
+=item W
+
+Delete all watch-expressions.
+
+=item O [opt[=val]] [opt"val"] [opt?]...
+
+Set or query values of options. val defaults to 1. opt can
+be abbreviated. Several options can be listed.
+
+=over 12
+
+=item C<recallCommand>, C<ShellBang>
+
+The characters used to recall command or spawn shell. By
+default, these are both set to C<!>.
+
+=item C<pager>
+
+Program to use for output of pager-piped commands (those
+beginning with a C<|> character.) By default,
+C<$ENV{PAGER}> will be used.
+
+=item C<tkRunning>
+
+Run Tk while prompting (with ReadLine).
+
+=item C<signalLevel>, C<warnLevel>, C<dieLevel>
+
+Level of verbosity. By default the debugger is in a sane verbose mode,
+thus it will print backtraces on all the warnings and die-messages
+which are going to be printed out, and will print a message when
+interesting uncaught signals arrive.
+
+To disable this behaviour, set these values to 0. If C<dieLevel> is 2,
+then the messages which will be caught by surrounding C<eval> are also
+printed.
+
+=item C<AutoTrace>
+
+Trace mode (similar to C<t> command, but can be put into
+C<PERLDB_OPTS>).
+
+=item C<LineInfo>
+
+File or pipe to print line number info to. If it is a pipe (say,
+C<|visual_perl_db>), then a short, "emacs like" message is used.
+
+=item C<inhibit_exit>
+
+If 0, allows I<stepping off> the end of the script.
+
+=item C<PrintRet>
+
+affects printing of return value after C<r> command.
+
+=item C<ornaments>
+
+affects screen appearance of the command line (see L<Term::ReadLine>).
+
+=item C<frame>
+
+affects printing messages on entry and exit from subroutines. If
+C<frame & 2> is false, messages are printed on entry only. (Printing
+on exit may be useful if inter(di)spersed with other messages.)
+
+If C<frame & 4>, arguments to functions are printed as well as the
+context and caller info. If C<frame & 8>, overloaded C<stringify> and
+C<tie>d C<FETCH> are enabled on the printed arguments. If C<frame &
+16>, the return value from the subroutine is printed as well.
+
+The length at which the argument list is truncated is governed by the
+next option:
+
+=item C<maxTraceLen>
+
+length at which the argument list is truncated when C<frame> option's
+bit 4 is set.
+
+=back
+
+The following options affect what happens with C<V>, C<X>, and C<x>
+commands:
+
+=over 12
+
+=item C<arrayDepth>, C<hashDepth>
+
+Print only first N elements ('' for all).
+
+=item C<compactDump>, C<veryCompact>
+
+Change style of array and hash dump. If C<compactDump>, short array
+may be printed on one line.
+
+=item C<globPrint>
+
+Whether to print contents of globs.
+
+=item C<DumpDBFiles>
+
+Dump arrays holding debugged files.
+
+=item C<DumpPackages>
+
+Dump symbol tables of packages.
+
+=item C<DumpReused>
+
+Dump contents of "reused" addresses.
+
+=item C<quote>, C<HighBit>, C<undefPrint>
+
+Change style of string dump. Default value of C<quote> is C<auto>, one
+can enable either double-quotish dump, or single-quotish by setting it
+to C<"> or C<'>. By default, characters with high bit set are printed
+I<as is>.
+
+=item C<UsageOnly>
+
+I<very> rudimentally per-package memory usage dump. Calculates total
+size of strings in variables in the package.
+
+=back
+
+During startup options are initialized from C<$ENV{PERLDB_OPTS}>.
+You can put additional initialization options C<TTY>, C<noTTY>,
+C<ReadLine>, and C<NonStop> there.
+
+Example rc file:
+
+ &parse_options("NonStop=1 LineInfo=db.out AutoTrace");
+
+The script will run without human intervention, putting trace information
+into the file I<db.out>. (If you interrupt it, you would better reset
+C<LineInfo> to something "interactive"!)
+
+=over 12
+
+=item C<TTY>
+
+The TTY to use for debugging I/O.
+
+=item C<noTTY>
+
+If set, goes in C<NonStop> mode, and would not connect to a TTY. If
+interrupt (or if control goes to debugger via explicit setting of
+$DB::signal or $DB::single from the Perl script), connects to a TTY
+specified by the C<TTY> option at startup, or to a TTY found at
+runtime using C<Term::Rendezvous> module of your choice.
+
+This module should implement a method C<new> which returns an object
+with two methods: C<IN> and C<OUT>, returning two filehandles to use
+for debugging input and output correspondingly. Method C<new> may
+inspect an argument which is a value of C<$ENV{PERLDB_NOTTY}> at
+startup, or is C<"/tmp/perldbtty$$"> otherwise.
+
+=item C<ReadLine>
+
+If false, readline support in debugger is disabled, so you can debug
+ReadLine applications.
+
+=item C<NonStop>
+
+If set, debugger goes into noninteractive mode until interrupted, or
+programmatically by setting $DB::signal or $DB::single.
+
+=back
+
+Here's an example of using the C<$ENV{PERLDB_OPTS}> variable:
+
+ $ PERLDB_OPTS="N f=2" perl -d myprogram
+
+will run the script C<myprogram> without human intervention, printing
+out the call tree with entry and exit points. Note that C<N f=2> is
+equivalent to C<NonStop=1 frame=2>. Note also that at the moment when
+this documentation was written all the options to the debugger could
+be uniquely abbreviated by the first letter (with exception of
+C<Dump*> options).
+
+Other examples may include
+
+ $ PERLDB_OPTS="N f A L=listing" perl -d myprogram
+
+- runs script noninteractively, printing info on each entry into a
+subroutine and each executed line into the file F<listing>. (If you
+interrupt it, you would better reset C<LineInfo> to something
+"interactive"!)
+
+
+ $ env "PERLDB_OPTS=R=0 TTY=/dev/ttyc" perl -d myprogram
+
+may be useful for debugging a program which uses C<Term::ReadLine>
+itself. Do not forget detach shell from the TTY in the window which
+corresponds to F</dev/ttyc>, say, by issuing a command like
+
+ $ sleep 1000000
+
+See L<"Debugger Internals"> below for more details.
+
+=item E<lt> [ command ]
+
+Set an action (Perl command) to happen before every debugger prompt.
+A multi-line command may be entered by backslashing the newlines. If
+C<command> is missing, resets the list of actions.
+
+=item E<lt>E<lt> command
+
+Add an action (Perl command) to happen before every debugger prompt.
+A multi-line command may be entered by backslashing the newlines.
+
+=item E<gt> command
+
+Set an action (Perl command) to happen after the prompt when you've
+just given a command to return to executing the script. A multi-line
+command may be entered by backslashing the newlines. If C<command> is
+missing, resets the list of actions.
+
+=item E<gt>E<gt> command
+
+Adds an action (Perl command) to happen after the prompt when you've
+just given a command to return to executing the script. A multi-line
+command may be entered by backslashing the newlines.
+
+=item { [ command ]
+
+Set an action (debugger command) to happen before every debugger prompt.
+A multi-line command may be entered by backslashing the newlines. If
+C<command> is missing, resets the list of actions.
+
+=item {{ command
+
+Add an action (debugger command) to happen before every debugger prompt.
+A multi-line command may be entered by backslashing the newlines.
+
+=item ! number
+
+Redo a previous command (default previous command).
+
+=item ! -number
+
+Redo number'th-to-last command.
+
+=item ! pattern
+
+Redo last command that started with pattern.
+See C<O recallCommand>, too.
+
+=item !! cmd
+
+Run cmd in a subprocess (reads from DB::IN, writes to DB::OUT)
+See C<O shellBang> too.
+
+=item H -number
+
+Display last n commands. Only commands longer than one character are
+listed. If number is omitted, lists them all.
+
+=item q or ^D
+
+Quit. ("quit" doesn't work for this.) This is the only supported way
+to exit the debugger, though typing C<exit> twice may do it too.
+
+Set an C<O>ption C<inhibit_exit> to 0 if you want to be able to I<step
+off> the end the script. You may also need to set C<$finished> to 0 at
+some moment if you want to step through global destruction.
+
+=item R
+
+Restart the debugger by B<exec>ing a new session. It tries to maintain
+your history across this, but internal settings and command line options
+may be lost.
+
+Currently the following setting are preserved: history, breakpoints,
+actions, debugger C<O>ptions, and the following command line
+options: B<-w>, B<-I>, and B<-e>.
+
+=item |dbcmd
+
+Run debugger command, piping DB::OUT to current pager.
+
+=item ||dbcmd
+
+Same as C<|dbcmd> but DB::OUT is temporarily B<select>ed as well.
+Often used with commands that would otherwise produce long
+output, such as
+
+ |V main
+
+=item = [alias value]
+
+Define a command alias, like
+
+ = quit q
+
+or list current aliases.
+
+=item command
+
+Execute command as a Perl statement. A missing semicolon will be
+supplied.
+
+=item m expr
+
+The expression is evaluated, and the methods which may be applied to
+the result are listed.
+
+=item m package
+
+The methods which may be applied to objects in the C<package> are listed.
+
+=back
+
+=head2 Debugger input/output
+
+=over 8
+
+=item Prompt
+
+The debugger prompt is something like
+
+ DB<8>
+
+or even
+
+ DB<<17>>
+
+where that number is the command number, which you'd use to access with
+the builtin B<csh>-like history mechanism, e.g., C<!17> would repeat
+command number 17. The number of angle brackets indicates the depth of
+the debugger. You could get more than one set of brackets, for example, if
+you'd already at a breakpoint and then printed out the result of a
+function call that itself also has a breakpoint, or you step into an
+expression via C<s/n/t expression> command.
+
+=item Multiline commands
+
+If you want to enter a multi-line command, such as a subroutine
+definition with several statements, or a format, you may escape the
+newline that would normally end the debugger command with a backslash.
+Here's an example:
+
+ DB<1> for (1..4) { \
+ cont: print "ok\n"; \
+ cont: }
+ ok
+ ok
+ ok
+ ok
+
+Note that this business of escaping a newline is specific to interactive
+commands typed into the debugger.
+
+=item Stack backtrace
+
+Here's an example of what a stack backtrace via C<T> command might
+look like:
+
+ $ = main::infested called from file `Ambulation.pm' line 10
+ @ = Ambulation::legs(1, 2, 3, 4) called from file `camel_flea' line 7
+ $ = main::pests('bactrian', 4) called from file `camel_flea' line 4
+
+The left-hand character up there tells whether the function was called
+in a scalar or list context (we bet you can tell which is which). What
+that says is that you were in the function C<main::infested> when you ran
+the stack dump, and that it was called in a scalar context from line 10
+of the file I<Ambulation.pm>, but without any arguments at all, meaning
+it was called as C<&infested>. The next stack frame shows that the
+function C<Ambulation::legs> was called in a list context from the
+I<camel_flea> file with four arguments. The last stack frame shows that
+C<main::pests> was called in a scalar context, also from I<camel_flea>,
+but from line 4.
+
+Note that if you execute C<T> command from inside an active C<use>
+statement, the backtrace will contain both C<require>
+frame and an C<eval>) frame.
+
+=item Listing
+
+Listing given via different flavors of C<l> command looks like this:
+
+ DB<<13>> l
+ 101: @i{@i} = ();
+ 102:b @isa{@i,$pack} = ()
+ 103 if(exists $i{$prevpack} || exists $isa{$pack});
+ 104 }
+ 105
+ 106 next
+ 107==> if(exists $isa{$pack});
+ 108
+ 109:a if ($extra-- > 0) {
+ 110: %isa = ($pack,1);
+
+Note that the breakable lines are marked with C<:>, lines with
+breakpoints are marked by C<b>, with actions by C<a>, and the
+next executed line is marked by C<==E<gt>>.
+
+=item Frame listing
+
+When C<frame> option is set, debugger would print entered (and
+optionally exited) subroutines in different styles.
+
+What follows is the start of the listing of
+
+ env "PERLDB_OPTS=f=n N" perl -d -V
+
+for different values of C<n>:
+
+=over 4
+
+=item 1
+
+ entering main::BEGIN
+ entering Config::BEGIN
+ Package lib/Exporter.pm.
+ Package lib/Carp.pm.
+ Package lib/Config.pm.
+ entering Config::TIEHASH
+ entering Exporter::import
+ entering Exporter::export
+ entering Config::myconfig
+ entering Config::FETCH
+ entering Config::FETCH
+ entering Config::FETCH
+ entering Config::FETCH
+
+=item 2
+
+ entering main::BEGIN
+ entering Config::BEGIN
+ Package lib/Exporter.pm.
+ Package lib/Carp.pm.
+ exited Config::BEGIN
+ Package lib/Config.pm.
+ entering Config::TIEHASH
+ exited Config::TIEHASH
+ entering Exporter::import
+ entering Exporter::export
+ exited Exporter::export
+ exited Exporter::import
+ exited main::BEGIN
+ entering Config::myconfig
+ entering Config::FETCH
+ exited Config::FETCH
+ entering Config::FETCH
+ exited Config::FETCH
+ entering Config::FETCH
+
+=item 4
+
+ in $=main::BEGIN() from /dev/nul:0
+ in $=Config::BEGIN() from lib/Config.pm:2
+ Package lib/Exporter.pm.
+ Package lib/Carp.pm.
+ Package lib/Config.pm.
+ in $=Config::TIEHASH('Config') from lib/Config.pm:644
+ in $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
+ in $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from li
+ in @=Config::myconfig() from /dev/nul:0
+ in $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'SUBVERSION') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'osname') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'osvers') from lib/Config.pm:574
+
+=item 6
+
+ in $=main::BEGIN() from /dev/nul:0
+ in $=Config::BEGIN() from lib/Config.pm:2
+ Package lib/Exporter.pm.
+ Package lib/Carp.pm.
+ out $=Config::BEGIN() from lib/Config.pm:0
+ Package lib/Config.pm.
+ in $=Config::TIEHASH('Config') from lib/Config.pm:644
+ out $=Config::TIEHASH('Config') from lib/Config.pm:644
+ in $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
+ in $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
+ out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
+ out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
+ out $=main::BEGIN() from /dev/nul:0
+ in @=Config::myconfig() from /dev/nul:0
+ in $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
+ out $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
+ out $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
+ out $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
+ in $=Config::FETCH(ref(Config), 'SUBVERSION') from lib/Config.pm:574
+
+=item 14
+
+ in $=main::BEGIN() from /dev/nul:0
+ in $=Config::BEGIN() from lib/Config.pm:2
+ Package lib/Exporter.pm.
+ Package lib/Carp.pm.
+ out $=Config::BEGIN() from lib/Config.pm:0
+ Package lib/Config.pm.
+ in $=Config::TIEHASH('Config') from lib/Config.pm:644
+ out $=Config::TIEHASH('Config') from lib/Config.pm:644
+ in $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
+ in $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
+ out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
+ out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
+ out $=main::BEGIN() from /dev/nul:0
+ in @=Config::myconfig() from /dev/nul:0
+ in $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
+ out $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
+ in $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
+ out $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
+
+=item 30
+
+ in $=CODE(0x15eca4)() from /dev/null:0
+ in $=CODE(0x182528)() from lib/Config.pm:2
+ Package lib/Exporter.pm.
+ out $=CODE(0x182528)() from lib/Config.pm:0
+ scalar context return from CODE(0x182528): undef
+ Package lib/Config.pm.
+ in $=Config::TIEHASH('Config') from lib/Config.pm:628
+ out $=Config::TIEHASH('Config') from lib/Config.pm:628
+ scalar context return from Config::TIEHASH: empty hash
+ in $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
+ in $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
+ out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
+ scalar context return from Exporter::export: ''
+ out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
+ scalar context return from Exporter::import: ''
+
+
+=back
+
+In all the cases indentation of lines shows the call tree, if bit 2 of
+C<frame> is set, then a line is printed on exit from a subroutine as
+well, if bit 4 is set, then the arguments are printed as well as the
+caller info, if bit 8 is set, the arguments are printed even if they
+are tied or references, if bit 16 is set, the return value is printed
+as well.
+
+When a package is compiled, a line like this
+
+ Package lib/Carp.pm.
+
+is printed with proper indentation.
+
+=back
+
+=head2 Debugging compile-time statements
+
+If you have any compile-time executable statements (code within a BEGIN
+block or a C<use> statement), these will C<NOT> be stopped by debugger,
+although C<require>s will (and compile-time statements can be traced
+with C<AutoTrace> option set in C<PERLDB_OPTS>). From your own Perl
+code, however, you can
+transfer control back to the debugger using the following statement,
+which is harmless if the debugger is not running:
+
+ $DB::single = 1;
+
+If you set C<$DB::single> to the value 2, it's equivalent to having
+just typed the C<n> command, whereas a value of 1 means the C<s>
+command. The C<$DB::trace> variable should be set to 1 to simulate
+having typed the C<t> command.
+
+Another way to debug compile-time code is to start debugger, set a
+breakpoint on I<load> of some module thusly
+
+ DB<7> b load f:/perllib/lib/Carp.pm
+ Will stop on load of `f:/perllib/lib/Carp.pm'.
+
+and restart debugger by C<R> command (if possible). One can use C<b
+compile subname> for the same purpose.
+
+=head2 Debugger Customization
+
+Most probably you do not want to modify the debugger, it contains enough
+hooks to satisfy most needs. You may change the behaviour of debugger
+from the debugger itself, using C<O>ptions, from the command line via
+C<PERLDB_OPTS> environment variable, and from I<customization files>.
+
+You can do some customization by setting up a F<.perldb> file which
+contains initialization code. For instance, you could make aliases
+like these (the last one is one people expect to be there):
+
+ $DB::alias{'len'} = 's/^len(.*)/p length($1)/';
+ $DB::alias{'stop'} = 's/^stop (at|in)/b/';
+ $DB::alias{'ps'} = 's/^ps\b/p scalar /';
+ $DB::alias{'quit'} = 's/^quit(\s*)/exit\$/';
+
+One changes options from F<.perldb> file via calls like this one;
+
+ parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=2");
+
+(the code is executed in the package C<DB>). Note that F<.perldb> is
+processed before processing C<PERLDB_OPTS>. If F<.perldb> defines the
+subroutine C<afterinit>, it is called after all the debugger
+initialization ends. F<.perldb> may be contained in the current
+directory, or in the C<LOGDIR>/C<HOME> directory.
+
+If you want to modify the debugger, copy F<perl5db.pl> from the Perl
+library to another name and modify it as necessary. You'll also want
+to set your C<PERL5DB> environment variable to say something like this:
+
+ BEGIN { require "myperl5db.pl" }
+
+As the last resort, one can use C<PERL5DB> to customize debugger by
+directly setting internal variables or calling debugger functions.
+
+=head2 Readline Support
+
+As shipped, the only command line history supplied is a simplistic one
+that checks for leading exclamation points. However, if you install
+the Term::ReadKey and Term::ReadLine modules from CPAN, you will
+have full editing capabilities much like GNU I<readline>(3) provides.
+Look for these in the F<modules/by-module/Term> directory on CPAN.
+
+A rudimentary command line completion is also available.
+Unfortunately, the names of lexical variables are not available for
+completion.
+
+=head2 Editor Support for Debugging
+
+If you have GNU B<emacs> installed on your system, it can interact with
+the Perl debugger to provide an integrated software development
+environment reminiscent of its interactions with C debuggers.
+
+Perl is also delivered with a start file for making B<emacs> act like a
+syntax-directed editor that understands (some of) Perl's syntax. Look in
+the I<emacs> directory of the Perl source distribution.
+
+(Historically, a similar setup for interacting with B<vi> and the
+X11 window system had also been available, but at the time of this
+writing, no debugger support for B<vi> currently exists.)
+
+=head2 The Perl Profiler
+
+If you wish to supply an alternative debugger for Perl to run, just
+invoke your script with a colon and a package argument given to the B<-d>
+flag. One of the most popular alternative debuggers for Perl is
+B<DProf>, the Perl profiler. As of this writing, B<DProf> is not
+included with the standard Perl distribution, but it is expected to
+be included soon, for certain values of "soon".
+
+Meanwhile, you can fetch the Devel::Dprof module from CPAN. Assuming
+it's properly installed on your system, to profile your Perl program in
+the file F<mycode.pl>, just type:
+
+ perl -d:DProf mycode.pl
+
+When the script terminates the profiler will dump the profile information
+to a file called F<tmon.out>. A tool like B<dprofpp> (also supplied with
+the Devel::DProf package) can be used to interpret the information which is
+in that profile.
+
+=head2 Debugger support in perl
+
+When you call the B<caller> function (see L<perlfunc/caller>) from the
+package DB, Perl sets the array @DB::args to contain the arguments the
+corresponding stack frame was called with.
+
+If perl is run with B<-d> option, the following additional features
+are enabled (cf. L<perlvar/$^P>):
+
+=over
+
+=item *
+
+Perl inserts the contents of C<$ENV{PERL5DB}> (or C<BEGIN {require
+'perl5db.pl'}> if not present) before the first line of the
+application.
+
+=item *
+
+The array C<@{"_E<lt>$filename"}> is the line-by-line contents of
+$filename for all the compiled files. Same for C<eval>ed strings which
+contain subroutines, or which are currently executed. The C<$filename>
+for C<eval>ed strings looks like C<(eval 34)>.
+
+=item *
+
+The hash C<%{"_E<lt>$filename"}> contains breakpoints and action (it is
+keyed by line number), and individual entries are settable (as opposed
+to the whole hash). Only true/false is important to Perl, though the
+values used by F<perl5db.pl> have the form
+C<"$break_condition\0$action">. Values are magical in numeric context:
+they are zeros if the line is not breakable.
+
+Same for evaluated strings which contain subroutines, or which are
+currently executed. The $filename for C<eval>ed strings looks like
+C<(eval 34)>.
+
+=item *
+
+The scalar C<${"_E<lt>$filename"}> contains C<"_E<lt>$filename">. Same for
+evaluated strings which contain subroutines, or which are currently
+executed. The $filename for C<eval>ed strings looks like C<(eval
+34)>.
+
+=item *
+
+After each C<require>d file is compiled, but before it is executed,
+C<DB::postponed(*{"_E<lt>$filename"})> is called (if subroutine
+C<DB::postponed> exists). Here the $filename is the expanded name of
+the C<require>d file (as found in values of %INC).
+
+=item *
+
+After each subroutine C<subname> is compiled existence of
+C<$DB::postponed{subname}> is checked. If this key exists,
+C<DB::postponed(subname)> is called (if subroutine C<DB::postponed>
+exists).
+
+=item *
+
+A hash C<%DB::sub> is maintained, with keys being subroutine names,
+values having the form C<filename:startline-endline>. C<filename> has
+the form C<(eval 31)> for subroutines defined inside C<eval>s.
+
+=item *
+
+When execution of the application reaches a place that can have
+a breakpoint, a call to C<DB::DB()> is performed if any one of
+variables $DB::trace, $DB::single, or $DB::signal is true. (Note that
+these variables are not C<local>izable.) This feature is disabled when
+the control is inside C<DB::DB()> or functions called from it (unless
+C<$^D & (1E<lt>E<lt>30)>).
+
+=item *
+
+When execution of the application reaches a subroutine call, a call
+to C<&DB::sub>(I<args>) is performed instead, with C<$DB::sub> being
+the name of the called subroutine. (Unless the subroutine is compiled
+in the package C<DB>.)
+
+=back
+
+Note that if C<&DB::sub> needs some external data to be setup for it
+to work, no subroutine call is possible until this is done. For the
+standard debugger C<$DB::deep> (how many levels of recursion deep into
+the debugger you can go before a mandatory break) gives an example of
+such a dependency.
+
+The minimal working debugger consists of one line
+
+ sub DB::DB {}
+
+which is quite handy as contents of C<PERL5DB> environment
+variable:
+
+ env "PERL5DB=sub DB::DB {}" perl -d your-script
+
+Another (a little bit more useful) minimal debugger can be created
+with the only line being
+
+ sub DB::DB {print ++$i; scalar <STDIN>}
+
+This debugger would print the sequential number of encountered
+statement, and would wait for your C<CR> to continue.
+
+The following debugger is quite functional:
+
+ {
+ package DB;
+ sub DB {}
+ sub sub {print ++$i, " $sub\n"; &$sub}
+ }
+
+It prints the sequential number of subroutine call and the name of the
+called subroutine. Note that C<&DB::sub> should be compiled into the
+package C<DB>.
+
+=head2 Debugger Internals
+
+At the start, the debugger reads your rc file (F<./.perldb> or
+F<~/.perldb> under Unix), which can set important options. This file may
+define a subroutine C<&afterinit> to be executed after the debugger is
+initialized.
+
+After the rc file is read, the debugger reads environment variable
+PERLDB_OPTS and parses it as a rest of C<O ...> line in debugger prompt.
+
+It also maintains magical internal variables, such as C<@DB::dbline>,
+C<%DB::dbline>, which are aliases for C<@{"::_<current_file"}>
+C<%{"::_<current_file"}>. Here C<current_file> is the currently
+selected (with the debugger's C<f> command, or by flow of execution)
+file.
+
+Some functions are provided to simplify customization. See L<"Debugger
+Customization"> for description of C<DB::parse_options(string)>. The
+function C<DB::dump_trace(skip[, count])> skips the specified number
+of frames, and returns a list containing info about the caller
+frames (all if C<count> is missing). Each entry is a hash with keys
+C<context> (C<$> or C<@>), C<sub> (subroutine name, or info about
+eval), C<args> (C<undef> or a reference to an array), C<file>, and
+C<line>.
+
+The function C<DB::print_trace(FH, skip[, count[, short]])> prints
+formatted info about caller frames. The last two functions may be
+convenient as arguments to C<E<lt>>, C<E<lt>E<lt>> commands.
+
+=head2 Other resources
+
+You did try the B<-w> switch, didn't you?
+
+=head2 BUGS
+
+You cannot get the stack frame information or otherwise debug functions
+that were not compiled by Perl, such as C or C++ extensions.
+
+If you alter your @_ arguments in a subroutine (such as with B<shift>
+or B<pop>, the stack backtrace will not show the original values.
+
+=head1 Debugging Perl memory usage
+
+Perl is I<very> frivolous with memory. There is a saying that to
+estimate memory usage of Perl, assume a reasonable algorithm of
+allocation, and multiply your estimages by 10. This is not absolutely
+true, but may give you a good grasp of what happens.
+
+Say, an integer cannot take less than 20 bytes of memory, a float
+cannot take less than 24 bytes, a string cannot take less than 32
+bytes (all these examples assume 32-bit architectures, the result are
+much worse on 64-bit architectures). If a variable is accessed in two
+of three different ways (which require an integer, a float, or a
+string), the memory footprint may increase by another 20 bytes. A
+sloppy malloc() implementation will make these numbers yet more.
+
+On the opposite end of the scale, a declaration like
+
+ sub foo;
+
+may take (on some versions of perl) up to 500 bytes of memory.
+
+Off-the-cuff anecdotal estimates of a code bloat give a factor around
+8. This means that the compiled form of reasonable (commented
+indented etc.) code will take approximately 8 times more than the
+disk space the code takes.
+
+There are two Perl-specific ways to analyze the memory usage:
+$ENV{PERL_DEBUG_MSTATS} and B<-DL> switch. First one is available
+only if perl is compiled with Perl's malloc(), the second one only if
+Perl compiled with C<-DDEBUGGING> (as with giving C<-D optimise=-g>
+option to F<Configure>).
+
+=head2 Using C<$ENV{PERL_DEBUG_MSTATS}>
+
+If your perl is using Perl's malloc(), and compiled with correct
+switches (this is the default), then it will print memory usage
+statistics after compiling your code (if C<$ENV{PERL_DEBUG_MSTATS}> >
+1), and before termination of the script (if
+C<$ENV{PERL_DEBUG_MSTATS}> >= 1). The report format is similar to one
+in the following example:
+
+ env PERL_DEBUG_MSTATS=2 perl -e "require Carp"
+ Memory allocation statistics after compilation: (buckets 4(4)..8188(8192)
+ 14216 free: 130 117 28 7 9 0 2 2 1 0 0
+ 437 61 36 0 5
+ 60924 used: 125 137 161 55 7 8 6 16 2 0 1
+ 74 109 304 84 20
+ Total sbrk(): 77824/21:119. Odd ends: pad+heads+chain+tail: 0+636+0+2048.
+ Memory allocation statistics after execution: (buckets 4(4)..8188(8192)
+ 30888 free: 245 78 85 13 6 2 1 3 2 0 1
+ 315 162 39 42 11
+ 175816 used: 265 176 1112 111 26 22 11 27 2 1 1
+ 196 178 1066 798 39
+ Total sbrk(): 215040/47:145. Odd ends: pad+heads+chain+tail: 0+2192+0+6144.
+
+It is possible to ask for such a statistic at arbitrary moment by
+usind Devel::Peek::mstats() (module Devel::Peek is available on CPAN).
+
+Here is the explanation of different parts of the format:
+
+=over
+
+=item C<buckets SMALLEST(APPROX)..GREATEST(APPROX)>
+
+Perl's malloc() uses bucketed allocations. Every request is rounded
+up to the closest bucket size available, and a bucket of these size is
+taken from the pool of the buckets of this size.
+
+The above line describes limits of buckets currently in use. Each
+bucket has two sizes: memory footprint, and the maximal size of user
+data which may be put into this bucket. Say, in the above example the
+smallest bucket is both sizes 4. The biggest bucket has usable size
+8188, and the memory footprint 8192.
+
+With debugging Perl some buckets may have negative usable size. This
+means that these buckets cannot (and will not) be used. For greater
+buckets the memory footprint may be one page greater than a power of
+2. In such a case the corresponding power of two is printed instead
+in the C<APPROX> field above.
+
+=item Free/Used
+
+The following 1 or 2 rows of numbers correspond to the number of
+buckets of each size between C<SMALLEST> and C<GREATEST>. In the
+first row the sizes (memory footprints) of buckets are powers of two
+(or possibly one page greater). In the second row (if present) the
+memory footprints of the buckets are between memory footprints of two
+buckets "above".
+
+Say, with the above example the memory footprints are (with current
+algorith)
+
+ free: 8 16 32 64 128 256 512 1024 2048 4096 8192
+ 4 12 24 48 80
+
+With non-C<DEBUGGING> perl the buckets starting from C<128>-long ones
+have 4-byte overhead, thus 8192-long bucket may take up to
+8188-byte-long allocations.
+
+=item C<Total sbrk(): SBRKed/SBRKs:CONTINUOUS>
+
+The first two fields give the total amount of memory perl sbrk()ed,
+and number of sbrk()s used. The third number is what perl thinks
+about continuity of returned chunks. As far as this number is
+positive, malloc() will assume that it is probable that sbrk() will
+provide continuous memory.
+
+The amounts sbrk()ed by external libraries is not counted.
+
+=item C<pad: 0>
+
+The amount of sbrk()ed memory needed to keep buckets aligned.
+
+=item C<heads: 2192>
+
+While memory overhead of bigger buckets is kept inside the bucket, for
+smaller buckets it is kept in separate areas. This field gives the
+total size of these areas.
+
+=item C<chain: 0>
+
+malloc() may want to subdivide a bigger bucket into smaller buckets.
+If only a part of the deceased-bucket is left non-subdivided, the rest
+is kept as an element of a linked list. This field gives the total
+size of these chunks.
+
+=item C<tail: 6144>
+
+To minimize amount of sbrk()s malloc() asks for more memory. This
+field gives the size of the yet-unused part, which is sbrk()ed, but
+never touched.
+
+=back
+
+=head2 Example of using B<-DL> switch
+
+Below we show how to analyse memory usage by
+
+ do 'lib/auto/POSIX/autosplit.ix';
+
+The file in question contains a header and 146 lines similar to
+
+ sub getcwd ;
+
+B<Note:> I<the discussion below supposes 32-bit architecture. In the
+newer versions of perl the memory usage of the constructs discussed
+here is much improved, but the story discussed below is a real-life
+story. This story is very terse, and assumes more than cursory
+knowledge of Perl internals.>
+
+Here is the itemized list of Perl allocations performed during parsing
+of this file:
+
+ !!! "after" at test.pl line 3.
+ Id subtot 4 8 12 16 20 24 28 32 36 40 48 56 64 72 80 80+
+ 0 02 13752 . . . . 294 . . . . . . . . . . 4
+ 0 54 5545 . . 8 124 16 . . . 1 1 . . . . . 3
+ 5 05 32 . . . . . . . 1 . . . . . . . .
+ 6 02 7152 . . . . . . . . . . 149 . . . . .
+ 7 02 3600 . . . . . 150 . . . . . . . . . .
+ 7 03 64 . -1 . 1 . . 2 . . . . . . . . .
+ 7 04 7056 . . . . . . . . . . . . . . . 7
+ 7 17 38404 . . . . . . . 1 . . 442 149 . . 147 .
+ 9 03 2078 17 249 32 . . . . 2 . . . . . . . .
+
+
+To see this list insert two C<warn('!...')> statements around the call:
+
+ warn('!');
+ do 'lib/auto/POSIX/autosplit.ix';
+ warn('!!! "after"');
+
+and run it with B<-DL> option. The first warn() will print memory
+allocation info before the parsing of the file, and will memorize the
+statistics at this point (we ignore what it prints). The second warn()
+will print increments w.r.t. this memorized statistics. This is the
+above printout.
+
+Different I<Id>s on the left correspond to different subsystems of
+perl interpreter, they are just first argument given to perl memory
+allocation API New(). To find what C<9 03> means C<grep> the perl
+source for C<903>. You will see that it is F<util.c>, function
+savepvn(). This function is used to store a copy of existing chunk of
+memory. Using C debugger, one can see that it is called either
+directly from gv_init(), or via sv_magic(), and gv_init() is called
+from gv_fetchpv() - which is called from newSUB().
+
+B<Note:> to reach this place in debugger and skip all the calls to
+savepvn during the compilation of the main script, set a C breakpoint
+in Perl_warn(), C<continue> this point is reached, I<then> set
+breakpoint in Perl_savepvn(). Note that you may need to skip a
+handful of Perl_savepvn() which do not correspond to mass production
+of CVs (there are more C<903> allocations than 146 similar lines of
+F<lib/auto/POSIX/autosplit.ix>). Note also that C<Perl_> prefixes are
+added by macroization code in perl header files to avoid conflicts
+with external libraries.
+
+Anyway, we see that C<903> ids correspond to creation of globs, twice
+per glob - for glob name, and glob stringification magic.
+
+Here are explanations for other I<Id>s above:
+
+=over
+
+=item C<717>
+
+is for creation of bigger C<XPV*> structures. In the above case it
+creates 3 C<AV> per subroutine, one for a list of lexical variable
+names, one for a scratchpad (which contains lexical variables and
+C<targets>), and one for the array of scratchpads needed for
+recursion.
+
+It also creates a C<GV> and a C<CV> per subroutine (all called from
+start_subparse()).
+
+=item C<002>
+
+Creates C array corresponding to the C<AV> of scratchpads, and the
+scratchpad itself (the first fake entry of this scratchpad is created
+though the subroutine itself is not defined yet).
+
+It also creates C arrays to keep data for the stash (this is one HV,
+but it grows, thus there are 4 big allocations: the big chunks are not
+freeed, but are kept as additional arenas for C<SV> allocations).
+
+=item C<054>
+
+creates a C<HEK> for the name of the glob for the subroutine (this
+name is a key in a I<stash>).
+
+Big allocations with this I<Id> correspond to allocations of new
+arenas to keep C<HE>.
+
+=item C<602>
+
+creates a C<GP> for the glob for the subroutine.
+
+=item C<702>
+
+creates the C<MAGIC> for the glob for the subroutine.
+
+=item C<704>
+
+creates I<arenas> which keep SVs.
+
+=back
+
+=head2 B<-DL> details
+
+If Perl is run with B<-DL> option, then warn()s which start with `!'
+behave specially. They print a list of I<categories> of memory
+allocations, and statistics of allocations of different sizes for
+these categories.
+
+If warn() string starts with
+
+=over
+
+=item C<!!!>
+
+print changed categories only, print the differences in counts of allocations;
+
+=item C<!!>
+
+print grown categories only; print the absolute values of counts, and totals;
+
+=item C<!>
+
+print nonempty categories, print the absolute values of counts and totals.
+
+=back
+
+=head2 Limitations of B<-DL> statistic
+
+If an extension or an external library does not use Perl API to
+allocate memory, these allocations are not counted.
+
+=head1 Debugging regular expressions
+
+There are two ways to enable debugging output for regular expressions.
+
+If your perl is compiled with C<-DDEBUGGING>, you may use the
+B<-Dr> flag on the command line.
+
+Otherwise, one can C<use re 'debug'>, which has effects both at
+compile time, and at run time (and is I<not> lexically scoped).
+
+=head2 Compile-time output
+
+The debugging output for the compile time looks like this:
+
+ compiling RE `[bc]d(ef*g)+h[ij]k$'
+ size 43 first at 1
+ 1: ANYOF(11)
+ 11: EXACT <d>(13)
+ 13: CURLYX {1,32767}(27)
+ 15: OPEN1(17)
+ 17: EXACT <e>(19)
+ 19: STAR(22)
+ 20: EXACT <f>(0)
+ 22: EXACT <g>(24)
+ 24: CLOSE1(26)
+ 26: WHILEM(0)
+ 27: NOTHING(28)
+ 28: EXACT <h>(30)
+ 30: ANYOF(40)
+ 40: EXACT <k>(42)
+ 42: EOL(43)
+ 43: END(0)
+ anchored `de' at 1 floating `gh' at 3..2147483647 (checking floating)
+ stclass `ANYOF' minlen 7
+
+The first line shows the pre-compiled form of the regexp, and the
+second shows the size of the compiled form (in arbitrary units,
+usually 4-byte words) and the label I<id> of the first node which
+does a match.
+
+The last line (split into two lines in the above) contains the optimizer
+info. In the example shown, the optimizer found that the match
+should contain a substring C<de> at the offset 1, and substring C<gh>
+at some offset between 3 and infinity. Moreover, when checking for
+these substrings (to abandon impossible matches quickly) it will check
+for the substring C<gh> before checking for the substring C<de>. The
+optimizer may also use the knowledge that the match starts (at the
+C<first> I<id>) with a character class, and the match cannot be
+shorter than 7 chars.
+
+The fields of interest which may appear in the last line are
+
+=over
+
+=item C<anchored> I<STRING> C<at> I<POS>
+
+=item C<floating> I<STRING> C<at> I<POS1..POS2>
+
+see above;
+
+=item C<matching floating/anchored>
+
+which substring to check first;
+
+=item C<minlen>
+
+the minimal length of the match;
+
+=item C<stclass> I<TYPE>
+
+The type of the first matching node.
+
+=item C<noscan>
+
+which advises to not scan for the found substrings;
+
+=item C<isall>
+
+which says that the optimizer info is in fact all that the regular
+expression contains (thus one does not need to enter the RE engine at
+all);
+
+=item C<GPOS>
+
+if the pattern contains C<\G>;
+
+=item C<plus>
+
+if the pattern starts with a repeated char (as in C<x+y>);
+
+=item C<implicit>
+
+if the pattern starts with C<.*>;
+
+=item C<with eval>
+
+if the pattern contain eval-groups (see L<perlre/(?{ code })>);
+
+=item C<anchored(TYPE)>
+
+if the pattern may
+match only at a handful of places (with C<TYPE> being
+C<BOL>, C<MBOL>, or C<GPOS>, see the table below).
+
+=back
+
+If a substring is known to match at end-of-line only, it may be
+followed by C<$>, as in C<floating `k'$>.
+
+The optimizer-specific info is used to avoid entering (a slow) RE
+engine on strings which will definitely not match. If C<isall> flag
+is set, a call to the RE engine may be avoided even when optimizer
+found an appropriate place for the match.
+
+The rest of the output contains the list of I<nodes> of the compiled
+form of the RE. Each line has format
+
+C< >I<id>: I<TYPE> I<OPTIONAL-INFO> (I<next-id>)
+
+=head2 Types of nodes
+
+Here is the list of possible types with short descriptions:
+
+ # TYPE arg-description [num-args] [longjump-len] DESCRIPTION
+
+ # Exit points
+ END no End of program.
+ SUCCEED no Return from a subroutine, basically.
+
+ # Anchors:
+ BOL no Match "" at beginning of line.
+ MBOL no Same, assuming multiline.
+ SBOL no Same, assuming singleline.
+ EOS no Match "" at end of string.
+ EOL no Match "" at end of line.
+ MEOL no Same, assuming multiline.
+ SEOL no Same, assuming singleline.
+ BOUND no Match "" at any word boundary
+ BOUNDL no Match "" at any word boundary
+ NBOUND no Match "" at any word non-boundary
+ NBOUNDL no Match "" at any word non-boundary
+ GPOS no Matches where last m//g left off.
+
+ # [Special] alternatives
+ ANY no Match any one character (except newline).
+ SANY no Match any one character.
+ ANYOF sv Match character in (or not in) this class.
+ ALNUM no Match any alphanumeric character
+ ALNUML no Match any alphanumeric char in locale
+ NALNUM no Match any non-alphanumeric character
+ NALNUML no Match any non-alphanumeric char in locale
+ SPACE no Match any whitespace character
+ SPACEL no Match any whitespace char in locale
+ NSPACE no Match any non-whitespace character
+ NSPACEL no Match any non-whitespace char in locale
+ DIGIT no Match any numeric character
+ NDIGIT no Match any non-numeric character
+
+ # BRANCH The set of branches constituting a single choice are hooked
+ # together with their "next" pointers, since precedence prevents
+ # anything being concatenated to any individual branch. The
+ # "next" pointer of the last BRANCH in a choice points to the
+ # thing following the whole choice. This is also where the
+ # final "next" pointer of each individual branch points; each
+ # branch starts with the operand node of a BRANCH node.
+ #
+ BRANCH node Match this alternative, or the next...
+
+ # BACK Normal "next" pointers all implicitly point forward; BACK
+ # exists to make loop structures possible.
+ # not used
+ BACK no Match "", "next" ptr points backward.
+
+ # Literals
+ EXACT sv Match this string (preceded by length).
+ EXACTF sv Match this string, folded (prec. by length).
+ EXACTFL sv Match this string, folded in locale (w/len).
+
+ # Do nothing
+ NOTHING no Match empty string.
+ # A variant of above which delimits a group, thus stops optimizations
+ TAIL no Match empty string. Can jump here from outside.
+
+ # STAR,PLUS '?', and complex '*' and '+', are implemented as circular
+ # BRANCH structures using BACK. Simple cases (one character
+ # per match) are implemented with STAR and PLUS for speed
+ # and to minimize recursive plunges.
+ #
+ STAR node Match this (simple) thing 0 or more times.
+ PLUS node Match this (simple) thing 1 or more times.
+
+ CURLY sv 2 Match this simple thing {n,m} times.
+ CURLYN no 2 Match next-after-this simple thing
+ # {n,m} times, set parenths.
+ CURLYM no 2 Match this medium-complex thing {n,m} times.
+ CURLYX sv 2 Match this complex thing {n,m} times.
+
+ # This terminator creates a loop structure for CURLYX
+ WHILEM no Do curly processing and see if rest matches.
+
+ # OPEN,CLOSE,GROUPP ...are numbered at compile time.
+ OPEN num 1 Mark this point in input as start of #n.
+ CLOSE num 1 Analogous to OPEN.
+
+ REF num 1 Match some already matched string
+ REFF num 1 Match already matched string, folded
+ REFFL num 1 Match already matched string, folded in loc.
+
+ # grouping assertions
+ IFMATCH off 1 2 Succeeds if the following matches.
+ UNLESSM off 1 2 Fails if the following matches.
+ SUSPEND off 1 1 "Independent" sub-RE.
+ IFTHEN off 1 1 Switch, should be preceeded by switcher .
+ GROUPP num 1 Whether the group matched.
+
+ # Support for long RE
+ LONGJMP off 1 1 Jump far away.
+ BRANCHJ off 1 1 BRANCH with long offset.
+
+ # The heavy worker
+ EVAL evl 1 Execute some Perl code.
+
+ # Modifiers
+ MINMOD no Next operator is not greedy.
+ LOGICAL no Next opcode should set the flag only.
+
+ # This is not used yet
+ RENUM off 1 1 Group with independently numbered parens.
+
+ # This is not really a node, but an optimized away piece of a "long" node.
+ # To simplify debugging output, we mark it as if it were a node
+ OPTIMIZED off Placeholder for dump.
+
+=head2 Run-time output
+
+First of all, when doing a match, one may get no run-time output even
+if debugging is enabled. this means that the RE engine was never
+entered, all of the job was done by the optimizer.
+
+If RE engine was entered, the output may look like this:
+
+ Matching `[bc]d(ef*g)+h[ij]k$' against `abcdefg__gh__'
+ Setting an EVAL scope, savestack=3
+ 2 <ab> <cdefg__gh_> | 1: ANYOF
+ 3 <abc> <defg__gh_> | 11: EXACT <d>
+ 4 <abcd> <efg__gh_> | 13: CURLYX {1,32767}
+ 4 <abcd> <efg__gh_> | 26: WHILEM
+ 0 out of 1..32767 cc=effff31c
+ 4 <abcd> <efg__gh_> | 15: OPEN1
+ 4 <abcd> <efg__gh_> | 17: EXACT <e>
+ 5 <abcde> <fg__gh_> | 19: STAR
+ EXACT <f> can match 1 times out of 32767...
+ Setting an EVAL scope, savestack=3
+ 6 <bcdef> <g__gh__> | 22: EXACT <g>
+ 7 <bcdefg> <__gh__> | 24: CLOSE1
+ 7 <bcdefg> <__gh__> | 26: WHILEM
+ 1 out of 1..32767 cc=effff31c
+ Setting an EVAL scope, savestack=12
+ 7 <bcdefg> <__gh__> | 15: OPEN1
+ 7 <bcdefg> <__gh__> | 17: EXACT <e>
+ restoring \1 to 4(4)..7
+ failed, try continuation...
+ 7 <bcdefg> <__gh__> | 27: NOTHING
+ 7 <bcdefg> <__gh__> | 28: EXACT <h>
+ failed...
+ failed...
+
+The most significant information in the output is about the particular I<node>
+of the compiled RE which is currently being tested against the target string.
+The format of these lines is
+
+C< >I<STRING-OFFSET> <I<PRE-STRING>> <I<POST-STRING>> |I<ID>: I<TYPE>
+
+The I<TYPE> info is indented with respect to the backtracking level.
+Other incidental information appears interspersed within.
+
+=cut
diff --git a/contrib/perl5/pod/perldelta.pod b/contrib/perl5/pod/perldelta.pod
new file mode 100644
index 0000000..a3c6b6c
--- /dev/null
+++ b/contrib/perl5/pod/perldelta.pod
@@ -0,0 +1,919 @@
+=head1 NAME
+
+perldelta - what's new for perl5.005
+
+=head1 DESCRIPTION
+
+This document describes differences between the 5.004 release and this one.
+
+=head1 About the new versioning system
+
+Perl is now developed on two tracks: a maintenance track that makes
+small, safe updates to released production versions with emphasis on
+compatibility; and a development track that pursues more aggressive
+evolution. Maintenance releases (which should be considered production
+quality) have subversion numbers that run from C<1> to C<49>, and
+development releases (which should be considered "alpha" quality) run
+from C<50> to C<99>.
+
+Perl 5.005 is the combined product of the new dual-track development
+scheme.
+
+=head1 Incompatible Changes
+
+=head2 WARNING: This version is not binary compatible with Perl 5.004.
+
+Starting with Perl 5.004_50 there were many deep and far-reaching changes
+to the language internals. If you have dynamically loaded extensions
+that you built under perl 5.003 or 5.004, you can continue to use them
+with 5.004, but you will need to rebuild and reinstall those extensions
+to use them 5.005. See L<INSTALL> for detailed instructions on how to
+upgrade.
+
+=head2 Default installation structure has changed
+
+The new Configure defaults are designed to allow a smooth upgrade from
+5.004 to 5.005, but you should read L<INSTALL> for a detailed
+discussion of the changes in order to adapt them to your system.
+
+=head2 Perl Source Compatibility
+
+When none of the experimental features are enabled, there should be
+very few user-visible Perl source compatibility issues.
+
+If threads are enabled, then some caveats apply. C<@_> and C<$_> become
+lexical variables. The effect of this should be largely transparent to
+the user, but there are some boundary conditions under which user will
+need to be aware of the issues. For example, C<local(@_)> results in
+a "Can't localize lexical variable @_ ..." message. This may be enabled
+in a future version.
+
+Some new keywords have been introduced. These are generally expected to
+have very little impact on compatibility. See L<New C<INIT> keyword>,
+L<New C<lock> keyword>, and L<New C<qr//> operator>.
+
+Certain barewords are now reserved. Use of these will provoke a warning
+if you have asked for them with the C<-w> switch.
+See L<C<our> is now a reserved word>.
+
+=head2 C Source Compatibility
+
+There have been a large number of changes in the internals to support
+the new features in this release.
+
+=over 4
+
+=item Core sources now require ANSI C compiler
+
+An ANSI C compiler is now B<required> to build perl. See F<INSTALL>.
+
+=item All Perl global variables must now be referenced with an explicit prefix
+
+All Perl global variables that are visible for use by extensions now
+have a C<PL_> prefix. New extensions should C<not> refer to perl globals
+by their unqualified names. To preserve sanity, we provide limited
+backward compatibility for globals that are being widely used like
+C<sv_undef> and C<na> (which should now be written as C<PL_sv_undef>,
+C<PL_na> etc.)
+
+If you find that your XS extension does not compile anymore because a
+perl global is not visible, try adding a C<PL_> prefix to the global
+and rebuild.
+
+It is strongly recommended that all functions in the Perl API that don't
+begin with C<perl> be referenced with a C<Perl_> prefix. The bare function
+names without the C<Perl_> prefix are supported with macros, but this
+support may cease in a future release.
+
+See L<perlguts/API LISTING>.
+
+=item Enabling threads has source compatibility issues
+
+Perl built with threading enabled requires extensions to use the new
+C<dTHR> macro to initialize the handle to access per-thread data.
+If you see a compiler error that talks about the variable C<thr> not
+being declared (when building a module that has XS code), you need
+to add C<dTHR;> at the beginning of the block that elicited the error.
+
+The API function C<perl_get_sv("@",FALSE)> should be used instead of
+directly accessing perl globals as C<GvSV(errgv)>. The API call is
+backward compatible with existing perls and provides source compatibility
+with threading is enabled.
+
+See L<API Changes for more information>.
+
+=back
+
+=head2 Binary Compatibility
+
+This version is NOT binary compatible with older versions. All extensions
+will need to be recompiled. Further binaries built with threads enabled
+are incompatible with binaries built without. This should largely be
+transparent to the user, as all binary incompatible configurations have
+their own unique architecture name, and extension binaries get installed at
+unique locations. This allows coexistence of several configurations in
+the same directory hierarchy. See F<INSTALL>.
+
+=head2 Security fixes may affect compatibility
+
+A few taint leaks and taint omissions have been corrected. This may lead
+to "failure" of scripts that used to work with older versions. Compiling
+with -DINCOMPLETE_TAINTS provides a perl with minimal amounts of changes
+to the tainting behavior. But note that the resulting perl will have
+known insecurities.
+
+Oneliners with the C<-e> switch do not create temporary files anymore.
+
+=head2 Relaxed new mandatory warnings introduced in 5.004
+
+Many new warnings that were introduced in 5.004 have been made
+optional. Some of these warnings are still present, but perl's new
+features make them less often a problem. See L<New Diagnostics>.
+
+=head2 Licensing
+
+Perl has a new Social Contract for contributors. See F<Porting/Contract>.
+
+The license included in much of the Perl documentation has changed.
+Most of the Perl documentation was previously under the implicit GNU
+General Public License or the Artistic License (at the user's choice).
+Now much of the documentation unambigously states the terms under which
+it may be distributed. Those terms are in general much less restrictive
+than the GNU GPL. See L<perl> and the individual perl man pages listed
+therein.
+
+=head1 Core Changes
+
+
+=head2 Threads
+
+WARNING: Threading is considered an B<experimental> feature. Details of the
+implementation may change without notice. There are known limitations
+and some bugs. These are expected to be fixed in future versions.
+
+See L<README.threads>.
+
+=head2 Compiler
+
+WARNING: The Compiler and related tools are considered B<experimental>.
+Features may change without notice, and there are known limitations
+and bugs. Since the compiler is fully external to perl, the default
+configuration will build and install it.
+
+The Compiler produces three different types of transformations of a
+perl program. The C backend generates C code that captures perl's state
+just before execution begins. It eliminates the compile-time overheads
+of the regular perl interpreter, but the run-time performance remains
+comparatively the same. The CC backend generates optimized C code
+equivalent to the code path at run-time. The CC backend has greater
+potential for big optimizations, but only a few optimizations are
+implemented currently. The Bytecode backend generates a platform
+independent bytecode representation of the interpreter's state
+just before execution. Thus, the Bytecode back end also eliminates
+much of the compilation overhead of the interpreter.
+
+The compiler comes with several valuable utilities.
+
+C<B::Lint> is an experimental module to detect and warn about suspicious
+code, especially the cases that the C<-w> switch does not detect.
+
+C<B::Deparse> can be used to demystify perl code, and understand
+how perl optimizes certain constructs.
+
+C<B::Xref> generates cross reference reports of all definition and use
+of variables, subroutines and formats in a program.
+
+C<B::Showlex> show the lexical variables used by a subroutine or file
+at a glance.
+
+C<perlcc> is a simple frontend for compiling perl.
+
+See C<ext/B/README>, L<B>, and the respective compiler modules.
+
+=head2 Regular Expressions
+
+Perl's regular expression engine has been seriously overhauled, and
+many new constructs are supported. Several bugs have been fixed.
+
+Here is an itemized summary:
+
+=over 4
+
+=item Many new and improved optimizations
+
+Changes in the RE engine:
+
+ Unneeded nodes removed;
+ Substrings merged together;
+ New types of nodes to process (SUBEXPR)* and similar expressions
+ quickly, used if the SUBEXPR has no side effects and matches
+ strings of the same length;
+ Better optimizations by lookup for constant substrings;
+ Better search for constants substrings anchored by $ ;
+
+Changes in Perl code using RE engine:
+
+ More optimizations to s/longer/short/;
+ study() was not working;
+ /blah/ may be optimized to an analogue of index() if $& $` $' not seen;
+ Unneeded copying of matched-against string removed;
+ Only matched part of the string is copying if $` $' were not seen;
+
+=item Many bug fixes
+
+Note that only the major bug fixes are listed here. See F<Changes> for others.
+
+ Backtracking might not restore start of $3.
+ No feedback if max count for * or + on "complex" subexpression
+ was reached, similarly (but at compile time) for {3,34567}
+ Primitive restrictions on max count introduced to decrease a
+ possibility of a segfault;
+ (ZERO-LENGTH)* could segfault;
+ (ZERO-LENGTH)* was prohibited;
+ Long REs were not allowed;
+ /RE/g could skip matches at the same position after a
+ zero-length match;
+
+=item New regular expression constructs
+
+The following new syntax elements are supported:
+
+ (?<=RE)
+ (?<!RE)
+ (?{ CODE })
+ (?i-x)
+ (?i:RE)
+ (?(COND)YES_RE|NO_RE)
+ (?>RE)
+ \z
+
+=item New operator for precompiled regular expressions
+
+See L<New C<qr//> operator>.
+
+=item Other improvements
+
+ Better debugging output (possibly with colors),
+ even from non-debugging Perl;
+ RE engine code now looks like C, not like assembler;
+ Behaviour of RE modifiable by `use re' directive;
+ Improved documentation;
+ Test suite significantly extended;
+ Syntax [:^upper:] etc., reserved inside character classes;
+
+=item Incompatible changes
+
+ (?i) localized inside enclosing group;
+ $( is not interpolated into RE any more;
+ /RE/g may match at the same position (with non-zero length)
+ after a zero-length match (bug fix).
+
+=back
+
+See L<perlre> and L<perlop>.
+
+=head2 Improved malloc()
+
+See banner at the beginning of C<malloc.c> for details.
+
+=head2 Quicksort is internally implemented
+
+Perl now contains its own highly optimized qsort() routine. The new qsort()
+is resistant to inconsistent comparison functions, so Perl's C<sort()> will
+not provoke coredumps any more when given poorly written sort subroutines.
+(Some C library C<qsort()>s that were being used before used to have this
+problem.) In our testing, the new C<qsort()> required the minimal number
+of pair-wise compares on average, among all known C<qsort()> implementations.
+
+See C<perlfunc/sort>.
+
+=head2 Reliable signals
+
+Perl's signal handling is susceptible to random crashes, because signals
+arrive asynchronously, and the Perl runtime is not reentrant at arbitrary
+times.
+
+However, one experimental implementation of reliable signals is available
+when threads are enabled. See C<Thread::Signal>. Also see F<INSTALL> for
+how to build a Perl capable of threads.
+
+=head2 Reliable stack pointers
+
+The internals now reallocate the perl stack only at predictable times.
+In particular, magic calls never trigger reallocations of the stack,
+because all reentrancy of the runtime is handled using a "stack of stacks".
+This should improve reliability of cached stack pointers in the internals
+and in XSUBs.
+
+=head2 More generous treatment of carriage returns
+
+Perl used to complain if it encountered literal carriage returns in
+scripts. Now they are mostly treated like whitespace within program text.
+Inside string literals and here documents, literal carriage returns are
+ignored if they occur paired with newlines, or get interpreted as newlines
+if they stand alone. This behavior means that literal carriage returns
+in files should be avoided. You can get the older, more compatible (but
+less generous) behavior by defining the preprocessor symbol
+C<PERL_STRICT_CR> when building perl. Of course, all this has nothing
+whatever to do with how escapes like C<\r> are handled within strings.
+
+Note that this doesn't somehow magically allow you to keep all text files
+in DOS format. The generous treatment only applies to files that perl
+itself parses. If your C compiler doesn't allow carriage returns in
+files, you may still be unable to build modules that need a C compiler.
+
+=head2 Memory leaks
+
+C<substr>, C<pos> and C<vec> don't leak memory anymore when used in lvalue
+context. Many small leaks that impacted applications that embed multiple
+interpreters have been fixed.
+
+=head2 Better support for multiple interpreters
+
+The build-time option C<-DMULTIPLICITY> has had many of the details
+reworked. Some previously global variables that should have been
+per-interpreter now are. With care, this allows interpreters to call
+each other. See the C<PerlInterp> extension on CPAN.
+
+=head2 Behavior of local() on array and hash elements is now well-defined
+
+See L<perlsub/"Temporary Values via local()">.
+
+=head2 C<%!> is transparently tied to the L<Errno> module
+
+See L<perlvar>, and L<Errno>.
+
+=head2 Pseudo-hashes are supported
+
+See L<perlref>.
+
+=head2 C<EXPR foreach EXPR> is supported
+
+See L<perlsyn>.
+
+=head2 Keywords can be globally overridden
+
+See L<perlsub>.
+
+=head2 C<$^E> is meaningful on Win32
+
+See L<perlvar>.
+
+=head2 C<foreach (1..1000000)> optimized
+
+C<foreach (1..1000000)> is now optimized into a counting loop. It does
+not try to allocate a 1000000-size list anymore.
+
+=head2 C<Foo::> can be used as implicitly quoted package name
+
+Barewords caused unintuitive behavior when a subroutine with the same
+name as a package happened to be defined. Thus, C<new Foo @args>,
+use the result of the call to C<Foo()> instead of C<Foo> being treated
+as a literal. The recommended way to write barewords in the indirect
+object slot is C<new Foo:: @args>. Note that the method C<new()> is
+called with a first argument of C<Foo>, not C<Foo::> when you do that.
+
+=head2 C<exists $Foo::{Bar::}> tests existence of a package
+
+It was impossible to test for the existence of a package without
+actually creating it before. Now C<exists $Foo::{Bar::}> can be
+used to test if the C<Foo::Bar> namespace has been created.
+
+=head2 Better locale support
+
+See L<perllocale>.
+
+=head2 Experimental support for 64-bit platforms
+
+Perl5 has always had 64-bit support on systems with 64-bit longs.
+Starting with 5.005, the beginnings of experimental support for systems
+with 32-bit long and 64-bit 'long long' integers has been added.
+If you add -DUSE_LONG_LONG to your ccflags in config.sh (or manually
+define it in perl.h) then perl will be built with 'long long' support.
+There will be many compiler warnings, and the resultant perl may not
+work on all systems. There are many other issues related to
+third-party extensions and libraries. This option exists to allow
+people to work on those issues.
+
+=head2 prototype() returns useful results on builtins
+
+See L<perlfunc/prototype>.
+
+=head2 Extended support for exception handling
+
+C<die()> now accepts a reference value, and C<$@> gets set to that
+value in exception traps. This makes it possible to propagate
+exception objects. This is an undocumented B<experimental> feature.
+
+=head2 Re-blessing in DESTROY() supported for chaining DESTROY() methods
+
+See L<perlobj/Destructors>.
+
+=head2 All C<printf> format conversions are handled internally
+
+See L<perlfunc/printf>.
+
+=head2 New C<INIT> keyword
+
+C<INIT> subs are like C<BEGIN> and C<END>, but they get run just before
+the perl runtime begins execution. e.g., the Perl Compiler makes use of
+C<INIT> blocks to initialize and resolve pointers to XSUBs.
+
+=head2 New C<lock> keyword
+
+The C<lock> keyword is the fundamental synchronization primitive
+in threaded perl. When threads are not enabled, it is currently a noop.
+
+To minimize impact on source compatibility this keyword is "weak", i.e., any
+user-defined subroutine of the same name overrides it, unless a C<use Thread>
+has been seen.
+
+=head2 New C<qr//> operator
+
+The C<qr//> operator, which is syntactically similar to the other quote-like
+operators, is used to create precompiled regular expressions. This compiled
+form can now be explicitly passed around in variables, and interpolated in
+other regular expressions. See L<perlop>.
+
+=head2 C<our> is now a reserved word
+
+Calling a subroutine with the name C<our> will now provoke a warning when
+using the C<-w> switch.
+
+=head2 Tied arrays are now fully supported
+
+See L<Tie::Array>.
+
+=head2 Tied handles support is better
+
+Several missing hooks have been added. There is also a new base class for
+TIEARRAY implementations. See L<Tie::Array>.
+
+=head2 4th argument to substr
+
+substr() can now both return and replace in one operation. The optional
+4th argument is the replacement string. See L<perlfunc/substr>.
+
+=head2 Negative LENGTH argument to splice
+
+splice() with a negative LENGTH argument now work similar to what the
+LENGTH did for substr(). Previously a negative LENGTH was treated as
+0. See L<perlfunc/splice>.
+
+=head2 Magic lvalues are now more magical
+
+When you say something like C<substr($x, 5) = "hi">, the scalar returned
+by substr() is special, in that any modifications to it affect $x.
+(This is called a 'magic lvalue' because an 'lvalue' is something on
+the left side of an assignment.) Normally, this is exactly what you
+would expect to happen, but Perl uses the same magic if you use substr(),
+pos(), or vec() in a context where they might be modified, like taking
+a reference with C<\> or as an argument to a sub that modifies C<@_>.
+In previous versions, this 'magic' only went one way, but now changes
+to the scalar the magic refers to ($x in the above example) affect the
+magic lvalue too. For instance, this code now acts differently:
+
+ $x = "hello";
+ sub printit {
+ $x = "g'bye";
+ print $_[0], "\n";
+ }
+ printit(substr($x, 0, 5));
+
+In previous versions, this would print "hello", but it now prints "g'bye".
+
+=head2 E<lt>E<gt> now reads in records
+
+If C<$/> is a referenence to an integer, or a scalar that holds an integer,
+E<lt>E<gt> will read in records instead of lines. For more info, see
+L<perlvar/$/>.
+
+=head1 Supported Platforms
+
+Configure has many incremental improvements. Site-wide policy for building
+perl can now be made persistent, via Policy.sh. Configure also records
+the command-line arguments used in F<config.sh>.
+
+=head2 New Platforms
+
+BeOS is now supported. See L<README.beos>.
+
+DOS is now supported under the DJGPP tools. See L<README.dos>.
+
+MPE/iX is now supported. See L<README.mpeix>.
+
+MVS (OS390) is now supported. See L<README.os390>.
+
+=head2 Changes in existing support
+
+Win32 support has been vastly enhanced. Support for Perl Object, a C++
+encapsulation of Perl. GCC and EGCS are now supported on Win32.
+See F<README.win32>, aka L<perlwin32>.
+
+VMS configuration system has been rewritten. See L<README.vms>.
+
+The hints files for most Unix platforms have seen incremental improvements.
+
+=head1 Modules and Pragmata
+
+=head2 New Modules
+
+=over
+
+=item B
+
+Perl compiler and tools. See L<B>.
+
+=item Data::Dumper
+
+A module to pretty print Perl data. See L<Data::Dumper>.
+
+=item Errno
+
+A module to look up errors more conveniently. See L<Errno>.
+
+=item File::Spec
+
+A portable API for file operations.
+
+=item ExtUtils::Installed
+
+Query and manage installed modules.
+
+=item ExtUtils::Packlist
+
+Manipulate .packlist files.
+
+=item Fatal
+
+Make functions/builtins succeed or die.
+
+=item IPC::SysV
+
+Constants and other support infrastructure for System V IPC operations
+in perl.
+
+=item Test
+
+A framework for writing testsuites.
+
+=item Tie::Array
+
+Base class for tied arrays.
+
+=item Tie::Handle
+
+Base class for tied handles.
+
+=item Thread
+
+Perl thread creation, manipulation, and support.
+
+=item attrs
+
+Set subroutine attributes.
+
+=item fields
+
+Compile-time class fields.
+
+=item re
+
+Various pragmata to control behavior of regular expressions.
+
+=back
+
+=head2 Changes in existing modules
+
+=over
+
+=item CGI
+
+CGI has been updated to version 2.42.
+
+=item POSIX
+
+POSIX now has its own platform-specific hints files.
+
+=item DB_File
+
+DB_File supports version 2.x of Berkeley DB. See C<ext/DB_File/Changes>.
+
+=item MakeMaker
+
+MakeMaker now supports writing empty makefiles, provides a way to
+specify that site umask() policy should be honored. There is also
+better support for manipulation of .packlist files, and getting
+information about installed modules.
+
+Extensions that have both architecture-dependent and
+architecture-independent files are now always installed completely in
+the architecture-dependent locations. Previously, the shareable parts
+were shared both across architectures and across perl versions and were
+therefore liable to be overwritten with newer versions that might have
+subtle incompatibilities.
+
+=item CPAN
+
+See <perlmodinstall> and L<CPAN>.
+
+=item Cwd
+
+Cwd::cwd is faster on most platforms.
+
+=item Benchmark
+
+Keeps better time.
+
+=back
+
+=head1 Utility Changes
+
+C<h2ph> and related utilities have been vastly overhauled.
+
+C<perlcc>, a new experimental front end for the compiler is available.
+
+The crude GNU C<configure> emulator is now called C<configure.gnu> to
+avoid trampling on C<Configure> under case-insensitive filesystems.
+
+C<perldoc> used to be rather slow. The slower features are now optional.
+In particular, case-insensitive searches need the C<-i> switch, and
+recursive searches need C<-r>. You can set these switches in the
+C<PERLDOC> environment variable to get the old behavior.
+
+=head1 Documentation Changes
+
+Config.pm now has a glossary of variables.
+
+F<Porting/patching.pod> has detailed instructions on how to create and
+submit patches for perl.
+
+L<perlport> specifies guidelines on how to write portably.
+
+L<perlmodinstall> describes how to fetch and install modules from C<CPAN>
+sites.
+
+Some more Perl traps are documented now. See L<perltrap>.
+
+=head1 New Diagnostics
+
+=over
+
+=item Ambiguous call resolved as CORE::%s(), qualify as such or use &
+
+(W) A subroutine you have declared has the same name as a Perl keyword,
+and you have used the name without qualification for calling one or the
+other. Perl decided to call the builtin because the subroutine is
+not imported.
+
+To force interpretation as a subroutine call, either put an ampersand
+before the subroutine name, or qualify the name with its package.
+Alternatively, you can import the subroutine (or pretend that it's
+imported with the C<use subs> pragma).
+
+To silently interpret it as the Perl operator, use the C<CORE::> prefix
+on the operator (e.g. C<CORE::log($x)>) or by declaring the subroutine
+to be an object method (see L<attrs>).
+
+=item Bad index while coercing array into hash
+
+(F) The index looked up in the hash found as the 0'th element of a
+pseudo-hash is not legal. Index values must be at 1 or greater.
+See L<perlref>.
+
+=item Bareword "%s" refers to nonexistent package
+
+(W) You used a qualified bareword of the form C<Foo::>, but
+the compiler saw no other uses of that namespace before that point.
+Perhaps you need to predeclare a package?
+
+=item Can't call method "%s" on an undefined value
+
+(F) You used the syntax of a method call, but the slot filled by the
+object reference or package name contains an undefined value.
+Something like this will reproduce the error:
+
+ $BADREF = 42;
+ process $BADREF 1,2,3;
+ $BADREF->process(1,2,3);
+
+=item Can't coerce array into hash
+
+(F) You used an array where a hash was expected, but the array has no
+information on how to map from keys to array indices. You can do that
+only with arrays that have a hash reference at index 0.
+
+=item Can't goto subroutine from an eval-string
+
+(F) The "goto subroutine" call can't be used to jump out of an eval "string".
+(You can use it to jump out of an eval {BLOCK}, but you probably don't want to.)
+
+=item Can't localize pseudo-hash element
+
+(F) You said something like C<local $ar-E<gt>{'key'}>, where $ar is
+a reference to a pseudo-hash. That hasn't been implemented yet, but
+you can get a similar effect by localizing the corresponding array
+element directly -- C<local $ar-E<gt>[$ar-E<gt>[0]{'key'}]>.
+
+=item Can't use %%! because Errno.pm is not available
+
+(F) The first time the %! hash is used, perl automatically loads the
+Errno.pm module. The Errno module is expected to tie the %! hash to
+provide symbolic names for C<$!> errno values.
+
+=item Cannot find an opnumber for "%s"
+
+(F) A string of a form C<CORE::word> was given to prototype(), but
+there is no builtin with the name C<word>.
+
+=item Character class syntax [. .] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax beginning
+with "[." and ending with ".]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[." and ".\]".
+
+=item Character class syntax [: :] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax beginning
+with "[:" and ending with ":]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[:" and ":\]".
+
+=item Character class syntax [= =] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax
+beginning with "[=" and ending with "=]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[=" and "=\]".
+
+=item %s: Eval-group in insecure regular expression
+
+(F) Perl detected tainted data when trying to compile a regular expression
+that contains the C<(?{ ... })> zero-width assertion, which is unsafe.
+See L<perlre/(?{ code })>, and L<perlsec>.
+
+=item %s: Eval-group not allowed, use re 'eval'
+
+(F) A regular expression contained the C<(?{ ... })> zero-width assertion,
+but that construct is only allowed when the C<use re 'eval'> pragma is
+in effect. See L<perlre/(?{ code })>.
+
+=item %s: Eval-group not allowed at run time
+
+(F) Perl tried to compile a regular expression containing the C<(?{ ... })>
+zero-width assertion at run time, as it would when the pattern contains
+interpolated values. Since that is a security risk, it is not allowed.
+If you insist, you may still do this by explicitly building the pattern
+from an interpolated string at run time and using that in an eval().
+See L<perlre/(?{ code })>.
+
+=item Explicit blessing to '' (assuming package main)
+
+(W) You are blessing a reference to a zero length string. This has
+the effect of blessing the reference into the package main. This is
+usually not what you want. Consider providing a default target
+package, e.g. bless($ref, $p or 'MyPackage');
+
+=item Illegal hex digit ignored
+
+(W) You may have tried to use a character other than 0 - 9 or A - F in a
+hexadecimal number. Interpretation of the hexadecimal number stopped
+before the illegal character.
+
+=item No such array field
+
+(F) You tried to access an array as a hash, but the field name used is
+not defined. The hash at index 0 should map all valid field names to
+array indices for that to work.
+
+=item No such field "%s" in variable %s of type %s
+
+(F) You tried to access a field of a typed variable where the type
+does not know about the field name. The field names are looked up in
+the %FIELDS hash in the type package at compile time. The %FIELDS hash
+is usually set up with the 'fields' pragma.
+
+=item Out of memory during ridiculously large request
+
+(F) You can't allocate more than 2^31+"small amount" bytes. This error
+is most likely to be caused by a typo in the Perl program. e.g., C<$arr[time]>
+instead of C<$arr[$time]>.
+
+=item Range iterator outside integer range
+
+(F) One (or both) of the numeric arguments to the range operator ".."
+are outside the range which can be represented by integers internally.
+One possible workaround is to force Perl to use magical string
+increment by prepending "0" to your numbers.
+
+=item Recursive inheritance detected while looking for method '%s' in package '%s'
+
+(F) More than 100 levels of inheritance were encountered while invoking a
+method. Probably indicates an unintended loop in your inheritance hierarchy.
+
+=item Reference found where even-sized list expected
+
+(W) You gave a single reference where Perl was expecting a list with
+an even number of elements (for assignment to a hash). This
+usually means that you used the anon hash constructor when you meant
+to use parens. In any case, a hash requires key/value B<pairs>.
+
+ %hash = { one => 1, two => 2, }; # WRONG
+ %hash = [ qw/ an anon array / ]; # WRONG
+ %hash = ( one => 1, two => 2, ); # right
+ %hash = qw( one 1 two 2 ); # also fine
+
+=item Undefined value assigned to typeglob
+
+(W) An undefined value was assigned to a typeglob, a la C<*foo = undef>.
+This does nothing. It's possible that you really mean C<undef *foo>.
+
+=item Use of reserved word "%s" is deprecated
+
+(D) The indicated bareword is a reserved word. Future versions of perl
+may use it as a keyword, so you're better off either explicitly quoting
+the word in a manner appropriate for its context of use, or using a
+different name altogether. The warning can be suppressed for subroutine
+names by either adding a C<&> prefix, or using a package qualifier,
+e.g. C<&our()>, or C<Foo::our()>.
+
+=item perl: warning: Setting locale failed.
+
+(S) The whole warning message will look something like:
+
+ perl: warning: Setting locale failed.
+ perl: warning: Please check that your locale settings:
+ LC_ALL = "En_US",
+ LANG = (unset)
+ are supported and installed on your system.
+ perl: warning: Falling back to the standard locale ("C").
+
+Exactly what were the failed locale settings varies. In the above the
+settings were that the LC_ALL was "En_US" and the LANG had no value.
+This error means that Perl detected that you and/or your system
+administrator have set up the so-called variable system but Perl could
+not use those settings. This was not dead serious, fortunately: there
+is a "default locale" called "C" that Perl can and will use, the
+script will be run. Before you really fix the problem, however, you
+will get the same error message each time you run Perl. How to really
+fix the problem can be found in L<perllocale> section B<LOCALE PROBLEMS>.
+
+=back
+
+
+=head1 Obsolete Diagnostics
+
+=over
+
+=item Can't mktemp()
+
+(F) The mktemp() routine failed for some reason while trying to process
+a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
+
+=item Can't write to temp file for B<-e>: %s
+
+(F) The write routine failed for some reason while trying to process
+a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
+
+=item Cannot open temporary file
+
+(F) The create routine failed for some reason while trying to process
+a B<-e> switch. Maybe your /tmp partition is full, or clobbered.
+
+=back
+
+=head1 BUGS
+
+If you find what you think is a bug, you might check the headers of
+recently posted articles in the comp.lang.perl.misc newsgroup.
+There may also be information at http://www.perl.com/perl/, the Perl
+Home Page.
+
+If you believe you have an unreported bug, please run the B<perlbug>
+program included with your release. Make sure you trim your bug down
+to a tiny but sufficient test case. Your bug report, along with the
+output of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be
+analysed by the Perl porting team.
+
+=head1 SEE ALSO
+
+The F<Changes> file for exhaustive details on what changed.
+
+The F<INSTALL> file for how to build Perl.
+
+The F<README> file for general stuff.
+
+The F<Artistic> and F<Copying> files for copyright information.
+
+=head1 HISTORY
+
+Written by Gurusamy Sarathy <F<gsar@umich.edu>>, with many contributions
+from The Perl Porters.
+
+Send omissions or corrections to <F<perlbug@perl.com>>.
+
+=cut
diff --git a/contrib/perl5/pod/perldiag.pod b/contrib/perl5/pod/perldiag.pod
new file mode 100644
index 0000000..8d21323
--- /dev/null
+++ b/contrib/perl5/pod/perldiag.pod
@@ -0,0 +1,3125 @@
+=head1 NAME
+
+perldiag - various Perl diagnostics
+
+=head1 DESCRIPTION
+
+These messages are classified as follows (listed in increasing order of
+desperation):
+
+ (W) A warning (optional).
+ (D) A deprecation (optional).
+ (S) A severe warning (mandatory).
+ (F) A fatal error (trappable).
+ (P) An internal error you should never see (trappable).
+ (X) A very fatal error (nontrappable).
+ (A) An alien error message (not generated by Perl).
+
+Optional warnings are enabled by using the B<-w> switch. Warnings may
+be captured by setting C<$SIG{__WARN__}> to a reference to a routine that
+will be called on each warning instead of printing it. See L<perlvar>.
+Trappable errors may be trapped using the eval operator. See
+L<perlfunc/eval>.
+
+Some of these messages are generic. Spots that vary are denoted with a %s,
+just as in a printf format. Note that some messages start with a %s!
+The symbols C<"%(-?@> sort before the letters, while C<[> and C<\> sort after.
+
+=over 4
+
+=item "my" variable %s can't be in a package
+
+(F) Lexically scoped variables aren't in a package, so it doesn't make sense
+to try to declare one with a package qualifier on the front. Use local()
+if you want to localize a package variable.
+
+=item "my" variable %s masks earlier declaration in same scope
+
+(W) A lexical variable has been redeclared in the same scope, effectively
+eliminating all access to the previous instance. This is almost always
+a typographical error. Note that the earlier variable will still exist
+until the end of the scope or until all closure referents to it are
+destroyed.
+
+=item "no" not allowed in expression
+
+(F) The "no" keyword is recognized and executed at compile time, and returns
+no useful value. See L<perlmod>.
+
+=item "use" not allowed in expression
+
+(F) The "use" keyword is recognized and executed at compile time, and returns
+no useful value. See L<perlmod>.
+
+=item % may only be used in unpack
+
+(F) You can't pack a string by supplying a checksum, because the
+checksumming process loses information, and you can't go the other
+way. See L<perlfunc/unpack>.
+
+=item %s (...) interpreted as function
+
+(W) You've run afoul of the rule that says that any list operator followed
+by parentheses turns into a function, with all the list operators arguments
+found inside the parentheses. See L<perlop/Terms and List Operators (Leftward)>.
+
+=item %s argument is not a HASH element
+
+(F) The argument to exists() must be a hash element, such as
+
+ $foo{$bar}
+ $ref->[12]->{"susie"}
+
+=item %s argument is not a HASH element or slice
+
+(F) The argument to delete() must be either a hash element, such as
+
+ $foo{$bar}
+ $ref->[12]->{"susie"}
+
+or a hash slice, such as
+
+ @foo{$bar, $baz, $xyzzy}
+ @{$ref->[12]}{"susie", "queue"}
+
+=item %s did not return a true value
+
+(F) A required (or used) file must return a true value to indicate that
+it compiled correctly and ran its initialization code correctly. It's
+traditional to end such a file with a "1;", though any true value would
+do. See L<perlfunc/require>.
+
+=item %s found where operator expected
+
+(S) The Perl lexer knows whether to expect a term or an operator. If it
+sees what it knows to be a term when it was expecting to see an operator,
+it gives you this warning. Usually it indicates that an operator or
+delimiter was omitted, such as a semicolon.
+
+=item %s had compilation errors
+
+(F) The final summary message when a C<perl -c> fails.
+
+=item %s has too many errors
+
+(F) The parser has given up trying to parse the program after 10 errors.
+Further error messages would likely be uninformative.
+
+=item %s matches null string many times
+
+(W) The pattern you've specified would be an infinite loop if the
+regular expression engine didn't specifically check for that. See L<perlre>.
+
+=item %s never introduced
+
+(S) The symbol in question was declared but somehow went out of scope
+before it could possibly have been used.
+
+=item %s syntax OK
+
+(F) The final summary message when a C<perl -c> succeeds.
+
+=item %s: Command not found
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item %s: Expression syntax
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item %s: Undefined variable
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item %s: not found
+
+(A) You've accidentally run your script through the Bourne shell
+instead of Perl. Check the #! line, or manually feed your script
+into Perl yourself.
+
+=item (Missing semicolon on previous line?)
+
+(S) This is an educated guess made in conjunction with the message "%s
+found where operator expected". Don't automatically put a semicolon on
+the previous line just because you saw this message.
+
+=item B<-P> not allowed for setuid/setgid script
+
+(F) The script would have to be opened by the C preprocessor by name,
+which provides a race condition that breaks security.
+
+=item C<-T> and C<-B> not implemented on filehandles
+
+(F) Perl can't peek at the stdio buffer of filehandles when it doesn't
+know about your kind of stdio. You'll have to use a filename instead.
+
+=item C<-p> destination: %s
+
+(F) An error occurred during the implicit output invoked by the C<-p>
+command-line switch. (This output goes to STDOUT unless you've
+redirected it with select().)
+
+=item 500 Server error
+
+See Server error.
+
+=item ?+* follows nothing in regexp
+
+(F) You started a regular expression with a quantifier. Backslash it
+if you meant it literally. See L<perlre>.
+
+=item @ outside of string
+
+(F) You had a pack template that specified an absolute position outside
+the string being unpacked. See L<perlfunc/pack>.
+
+=item accept() on closed fd
+
+(W) You tried to do an accept on a closed socket. Did you forget to check
+the return value of your socket() call? See L<perlfunc/accept>.
+
+=item Allocation too large: %lx
+
+(X) You can't allocate more than 64K on an MS-DOS machine.
+
+=item Applying %s to %s will act on scalar(%s)
+
+(W) The pattern match (//), substitution (s///), and transliteration (tr///)
+operators work on scalar values. If you apply one of them to an array
+or a hash, it will convert the array or hash to a scalar value -- the
+length of an array, or the population info of a hash -- and then work on
+that scalar value. This is probably not what you meant to do. See
+L<perlfunc/grep> and L<perlfunc/map> for alternatives.
+
+=item Arg too short for msgsnd
+
+(F) msgsnd() requires a string at least as long as sizeof(long).
+
+=item Ambiguous use of %s resolved as %s
+
+(W)(S) You said something that may not be interpreted the way
+you thought. Normally it's pretty easy to disambiguate it by supplying
+a missing quote, operator, parenthesis pair or declaration.
+
+=item Ambiguous call resolved as CORE::%s(), qualify as such or use &
+
+(W) A subroutine you have declared has the same name as a Perl keyword,
+and you have used the name without qualification for calling one or the
+other. Perl decided to call the builtin because the subroutine is
+not imported.
+
+To force interpretation as a subroutine call, either put an ampersand
+before the subroutine name, or qualify the name with its package.
+Alternatively, you can import the subroutine (or pretend that it's
+imported with the C<use subs> pragma).
+
+To silently interpret it as the Perl operator, use the C<CORE::> prefix
+on the operator (e.g. C<CORE::log($x)>) or by declaring the subroutine
+to be an object method (see L<attrs>).
+
+=item Args must match #! line
+
+(F) The setuid emulator requires that the arguments Perl was invoked
+with match the arguments specified on the #! line. Since some systems
+impose a one-argument limit on the #! line, try combining switches;
+for example, turn C<-w -U> into C<-wU>.
+
+=item Argument "%s" isn't numeric%s
+
+(W) The indicated string was fed as an argument to an operator that
+expected a numeric value instead. If you're fortunate the message
+will identify which operator was so unfortunate.
+
+=item Array @%s missing the @ in argument %d of %s()
+
+(D) Really old Perl let you omit the @ on array names in some spots. This
+is now heavily deprecated.
+
+=item assertion botched: %s
+
+(P) The malloc package that comes with Perl had an internal failure.
+
+=item Assertion failed: file "%s"
+
+(P) A general assertion failed. The file in question must be examined.
+
+=item Assignment to both a list and a scalar
+
+(F) If you assign to a conditional operator, the 2nd and 3rd arguments
+must either both be scalars or both be lists. Otherwise Perl won't
+know which context to supply to the right side.
+
+=item Attempt to free non-arena SV: 0x%lx
+
+(P) All SV objects are supposed to be allocated from arenas that will
+be garbage collected on exit. An SV was discovered to be outside any
+of those arenas.
+
+=item Attempt to free nonexistent shared string
+
+(P) Perl maintains a reference counted internal table of strings to
+optimize the storage and access of hash keys and other strings. This
+indicates someone tried to decrement the reference count of a string
+that can no longer be found in the table.
+
+=item Attempt to free temp prematurely
+
+(W) Mortalized values are supposed to be freed by the free_tmps()
+routine. This indicates that something else is freeing the SV before
+the free_tmps() routine gets a chance, which means that the free_tmps()
+routine will be freeing an unreferenced scalar when it does try to free
+it.
+
+=item Attempt to free unreferenced glob pointers
+
+(P) The reference counts got screwed up on symbol aliases.
+
+=item Attempt to free unreferenced scalar
+
+(W) Perl went to decrement the reference count of a scalar to see if it
+would go to 0, and discovered that it had already gone to 0 earlier,
+and should have been freed, and in fact, probably was freed. This
+could indicate that SvREFCNT_dec() was called too many times, or that
+SvREFCNT_inc() was called too few times, or that the SV was mortalized
+when it shouldn't have been, or that memory has been corrupted.
+
+=item Attempt to pack pointer to temporary value
+
+(W) You tried to pass a temporary value (like the result of a
+function, or a computed expression) to the "p" pack() template. This
+means the result contains a pointer to a location that could become
+invalid anytime, even before the end of the current statement. Use
+literals or global values as arguments to the "p" pack() template to
+avoid this warning.
+
+=item Attempt to use reference as lvalue in substr
+
+(W) You supplied a reference as the first argument to substr() used
+as an lvalue, which is pretty strange. Perhaps you forgot to
+dereference it first. See L<perlfunc/substr>.
+
+=item Bad arg length for %s, is %d, should be %d
+
+(F) You passed a buffer of the wrong size to one of msgctl(), semctl() or
+shmctl(). In C parlance, the correct sizes are, respectively,
+S<sizeof(struct msqid_ds *)>, S<sizeof(struct semid_ds *)>, and
+S<sizeof(struct shmid_ds *)>.
+
+=item Bad filehandle: %s
+
+(F) A symbol was passed to something wanting a filehandle, but the symbol
+has no filehandle associated with it. Perhaps you didn't do an open(), or
+did it in another package.
+
+=item Bad free() ignored
+
+(S) An internal routine called free() on something that had never been
+malloc()ed in the first place. Mandatory, but can be disabled by
+setting environment variable C<PERL_BADFREE> to 1.
+
+This message can be quite often seen with DB_File on systems with
+"hard" dynamic linking, like C<AIX> and C<OS/2>. It is a bug of
+C<Berkeley DB> which is left unnoticed if C<DB> uses I<forgiving>
+system malloc().
+
+=item Bad hash
+
+(P) One of the internal hash routines was passed a null HV pointer.
+
+=item Bad index while coercing array into hash
+
+(F) The index looked up in the hash found as the 0'th element of a
+pseudo-hash is not legal. Index values must be at 1 or greater.
+See L<perlref>.
+
+=item Bad name after %s::
+
+(F) You started to name a symbol by using a package prefix, and then didn't
+finish the symbol. In particular, you can't interpolate outside of quotes,
+so
+
+ $var = 'myvar';
+ $sym = mypack::$var;
+
+is not the same as
+
+ $var = 'myvar';
+ $sym = "mypack::$var";
+
+=item Bad symbol for array
+
+(P) An internal request asked to add an array entry to something that
+wasn't a symbol table entry.
+
+=item Bad symbol for filehandle
+
+(P) An internal request asked to add a filehandle entry to something that
+wasn't a symbol table entry.
+
+=item Bad symbol for hash
+
+(P) An internal request asked to add a hash entry to something that
+wasn't a symbol table entry.
+
+=item Badly placed ()'s
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item Bareword "%s" not allowed while "strict subs" in use
+
+(F) With "strict subs" in use, a bareword is only allowed as a
+subroutine identifier, in curly braces or to the left of the "=>" symbol.
+Perhaps you need to predeclare a subroutine?
+
+=item Bareword "%s" refers to nonexistent package
+
+(W) You used a qualified bareword of the form C<Foo::>, but
+the compiler saw no other uses of that namespace before that point.
+Perhaps you need to predeclare a package?
+
+=item BEGIN failed--compilation aborted
+
+(F) An untrapped exception was raised while executing a BEGIN subroutine.
+Compilation stops immediately and the interpreter is exited.
+
+=item BEGIN not safe after errors--compilation aborted
+
+(F) Perl found a C<BEGIN {}> subroutine (or a C<use> directive, which
+implies a C<BEGIN {}>) after one or more compilation errors had
+already occurred. Since the intended environment for the C<BEGIN {}>
+could not be guaranteed (due to the errors), and since subsequent code
+likely depends on its correct operation, Perl just gave up.
+
+=item bind() on closed fd
+
+(W) You tried to do a bind on a closed socket. Did you forget to check
+the return value of your socket() call? See L<perlfunc/bind>.
+
+=item Bizarre copy of %s in %s
+
+(P) Perl detected an attempt to copy an internal value that is not copiable.
+
+=item Callback called exit
+
+(F) A subroutine invoked from an external package via perl_call_sv()
+exited by calling exit.
+
+=item Can't "goto" outside a block
+
+(F) A "goto" statement was executed to jump out of what might look
+like a block, except that it isn't a proper block. This usually
+occurs if you tried to jump out of a sort() block or subroutine, which
+is a no-no. See L<perlfunc/goto>.
+
+=item Can't "goto" into the middle of a foreach loop
+
+(F) A "goto" statement was executed to jump into the middle of a
+foreach loop. You can't get there from here. See L<perlfunc/goto>.
+
+=item Can't "last" outside a block
+
+(F) A "last" statement was executed to break out of the current block,
+except that there's this itty bitty problem called there isn't a
+current block. Note that an "if" or "else" block doesn't count as a
+"loopish" block, as doesn't a block given to sort(). You can usually double
+the curlies to get the same effect though, because the inner curlies
+will be considered a block that loops once. See L<perlfunc/last>.
+
+=item Can't "next" outside a block
+
+(F) A "next" statement was executed to reiterate the current block, but
+there isn't a current block. Note that an "if" or "else" block doesn't
+count as a "loopish" block, as doesn't a block given to sort(). You can
+usually double the curlies to get the same effect though, because the inner
+curlies will be considered a block that loops once. See L<perlfunc/next>.
+
+=item Can't "redo" outside a block
+
+(F) A "redo" statement was executed to restart the current block, but
+there isn't a current block. Note that an "if" or "else" block doesn't
+count as a "loopish" block, as doesn't a block given to sort(). You can
+usually double the curlies to get the same effect though, because the inner
+curlies will be considered a block that loops once. See L<perlfunc/redo>.
+
+=item Can't bless non-reference value
+
+(F) Only hard references may be blessed. This is how Perl "enforces"
+encapsulation of objects. See L<perlobj>.
+
+=item Can't break at that line
+
+(S) A warning intended to only be printed while running within the debugger, indicating
+the line number specified wasn't the location of a statement that could
+be stopped at.
+
+=item Can't call method "%s" in empty package "%s"
+
+(F) You called a method correctly, and it correctly indicated a package
+functioning as a class, but that package doesn't have ANYTHING defined
+in it, let alone methods. See L<perlobj>.
+
+=item Can't call method "%s" on unblessed reference
+
+(F) A method call must know in what package it's supposed to run. It
+ordinarily finds this out from the object reference you supply, but
+you didn't supply an object reference in this case. A reference isn't
+an object reference until it has been blessed. See L<perlobj>.
+
+=item Can't call method "%s" without a package or object reference
+
+(F) You used the syntax of a method call, but the slot filled by the
+object reference or package name contains an expression that returns
+a defined value which is neither an object reference nor a package name.
+Something like this will reproduce the error:
+
+ $BADREF = 42;
+ process $BADREF 1,2,3;
+ $BADREF->process(1,2,3);
+
+=item Can't call method "%s" on an undefined value
+
+(F) You used the syntax of a method call, but the slot filled by the
+object reference or package name contains an undefined value.
+Something like this will reproduce the error:
+
+ $BADREF = undef;
+ process $BADREF 1,2,3;
+ $BADREF->process(1,2,3);
+
+=item Can't chdir to %s
+
+(F) You called C<perl -x/foo/bar>, but C</foo/bar> is not a directory
+that you can chdir to, possibly because it doesn't exist.
+
+=item Can't coerce %s to integer in %s
+
+(F) Certain types of SVs, in particular real symbol table entries
+(typeglobs), can't be forced to stop being what they are. So you can't
+say things like:
+
+ *foo += 1;
+
+You CAN say
+
+ $foo = *foo;
+ $foo += 1;
+
+but then $foo no longer contains a glob.
+
+=item Can't coerce %s to number in %s
+
+(F) Certain types of SVs, in particular real symbol table entries
+(typeglobs), can't be forced to stop being what they are.
+
+=item Can't coerce %s to string in %s
+
+(F) Certain types of SVs, in particular real symbol table entries
+(typeglobs), can't be forced to stop being what they are.
+
+=item Can't coerce array into hash
+
+(F) You used an array where a hash was expected, but the array has no
+information on how to map from keys to array indices. You can do that
+only with arrays that have a hash reference at index 0.
+
+=item Can't create pipe mailbox
+
+(P) An error peculiar to VMS. The process is suffering from exhausted quotas
+or other plumbing problems.
+
+=item Can't declare %s in my
+
+(F) Only scalar, array, and hash variables may be declared as lexical variables.
+They must have ordinary identifiers as names.
+
+=item Can't do inplace edit on %s: %s
+
+(S) The creation of the new file failed for the indicated reason.
+
+=item Can't do inplace edit without backup
+
+(F) You're on a system such as MS-DOS that gets confused if you try reading
+from a deleted (but still opened) file. You have to say C<-i.bak>, or some
+such.
+
+=item Can't do inplace edit: %s E<gt> 14 characters
+
+(S) There isn't enough room in the filename to make a backup name for the file.
+
+=item Can't do inplace edit: %s is not a regular file
+
+(S) You tried to use the B<-i> switch on a special file, such as a file in
+/dev, or a FIFO. The file was ignored.
+
+=item Can't do setegid!
+
+(P) The setegid() call failed for some reason in the setuid emulator
+of suidperl.
+
+=item Can't do seteuid!
+
+(P) The setuid emulator of suidperl failed for some reason.
+
+=item Can't do setuid
+
+(F) This typically means that ordinary perl tried to exec suidperl to
+do setuid emulation, but couldn't exec it. It looks for a name of the
+form sperl5.000 in the same directory that the perl executable resides
+under the name perl5.000, typically /usr/local/bin on Unix machines.
+If the file is there, check the execute permissions. If it isn't, ask
+your sysadmin why he and/or she removed it.
+
+=item Can't do waitpid with flags
+
+(F) This machine doesn't have either waitpid() or wait4(), so only waitpid()
+without flags is emulated.
+
+=item Can't do {n,m} with n E<gt> m
+
+(F) Minima must be less than or equal to maxima. If you really want
+your regexp to match something 0 times, just put {0}. See L<perlre>.
+
+=item Can't emulate -%s on #! line
+
+(F) The #! line specifies a switch that doesn't make sense at this point.
+For example, it'd be kind of silly to put a B<-x> on the #! line.
+
+=item Can't exec "%s": %s
+
+(W) An system(), exec(), or piped open call could not execute the named
+program for the indicated reason. Typical reasons include: the permissions
+were wrong on the file, the file wasn't found in C<$ENV{PATH}>, the
+executable in question was compiled for another architecture, or the
+#! line in a script points to an interpreter that can't be run for
+similar reasons. (Or maybe your system doesn't support #! at all.)
+
+=item Can't exec %s
+
+(F) Perl was trying to execute the indicated program for you because that's
+what the #! line said. If that's not what you wanted, you may need to
+mention "perl" on the #! line somewhere.
+
+=item Can't execute %s
+
+(F) You used the B<-S> switch, but the copies of the script to execute found
+in the PATH did not have correct permissions.
+
+=item Can't find %s on PATH, '.' not in PATH
+
+(F) You used the B<-S> switch, but the script to execute could not be found
+in the PATH, or at least not with the correct permissions. The script
+exists in the current directory, but PATH prohibits running it.
+
+=item Can't find %s on PATH
+
+(F) You used the B<-S> switch, but the script to execute could not be found
+in the PATH.
+
+=item Can't find label %s
+
+(F) You said to goto a label that isn't mentioned anywhere that it's possible
+for us to go to. See L<perlfunc/goto>.
+
+=item Can't find string terminator %s anywhere before EOF
+
+(F) Perl strings can stretch over multiple lines. This message means that
+the closing delimiter was omitted. Because bracketed quotes count nesting
+levels, the following is missing its final parenthesis:
+
+ print q(The character '(' starts a side comment.);
+
+If you're getting this error from a here-document, you may have
+included unseen whitespace before or after your closing tag. A good
+programmer's editor will have a way to help you find these characters.
+
+=item Can't fork
+
+(F) A fatal error occurred while trying to fork while opening a pipeline.
+
+=item Can't get filespec - stale stat buffer?
+
+(S) A warning peculiar to VMS. This arises because of the difference between
+access checks under VMS and under the Unix model Perl assumes. Under VMS,
+access checks are done by filename, rather than by bits in the stat buffer, so
+that ACLs and other protections can be taken into account. Unfortunately, Perl
+assumes that the stat buffer contains all the necessary information, and passes
+it, instead of the filespec, to the access checking routine. It will try to
+retrieve the filespec using the device name and FID present in the stat buffer,
+but this works only if you haven't made a subsequent call to the CRTL stat()
+routine, because the device name is overwritten with each call. If this warning
+appears, the name lookup failed, and the access checking routine gave up and
+returned FALSE, just to be conservative. (Note: The access checking routine
+knows about the Perl C<stat> operator and file tests, so you shouldn't ever
+see this warning in response to a Perl command; it arises only if some internal
+code takes stat buffers lightly.)
+
+=item Can't get pipe mailbox device name
+
+(P) An error peculiar to VMS. After creating a mailbox to act as a pipe, Perl
+can't retrieve its name for later use.
+
+=item Can't get SYSGEN parameter value for MAXBUF
+
+(P) An error peculiar to VMS. Perl asked $GETSYI how big you want your
+mailbox buffers to be, and didn't get an answer.
+
+=item Can't goto subroutine outside a subroutine
+
+(F) The deeply magical "goto subroutine" call can only replace one subroutine
+call for another. It can't manufacture one out of whole cloth. In general
+you should be calling it out of only an AUTOLOAD routine anyway. See
+L<perlfunc/goto>.
+
+=item Can't goto subroutine from an eval-string
+
+(F) The "goto subroutine" call can't be used to jump out of an eval "string".
+(You can use it to jump out of an eval {BLOCK}, but you probably don't want to.)
+
+=item Can't localize through a reference
+
+(F) You said something like C<local $$ref>, which Perl can't currently
+handle, because when it goes to restore the old value of whatever $ref
+pointed to after the scope of the local() is finished, it can't be
+sure that $ref will still be a reference.
+
+=item Can't localize lexical variable %s
+
+(F) You used local on a variable name that was previously declared as a
+lexical variable using "my". This is not allowed. If you want to
+localize a package variable of the same name, qualify it with the
+package name.
+
+=item Can't localize pseudo-hash element
+
+(F) You said something like C<local $ar-E<gt>{'key'}>, where $ar is
+a reference to a pseudo-hash. That hasn't been implemented yet, but
+you can get a similar effect by localizing the corresponding array
+element directly -- C<local $ar-E<gt>[$ar-E<gt>[0]{'key'}]>.
+
+=item Can't locate auto/%s.al in @INC
+
+(F) A function (or method) was called in a package which allows autoload,
+but there is no function to autoload. Most probable causes are a misprint
+in a function/method name or a failure to C<AutoSplit> the file, say, by
+doing C<make install>.
+
+=item Can't locate %s in @INC
+
+(F) You said to do (or require, or use) a file that couldn't be found
+in any of the libraries mentioned in @INC. Perhaps you need to set the
+PERL5LIB or PERL5OPT environment variable to say where the extra library
+is, or maybe the script needs to add the library name to @INC. Or maybe
+you just misspelled the name of the file. See L<perlfunc/require>.
+
+=item Can't locate object method "%s" via package "%s"
+
+(F) You called a method correctly, and it correctly indicated a package
+functioning as a class, but that package doesn't define that particular
+method, nor does any of its base classes. See L<perlobj>.
+
+=item Can't locate package %s for @%s::ISA
+
+(W) The @ISA array contained the name of another package that doesn't seem
+to exist.
+
+=item Can't make list assignment to \%ENV on this system
+
+(F) List assignment to %ENV is not supported on some systems, notably VMS.
+
+=item Can't modify %s in %s
+
+(F) You aren't allowed to assign to the item indicated, or otherwise try to
+change it, such as with an auto-increment.
+
+=item Can't modify nonexistent substring
+
+(P) The internal routine that does assignment to a substr() was handed
+a NULL.
+
+=item Can't msgrcv to read-only var
+
+(F) The target of a msgrcv must be modifiable to be used as a receive
+buffer.
+
+=item Can't open %s: %s
+
+(S) The implicit opening of a file through use of the C<E<lt>E<gt>>
+filehandle, either implicitly under the C<-n> or C<-p> command-line
+switches, or explicitly, failed for the indicated reason. Usually this
+is because you don't have read permission for a file which you named
+on the command line.
+
+=item Can't open bidirectional pipe
+
+(W) You tried to say C<open(CMD, "|cmd|")>, which is not supported. You can
+try any of several modules in the Perl library to do this, such as
+IPC::Open2. Alternately, direct the pipe's output to a file using "E<gt>",
+and then read it in under a different file handle.
+
+=item Can't open error file %s as stderr
+
+(F) An error peculiar to VMS. Perl does its own command line redirection, and
+couldn't open the file specified after '2E<gt>' or '2E<gt>E<gt>' on the
+command line for writing.
+
+=item Can't open input file %s as stdin
+
+(F) An error peculiar to VMS. Perl does its own command line redirection, and
+couldn't open the file specified after 'E<lt>' on the command line for reading.
+
+=item Can't open output file %s as stdout
+
+(F) An error peculiar to VMS. Perl does its own command line redirection, and
+couldn't open the file specified after 'E<gt>' or 'E<gt>E<gt>' on the command
+line for writing.
+
+=item Can't open output pipe (name: %s)
+
+(P) An error peculiar to VMS. Perl does its own command line redirection, and
+couldn't open the pipe into which to send data destined for stdout.
+
+=item Can't open perl script "%s": %s
+
+(F) The script you specified can't be opened for the indicated reason.
+
+=item Can't redefine active sort subroutine %s
+
+(F) Perl optimizes the internal handling of sort subroutines and keeps
+pointers into them. You tried to redefine one such sort subroutine when it
+was currently active, which is not allowed. If you really want to do
+this, you should write C<sort { &func } @x> instead of C<sort func @x>.
+
+=item Can't rename %s to %s: %s, skipping file
+
+(S) The rename done by the B<-i> switch failed for some reason, probably because
+you don't have write permission to the directory.
+
+=item Can't reopen input pipe (name: %s) in binary mode
+
+(P) An error peculiar to VMS. Perl thought stdin was a pipe, and tried to
+reopen it to accept binary data. Alas, it failed.
+
+=item Can't reswap uid and euid
+
+(P) The setreuid() call failed for some reason in the setuid emulator
+of suidperl.
+
+=item Can't return outside a subroutine
+
+(F) The return statement was executed in mainline code, that is, where
+there was no subroutine call to return out of. See L<perlsub>.
+
+=item Can't stat script "%s"
+
+(P) For some reason you can't fstat() the script even though you have
+it open already. Bizarre.
+
+=item Can't swap uid and euid
+
+(P) The setreuid() call failed for some reason in the setuid emulator
+of suidperl.
+
+=item Can't take log of %g
+
+(F) For ordinary real numbers, you can't take the logarithm of a
+negative number or zero. There's a Math::Complex package that comes
+standard with Perl, though, if you really want to do that for
+the negative numbers.
+
+=item Can't take sqrt of %g
+
+(F) For ordinary real numbers, you can't take the square root of a
+negative number. There's a Math::Complex package that comes standard
+with Perl, though, if you really want to do that.
+
+=item Can't undef active subroutine
+
+(F) You can't undefine a routine that's currently running. You can,
+however, redefine it while it's running, and you can even undef the
+redefined subroutine while the old routine is running. Go figure.
+
+=item Can't unshift
+
+(F) You tried to unshift an "unreal" array that can't be unshifted, such
+as the main Perl stack.
+
+=item Can't upgrade that kind of scalar
+
+(P) The internal sv_upgrade routine adds "members" to an SV, making
+it into a more specialized kind of SV. The top several SV types are
+so specialized, however, that they cannot be interconverted. This
+message indicates that such a conversion was attempted.
+
+=item Can't upgrade to undef
+
+(P) The undefined SV is the bottom of the totem pole, in the scheme
+of upgradability. Upgrading to undef indicates an error in the
+code calling sv_upgrade.
+
+=item Can't use %%! because Errno.pm is not available
+
+(F) The first time the %! hash is used, perl automatically loads the
+Errno.pm module. The Errno module is expected to tie the %! hash to
+provide symbolic names for C<$!> errno values.
+
+=item Can't use "my %s" in sort comparison
+
+(F) The global variables $a and $b are reserved for sort comparisons.
+You mentioned $a or $b in the same line as the E<lt>=E<gt> or cmp operator,
+and the variable had earlier been declared as a lexical variable.
+Either qualify the sort variable with the package name, or rename the
+lexical variable.
+
+=item Can't use %s for loop variable
+
+(F) Only a simple scalar variable may be used as a loop variable on a foreach.
+
+=item Can't use %s ref as %s ref
+
+(F) You've mixed up your reference types. You have to dereference a
+reference of the type needed. You can use the ref() function to
+test the type of the reference, if need be.
+
+=item Can't use \1 to mean $1 in expression
+
+(W) In an ordinary expression, backslash is a unary operator that creates
+a reference to its argument. The use of backslash to indicate a backreference
+to a matched substring is valid only as part of a regular expression pattern.
+Trying to do this in ordinary Perl code produces a value that prints
+out looking like SCALAR(0xdecaf). Use the $1 form instead.
+
+=item Can't use bareword ("%s") as %s ref while \"strict refs\" in use
+
+(F) Only hard references are allowed by "strict refs". Symbolic references
+are disallowed. See L<perlref>.
+
+=item Can't use string ("%s") as %s ref while "strict refs" in use
+
+(F) Only hard references are allowed by "strict refs". Symbolic references
+are disallowed. See L<perlref>.
+
+=item Can't use an undefined value as %s reference
+
+(F) A value used as either a hard reference or a symbolic reference must
+be a defined value. This helps to delurk some insidious errors.
+
+=item Can't use global %s in "my"
+
+(F) You tried to declare a magical variable as a lexical variable. This is
+not allowed, because the magic can be tied to only one location (namely
+the global variable) and it would be incredibly confusing to have
+variables in your program that looked like magical variables but
+weren't.
+
+=item Can't use subscript on %s
+
+(F) The compiler tried to interpret a bracketed expression as a
+subscript. But to the left of the brackets was an expression that
+didn't look like an array reference, or anything else subscriptable.
+
+=item Can't x= to read-only value
+
+(F) You tried to repeat a constant value (often the undefined value) with
+an assignment operator, which implies modifying the value itself.
+Perhaps you need to copy the value to a temporary, and repeat that.
+
+=item Cannot find an opnumber for "%s"
+
+(F) A string of a form C<CORE::word> was given to prototype(), but
+there is no builtin with the name C<word>.
+
+=item Cannot resolve method `%s' overloading `%s' in package `%s'
+
+(F|P) Error resolving overloading specified by a method name (as
+opposed to a subroutine reference): no such method callable via the
+package. If method name is C<???>, this is an internal error.
+
+=item Character class syntax [. .] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax beginning
+with "[." and ending with ".]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[." and ".\]".
+
+=item Character class syntax [: :] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax beginning
+with "[:" and ending with ":]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[:" and ":\]".
+
+=item Character class syntax [= =] is reserved for future extensions
+
+(W) Within regular expression character classes ([]) the syntax
+beginning with "[=" and ending with "=]" is reserved for future extensions.
+If you need to represent those character sequences inside a regular
+expression character class, just quote the square brackets with the
+backslash: "\[=" and "=\]".
+
+=item chmod: mode argument is missing initial 0
+
+(W) A novice will sometimes say
+
+ chmod 777, $filename
+
+not realizing that 777 will be interpreted as a decimal number, equivalent
+to 01411. Octal constants are introduced with a leading 0 in Perl, as in C.
+
+=item Close on unopened file E<lt>%sE<gt>
+
+(W) You tried to close a filehandle that was never opened.
+
+=item Compilation failed in require
+
+(F) Perl could not compile a file specified in a C<require> statement.
+Perl uses this generic message when none of the errors that it encountered
+were severe enough to halt compilation immediately.
+
+=item Complex regular subexpression recursion limit (%d) exceeded
+
+(W) The regular expression engine uses recursion in complex situations
+where back-tracking is required. Recursion depth is limited to 32766,
+or perhaps less in architectures where the stack cannot grow
+arbitrarily. ("Simple" and "medium" situations are handled without
+recursion and are not subject to a limit.) Try shortening the string
+under examination; looping in Perl code (e.g. with C<while>) rather
+than in the regular expression engine; or rewriting the regular
+expression so that it is simpler or backtracks less. (See L<perlbook>
+for information on I<Mastering Regular Expressions>.)
+
+=item connect() on closed fd
+
+(W) You tried to do a connect on a closed socket. Did you forget to check
+the return value of your socket() call? See L<perlfunc/connect>.
+
+=item Constant subroutine %s redefined
+
+(S) You redefined a subroutine which had previously been eligible for
+inlining. See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Constant subroutine %s undefined
+
+(S) You undefined a subroutine which had previously been eligible for
+inlining. See L<perlsub/"Constant Functions"> for commentary and
+workarounds.
+
+=item Copy method did not return a reference
+
+(F) The method which overloads "=" is buggy. See L<overload/Copy Constructor>.
+
+=item Corrupt malloc ptr 0x%lx at 0x%lx
+
+(P) The malloc package that comes with Perl had an internal failure.
+
+=item corrupted regexp pointers
+
+(P) The regular expression engine got confused by what the regular
+expression compiler gave it.
+
+=item corrupted regexp program
+
+(P) The regular expression engine got passed a regexp program without
+a valid magic number.
+
+=item Deep recursion on subroutine "%s"
+
+(W) This subroutine has called itself (directly or indirectly) 100
+times more than it has returned. This probably indicates an infinite
+recursion, unless you're writing strange benchmark programs, in which
+case it indicates something else.
+
+=item Delimiter for here document is too long
+
+(F) In a here document construct like C<E<lt>E<lt>FOO>, the label
+C<FOO> is too long for Perl to handle. You have to be seriously
+twisted to write code that triggers this error.
+
+=item Did you mean &%s instead?
+
+(W) You probably referred to an imported subroutine &FOO as $FOO or some such.
+
+=item Did you mean $ or @ instead of %?
+
+(W) You probably said %hash{$key} when you meant $hash{$key} or @hash{@keys}.
+On the other hand, maybe you just meant %hash and got carried away.
+
+=item Died
+
+(F) You passed die() an empty string (the equivalent of C<die "">) or
+you called it with no args and both C<$@> and C<$_> were empty.
+
+=item Do you need to predeclare %s?
+
+(S) This is an educated guess made in conjunction with the message "%s
+found where operator expected". It often means a subroutine or module
+name is being referenced that hasn't been declared yet. This may be
+because of ordering problems in your file, or because of a missing
+"sub", "package", "require", or "use" statement. If you're
+referencing something that isn't defined yet, you don't actually have
+to define the subroutine or package before the current location. You
+can use an empty "sub foo;" or "package FOO;" to enter a "forward"
+declaration.
+
+=item Don't know how to handle magic of type '%s'
+
+(P) The internal handling of magical variables has been cursed.
+
+=item do_study: out of memory
+
+(P) This should have been caught by safemalloc() instead.
+
+=item Duplicate free() ignored
+
+(S) An internal routine called free() on something that had already
+been freed.
+
+=item elseif should be elsif
+
+(S) There is no keyword "elseif" in Perl because Larry thinks it's
+ugly. Your code will be interpreted as an attempt to call a method
+named "elseif" for the class returned by the following block. This is
+unlikely to be what you want.
+
+=item END failed--cleanup aborted
+
+(F) An untrapped exception was raised while executing an END subroutine.
+The interpreter is immediately exited.
+
+=item Error converting file specification %s
+
+(F) An error peculiar to VMS. Because Perl may have to deal with file
+specifications in either VMS or Unix syntax, it converts them to a
+single form when it must operate on them directly. Either you've
+passed an invalid file specification to Perl, or you've found a
+case the conversion routines don't handle. Drat.
+
+=item %s: Eval-group in insecure regular expression
+
+(F) Perl detected tainted data when trying to compile a regular expression
+that contains the C<(?{ ... })> zero-width assertion, which is unsafe.
+See L<perlre/(?{ code })>, and L<perlsec>.
+
+=item %s: Eval-group not allowed, use re 'eval'
+
+(F) A regular expression contained the C<(?{ ... })> zero-width assertion,
+but that construct is only allowed when the C<use re 'eval'> pragma is
+in effect. See L<perlre/(?{ code })>.
+
+=item %s: Eval-group not allowed at run time
+
+(F) Perl tried to compile a regular expression containing the C<(?{ ... })>
+zero-width assertion at run time, as it would when the pattern contains
+interpolated values. Since that is a security risk, it is not allowed.
+If you insist, you may still do this by explicitly building the pattern
+from an interpolated string at run time and using that in an eval().
+See L<perlre/(?{ code })>.
+
+=item Excessively long <> operator
+
+(F) The contents of a <> operator may not exceed the maximum size of a
+Perl identifier. If you're just trying to glob a long list of
+filenames, try using the glob() operator, or put the filenames into a
+variable and glob that.
+
+=item Execution of %s aborted due to compilation errors
+
+(F) The final summary message when a Perl compilation fails.
+
+=item Exiting eval via %s
+
+(W) You are exiting an eval by unconventional means, such as
+a goto, or a loop control statement.
+
+=item Exiting pseudo-block via %s
+
+(W) You are exiting a rather special block construct (like a sort block or
+subroutine) by unconventional means, such as a goto, or a loop control
+statement. See L<perlfunc/sort>.
+
+=item Exiting subroutine via %s
+
+(W) You are exiting a subroutine by unconventional means, such as
+a goto, or a loop control statement.
+
+=item Exiting substitution via %s
+
+(W) You are exiting a substitution by unconventional means, such as
+a return, a goto, or a loop control statement.
+
+=item Explicit blessing to '' (assuming package main)
+
+(W) You are blessing a reference to a zero length string. This has
+the effect of blessing the reference into the package main. This is
+usually not what you want. Consider providing a default target
+package, e.g. bless($ref, $p or 'MyPackage');
+
+=item Fatal VMS error at %s, line %d
+
+(P) An error peculiar to VMS. Something untoward happened in a VMS system
+service or RTL routine; Perl's exit status should provide more details. The
+filename in "at %s" and the line number in "line %d" tell you which section of
+the Perl source code is distressed.
+
+=item fcntl is not implemented
+
+(F) Your machine apparently doesn't implement fcntl(). What is this, a
+PDP-11 or something?
+
+=item Filehandle %s never opened
+
+(W) An I/O operation was attempted on a filehandle that was never initialized.
+You need to do an open() or a socket() call, or call a constructor from
+the FileHandle package.
+
+=item Filehandle %s opened for only input
+
+(W) You tried to write on a read-only filehandle. If you
+intended it to be a read-write filehandle, you needed to open it with
+"+E<lt>" or "+E<gt>" or "+E<gt>E<gt>" instead of with "E<lt>" or nothing. If
+you intended only to write the file, use "E<gt>" or "E<gt>E<gt>". See
+L<perlfunc/open>.
+
+=item Filehandle opened for only input
+
+(W) You tried to write on a read-only filehandle. If you
+intended it to be a read-write filehandle, you needed to open it with
+"+E<lt>" or "+E<gt>" or "+E<gt>E<gt>" instead of with "E<lt>" or nothing. If
+you intended only to write the file, use "E<gt>" or "E<gt>E<gt>". See
+L<perlfunc/open>.
+
+=item Final $ should be \$ or $name
+
+(F) You must now decide whether the final $ in a string was meant to be
+a literal dollar sign, or was meant to introduce a variable name
+that happens to be missing. So you have to put either the backslash or
+the name.
+
+=item Final @ should be \@ or @name
+
+(F) You must now decide whether the final @ in a string was meant to be
+a literal "at" sign, or was meant to introduce a variable name
+that happens to be missing. So you have to put either the backslash or
+the name.
+
+=item Format %s redefined
+
+(W) You redefined a format. To suppress this warning, say
+
+ {
+ local $^W = 0;
+ eval "format NAME =...";
+ }
+
+=item Format not terminated
+
+(F) A format must be terminated by a line with a solitary dot. Perl got
+to the end of your file without finding such a line.
+
+=item Found = in conditional, should be ==
+
+(W) You said
+
+ if ($foo = 123)
+
+when you meant
+
+ if ($foo == 123)
+
+(or something like that).
+
+=item gdbm store returned %d, errno %d, key "%s"
+
+(S) A warning from the GDBM_File extension that a store failed.
+
+=item gethostent not implemented
+
+(F) Your C library apparently doesn't implement gethostent(), probably
+because if it did, it'd feel morally obligated to return every hostname
+on the Internet.
+
+=item get{sock,peer}name() on closed fd
+
+(W) You tried to get a socket or peer socket name on a closed socket.
+Did you forget to check the return value of your socket() call?
+
+=item getpwnam returned invalid UIC %#o for user "%s"
+
+(S) A warning peculiar to VMS. The call to C<sys$getuai> underlying the
+C<getpwnam> operator returned an invalid UIC.
+
+
+=item Glob not terminated
+
+(F) The lexer saw a left angle bracket in a place where it was expecting
+a term, so it's looking for the corresponding right angle bracket, and not
+finding it. Chances are you left some needed parentheses out earlier in
+the line, and you really meant a "less than".
+
+=item Global symbol "%s" requires explicit package name
+
+(F) You've said "use strict vars", which indicates that all variables
+must either be lexically scoped (using "my"), or explicitly qualified to
+say which package the global variable is in (using "::").
+
+=item goto must have label
+
+(F) Unlike with "next" or "last", you're not allowed to goto an
+unspecified destination. See L<perlfunc/goto>.
+
+=item Had to create %s unexpectedly
+
+(S) A routine asked for a symbol from a symbol table that ought to have
+existed already, but for some reason it didn't, and had to be created on
+an emergency basis to prevent a core dump.
+
+=item Hash %%s missing the % in argument %d of %s()
+
+(D) Really old Perl let you omit the % on hash names in some spots. This
+is now heavily deprecated.
+
+=item Identifier too long
+
+(F) Perl limits identifiers (names for variables, functions, etc.) to
+about 250 characters for simple names, and somewhat more for compound
+names (like C<$A::B>). You've exceeded Perl's limits. Future
+versions of Perl are likely to eliminate these arbitrary limitations.
+
+=item Ill-formed logical name |%s| in prime_env_iter
+
+(W) A warning peculiar to VMS. A logical name was encountered when preparing
+to iterate over %ENV which violates the syntactic rules governing logical
+names. Because it cannot be translated normally, it is skipped, and will not
+appear in %ENV. This may be a benign occurrence, as some software packages
+might directly modify logical name tables and introduce nonstandard names,
+or it may indicate that a logical name table has been corrupted.
+
+=item Illegal character %s (carriage return)
+
+(F) A carriage return character was found in the input. This is an
+error, and not a warning, because carriage return characters can break
+multi-line strings, including here documents (e.g., C<print E<lt>E<lt>EOF;>).
+
+Under Unix, this error is usually caused by executing Perl code --
+either the main program, a module, or an eval'd string -- that was
+transferred over a network connection from a non-Unix system without
+properly converting the text file format.
+
+Under systems that use something other than '\n' to delimit lines of
+text, this error can also be caused by reading Perl code from a file
+handle that is in binary mode (as set by the C<binmode> operator).
+
+In either case, the Perl code in question will probably need to be
+converted with something like C<s/\x0D\x0A?/\n/g> before it can be
+executed.
+
+=item Illegal division by zero
+
+(F) You tried to divide a number by 0. Either something was wrong in your
+logic, or you need to put a conditional in to guard against meaningless input.
+
+=item Illegal modulus zero
+
+(F) You tried to divide a number by 0 to get the remainder. Most numbers
+don't take to this kindly.
+
+=item Illegal octal digit
+
+(F) You used an 8 or 9 in a octal number.
+
+=item Illegal octal digit ignored
+
+(W) You may have tried to use an 8 or 9 in a octal number. Interpretation
+of the octal number stopped before the 8 or 9.
+
+=item Illegal hex digit ignored
+
+(W) You may have tried to use a character other than 0 - 9 or A - F in a
+hexadecimal number. Interpretation of the hexadecimal number stopped
+before the illegal character.
+
+=item Illegal switch in PERL5OPT: %s
+
+(X) The PERL5OPT environment variable may only be used to set the
+following switches: B<-[DIMUdmw]>.
+
+=item In string, @%s now must be written as \@%s
+
+(F) It used to be that Perl would try to guess whether you wanted an
+array interpolated or a literal @. It did this when the string was first
+used at runtime. Now strings are parsed at compile time, and ambiguous
+instances of @ must be disambiguated, either by prepending a backslash to
+indicate a literal, or by declaring (or using) the array within the
+program before the string (lexically). (Someday it will simply assume
+that an unbackslashed @ interpolates an array.)
+
+=item Insecure dependency in %s
+
+(F) You tried to do something that the tainting mechanism didn't like.
+The tainting mechanism is turned on when you're running setuid or setgid,
+or when you specify B<-T> to turn it on explicitly. The tainting mechanism
+labels all data that's derived directly or indirectly from the user,
+who is considered to be unworthy of your trust. If any such data is
+used in a "dangerous" operation, you get this error. See L<perlsec>
+for more information.
+
+=item Insecure directory in %s
+
+(F) You can't use system(), exec(), or a piped open in a setuid or setgid
+script if C<$ENV{PATH}> contains a directory that is writable by the world.
+See L<perlsec>.
+
+=item Insecure $ENV{%s} while running %s
+
+(F) You can't use system(), exec(), or a piped open in a setuid or
+setgid script if any of C<$ENV{PATH}>, C<$ENV{IFS}>, C<$ENV{CDPATH}>,
+C<$ENV{ENV}> or C<$ENV{BASH_ENV}> are derived from data supplied (or
+potentially supplied) by the user. The script must set the path to a
+known value, using trustworthy data. See L<perlsec>.
+
+=item Integer overflow in hex number
+
+(S) The literal hex number you have specified is too big for your
+architecture. On a 32-bit architecture the largest hex literal is
+0xFFFFFFFF.
+
+=item Integer overflow in octal number
+
+(S) The literal octal number you have specified is too big for your
+architecture. On a 32-bit architecture the largest octal literal is
+037777777777.
+
+=item Internal inconsistency in tracking vforks
+
+(S) A warning peculiar to VMS. Perl keeps track of the number
+of times you've called C<fork> and C<exec>, to determine
+whether the current call to C<exec> should affect the current
+script or a subprocess (see L<perlvms/exec>). Somehow, this count
+has become scrambled, so Perl is making a guess and treating
+this C<exec> as a request to terminate the Perl script
+and execute the specified command.
+
+=item internal disaster in regexp
+
+(P) Something went badly wrong in the regular expression parser.
+
+=item internal error: glob failed
+
+(P) Something went wrong with the external program(s) used for C<glob>
+and C<E<lt>*.cE<gt>>. This may mean that your csh (C shell) is
+broken. If so, you should change all of the csh-related variables in
+config.sh: If you have tcsh, make the variables refer to it as if it
+were csh (e.g. C<full_csh='/usr/bin/tcsh'>); otherwise, make them all
+empty (except that C<d_csh> should be C<'undef'>) so that Perl will
+think csh is missing. In either case, after editing config.sh, run
+C<./Configure -S> and rebuild Perl.
+
+=item internal urp in regexp at /%s/
+
+(P) Something went badly awry in the regular expression parser.
+
+=item invalid [] range in regexp
+
+(F) The range specified in a character class had a minimum character
+greater than the maximum character. See L<perlre>.
+
+=item Invalid conversion in %s: "%s"
+
+(W) Perl does not understand the given format conversion.
+See L<perlfunc/sprintf>.
+
+=item Invalid type in pack: '%s'
+
+(F) The given character is not a valid pack type. See L<perlfunc/pack>.
+(W) The given character is not a valid pack type but used to be silently
+ignored.
+
+=item Invalid type in unpack: '%s'
+
+(F) The given character is not a valid unpack type. See L<perlfunc/unpack>.
+(W) The given character is not a valid unpack type but used to be silently
+ignored.
+
+=item ioctl is not implemented
+
+(F) Your machine apparently doesn't implement ioctl(), which is pretty
+strange for a machine that supports C.
+
+=item junk on end of regexp
+
+(P) The regular expression parser is confused.
+
+=item Label not found for "last %s"
+
+(F) You named a loop to break out of, but you're not currently in a
+loop of that name, not even if you count where you were called from.
+See L<perlfunc/last>.
+
+=item Label not found for "next %s"
+
+(F) You named a loop to continue, but you're not currently in a loop of
+that name, not even if you count where you were called from. See
+L<perlfunc/last>.
+
+=item Label not found for "redo %s"
+
+(F) You named a loop to restart, but you're not currently in a loop of
+that name, not even if you count where you were called from. See
+L<perlfunc/last>.
+
+=item listen() on closed fd
+
+(W) You tried to do a listen on a closed socket. Did you forget to check
+the return value of your socket() call? See L<perlfunc/listen>.
+
+=item Method for operation %s not found in package %s during blessing
+
+(F) An attempt was made to specify an entry in an overloading table that
+doesn't resolve to a valid subroutine. See L<overload>.
+
+=item Might be a runaway multi-line %s string starting on line %d
+
+(S) An advisory indicating that the previous error may have been caused
+by a missing delimiter on a string or pattern, because it eventually
+ended earlier on the current line.
+
+=item Misplaced _ in number
+
+(W) An underline in a decimal constant wasn't on a 3-digit boundary.
+
+=item Missing $ on loop variable
+
+(F) Apparently you've been programming in B<csh> too much. Variables are always
+mentioned with the $ in Perl, unlike in the shells, where it can vary from
+one line to the next.
+
+=item Missing comma after first argument to %s function
+
+(F) While certain functions allow you to specify a filehandle or an
+"indirect object" before the argument list, this ain't one of them.
+
+=item Missing operator before %s?
+
+(S) This is an educated guess made in conjunction with the message "%s
+found where operator expected". Often the missing operator is a comma.
+
+=item Missing right bracket
+
+(F) The lexer counted more opening curly brackets (braces) than closing ones.
+As a general rule, you'll find it's missing near the place you were last
+editing.
+
+=item Modification of a read-only value attempted
+
+(F) You tried, directly or indirectly, to change the value of a
+constant. You didn't, of course, try "2 = 1", because the compiler
+catches that. But an easy way to do the same thing is:
+
+ sub mod { $_[0] = 1 }
+ mod(2);
+
+Another way is to assign to a substr() that's off the end of the string.
+
+=item Modification of non-creatable array value attempted, subscript %d
+
+(F) You tried to make an array value spring into existence, and the
+subscript was probably negative, even counting from end of the array
+backwards.
+
+=item Modification of non-creatable hash value attempted, subscript "%s"
+
+(P) You tried to make a hash value spring into existence, and it couldn't
+be created for some peculiar reason.
+
+=item Module name must be constant
+
+(F) Only a bare module name is allowed as the first argument to a "use".
+
+=item msg%s not implemented
+
+(F) You don't have System V message IPC on your system.
+
+=item Multidimensional syntax %s not supported
+
+(W) Multidimensional arrays aren't written like C<$foo[1,2,3]>. They're written
+like C<$foo[1][2][3]>, as in C.
+
+=item Name "%s::%s" used only once: possible typo
+
+(W) Typographical errors often show up as unique variable names.
+If you had a good reason for having a unique name, then just mention
+it again somehow to suppress the message. The C<use vars> pragma is
+provided for just this purpose.
+
+=item Negative length
+
+(F) You tried to do a read/write/send/recv operation with a buffer length
+that is less than 0. This is difficult to imagine.
+
+=item nested *?+ in regexp
+
+(F) You can't quantify a quantifier without intervening parentheses. So
+things like ** or +* or ?* are illegal.
+
+Note, however, that the minimal matching quantifiers, C<*?>, C<+?>, and C<??> appear
+to be nested quantifiers, but aren't. See L<perlre>.
+
+=item No #! line
+
+(F) The setuid emulator requires that scripts have a well-formed #! line
+even on machines that don't support the #! construct.
+
+=item No %s allowed while running setuid
+
+(F) Certain operations are deemed to be too insecure for a setuid or setgid
+script to even be allowed to attempt. Generally speaking there will be
+another way to do what you want that is, if not secure, at least securable.
+See L<perlsec>.
+
+=item No B<-e> allowed in setuid scripts
+
+(F) A setuid script can't be specified by the user.
+
+=item No comma allowed after %s
+
+(F) A list operator that has a filehandle or "indirect object" is not
+allowed to have a comma between that and the following arguments.
+Otherwise it'd be just another one of the arguments.
+
+One possible cause for this is that you expected to have imported a
+constant to your name space with B<use> or B<import> while no such
+importing took place, it may for example be that your operating system
+does not support that particular constant. Hopefully you did use an
+explicit import list for the constants you expect to see, please see
+L<perlfunc/use> and L<perlfunc/import>. While an explicit import list
+would probably have caught this error earlier it naturally does not
+remedy the fact that your operating system still does not support that
+constant. Maybe you have a typo in the constants of the symbol import
+list of B<use> or B<import> or in the constant name at the line where
+this error was triggered?
+
+=item No command into which to pipe on command line
+
+(F) An error peculiar to VMS. Perl handles its own command line redirection,
+and found a '|' at the end of the command line, so it doesn't know where you
+want to pipe the output from this command.
+
+=item No DB::DB routine defined
+
+(F) The currently executing code was compiled with the B<-d> switch,
+but for some reason the perl5db.pl file (or some facsimile thereof)
+didn't define a routine to be called at the beginning of each
+statement. Which is odd, because the file should have been required
+automatically, and should have blown up the require if it didn't parse
+right.
+
+=item No dbm on this machine
+
+(P) This is counted as an internal error, because every machine should
+supply dbm nowadays, because Perl comes with SDBM. See L<SDBM_File>.
+
+=item No DBsub routine
+
+(F) The currently executing code was compiled with the B<-d> switch,
+but for some reason the perl5db.pl file (or some facsimile thereof)
+didn't define a DB::sub routine to be called at the beginning of each
+ordinary subroutine call.
+
+=item No error file after 2E<gt> or 2E<gt>E<gt> on command line
+
+(F) An error peculiar to VMS. Perl handles its own command line redirection,
+and found a '2E<gt>' or a '2E<gt>E<gt>' on the command line, but can't find
+the name of the file to which to write data destined for stderr.
+
+=item No input file after E<lt> on command line
+
+(F) An error peculiar to VMS. Perl handles its own command line redirection,
+and found a 'E<lt>' on the command line, but can't find the name of the file
+from which to read data for stdin.
+
+=item No output file after E<gt> on command line
+
+(F) An error peculiar to VMS. Perl handles its own command line redirection,
+and found a lone 'E<gt>' at the end of the command line, so it doesn't know
+where you wanted to redirect stdout.
+
+=item No output file after E<gt> or E<gt>E<gt> on command line
+
+(F) An error peculiar to VMS. Perl handles its own command line redirection,
+and found a 'E<gt>' or a 'E<gt>E<gt>' on the command line, but can't find the
+name of the file to which to write data destined for stdout.
+
+=item No Perl script found in input
+
+(F) You called C<perl -x>, but no line was found in the file beginning
+with #! and containing the word "perl".
+
+=item No setregid available
+
+(F) Configure didn't find anything resembling the setregid() call for
+your system.
+
+=item No setreuid available
+
+(F) Configure didn't find anything resembling the setreuid() call for
+your system.
+
+=item No space allowed after B<-I>
+
+(F) The argument to B<-I> must follow the B<-I> immediately with no
+intervening space.
+
+=item No such array field
+
+(F) You tried to access an array as a hash, but the field name used is
+not defined. The hash at index 0 should map all valid field names to
+array indices for that to work.
+
+=item No such field "%s" in variable %s of type %s
+
+(F) You tried to access a field of a typed variable where the type
+does not know about the field name. The field names are looked up in
+the %FIELDS hash in the type package at compile time. The %FIELDS hash
+is usually set up with the 'fields' pragma.
+
+=item No such pipe open
+
+(P) An error peculiar to VMS. The internal routine my_pclose() tried to
+close a pipe which hadn't been opened. This should have been caught earlier as
+an attempt to close an unopened filehandle.
+
+=item No such signal: SIG%s
+
+(W) You specified a signal name as a subscript to %SIG that was not recognized.
+Say C<kill -l> in your shell to see the valid signal names on your system.
+
+=item Not a CODE reference
+
+(F) Perl was trying to evaluate a reference to a code value (that is, a
+subroutine), but found a reference to something else instead. You can
+use the ref() function to find out what kind of ref it really was.
+See also L<perlref>.
+
+=item Not a format reference
+
+(F) I'm not sure how you managed to generate a reference to an anonymous
+format, but this indicates you did, and that it didn't exist.
+
+=item Not a GLOB reference
+
+(F) Perl was trying to evaluate a reference to a "typeglob" (that is,
+a symbol table entry that looks like C<*foo>), but found a reference to
+something else instead. You can use the ref() function to find out
+what kind of ref it really was. See L<perlref>.
+
+=item Not a HASH reference
+
+(F) Perl was trying to evaluate a reference to a hash value, but
+found a reference to something else instead. You can use the ref()
+function to find out what kind of ref it really was. See L<perlref>.
+
+=item Not a perl script
+
+(F) The setuid emulator requires that scripts have a well-formed #! line
+even on machines that don't support the #! construct. The line must
+mention perl.
+
+=item Not a SCALAR reference
+
+(F) Perl was trying to evaluate a reference to a scalar value, but
+found a reference to something else instead. You can use the ref()
+function to find out what kind of ref it really was. See L<perlref>.
+
+=item Not a subroutine reference
+
+(F) Perl was trying to evaluate a reference to a code value (that is, a
+subroutine), but found a reference to something else instead. You can
+use the ref() function to find out what kind of ref it really was.
+See also L<perlref>.
+
+=item Not a subroutine reference in overload table
+
+(F) An attempt was made to specify an entry in an overloading table that
+doesn't somehow point to a valid subroutine. See L<overload>.
+
+=item Not an ARRAY reference
+
+(F) Perl was trying to evaluate a reference to an array value, but
+found a reference to something else instead. You can use the ref()
+function to find out what kind of ref it really was. See L<perlref>.
+
+=item Not enough arguments for %s
+
+(F) The function requires more arguments than you specified.
+
+=item Not enough format arguments
+
+(W) A format specified more picture fields than the next line supplied.
+See L<perlform>.
+
+=item Null filename used
+
+(F) You can't require the null filename, especially because on many machines
+that means the current directory! See L<perlfunc/require>.
+
+=item Null picture in formline
+
+(F) The first argument to formline must be a valid format picture
+specification. It was found to be empty, which probably means you
+supplied it an uninitialized value. See L<perlform>.
+
+=item NULL OP IN RUN
+
+(P) Some internal routine called run() with a null opcode pointer.
+
+=item Null realloc
+
+(P) An attempt was made to realloc NULL.
+
+=item NULL regexp argument
+
+(P) The internal pattern matching routines blew it big time.
+
+=item NULL regexp parameter
+
+(P) The internal pattern matching routines are out of their gourd.
+
+=item Number too long
+
+(F) Perl limits the representation of decimal numbers in programs to about
+about 250 characters. You've exceeded that length. Future versions of
+Perl are likely to eliminate this arbitrary limitation. In the meantime,
+try using scientific notation (e.g. "1e6" instead of "1_000_000").
+
+=item Odd number of elements in hash assignment
+
+(S) You specified an odd number of elements to initialize a hash, which
+is odd, because hashes come in key/value pairs.
+
+=item Offset outside string
+
+(F) You tried to do a read/write/send/recv operation with an offset
+pointing outside the buffer. This is difficult to imagine.
+The sole exception to this is that C<sysread()>ing past the buffer
+will extend the buffer and zero pad the new area.
+
+=item oops: oopsAV
+
+(S) An internal warning that the grammar is screwed up.
+
+=item oops: oopsHV
+
+(S) An internal warning that the grammar is screwed up.
+
+=item Operation `%s': no method found, %s
+
+(F) An attempt was made to perform an overloaded operation for which
+no handler was defined. While some handlers can be autogenerated in
+terms of other handlers, there is no default handler for any
+operation, unless C<fallback> overloading key is specified to be
+true. See L<overload>.
+
+=item Operator or semicolon missing before %s
+
+(S) You used a variable or subroutine call where the parser was
+expecting an operator. The parser has assumed you really meant
+to use an operator, but this is highly likely to be incorrect.
+For example, if you say "*foo *foo" it will be interpreted as
+if you said "*foo * 'foo'".
+
+=item Out of memory for yacc stack
+
+(F) The yacc parser wanted to grow its stack so it could continue parsing,
+but realloc() wouldn't give it more memory, virtual or otherwise.
+
+=item Out of memory during request for %s
+
+(X|F) The malloc() function returned 0, indicating there was insufficient
+remaining memory (or virtual memory) to satisfy the request.
+
+The request was judged to be small, so the possibility to trap it
+depends on the way perl was compiled. By default it is not trappable.
+However, if compiled for this, Perl may use the contents of C<$^M> as
+an emergency pool after die()ing with this message. In this case the
+error is trappable I<once>.
+
+=item Out of memory during "large" request for %s
+
+(F) The malloc() function returned 0, indicating there was insufficient
+remaining memory (or virtual memory) to satisfy the request. However,
+the request was judged large enough (compile-time default is 64K), so
+a possibility to shut down by trapping this error is granted.
+
+=item Out of memory during ridiculously large request
+
+(F) You can't allocate more than 2^31+"small amount" bytes. This error
+is most likely to be caused by a typo in the Perl program. e.g., C<$arr[time]>
+instead of C<$arr[$time]>.
+
+=item page overflow
+
+(W) A single call to write() produced more lines than can fit on a page.
+See L<perlform>.
+
+=item panic: ck_grep
+
+(P) Failed an internal consistency check trying to compile a grep.
+
+=item panic: ck_split
+
+(P) Failed an internal consistency check trying to compile a split.
+
+=item panic: corrupt saved stack index
+
+(P) The savestack was requested to restore more localized values than there
+are in the savestack.
+
+=item panic: die %s
+
+(P) We popped the context stack to an eval context, and then discovered
+it wasn't an eval context.
+
+=item panic: do_match
+
+(P) The internal pp_match() routine was called with invalid operational data.
+
+=item panic: do_split
+
+(P) Something terrible went wrong in setting up for the split.
+
+=item panic: do_subst
+
+(P) The internal pp_subst() routine was called with invalid operational data.
+
+=item panic: do_trans
+
+(P) The internal do_trans() routine was called with invalid operational data.
+
+=item panic: frexp
+
+(P) The library function frexp() failed, making printf("%f") impossible.
+
+=item panic: goto
+
+(P) We popped the context stack to a context with the specified label,
+and then discovered it wasn't a context we know how to do a goto in.
+
+=item panic: INTERPCASEMOD
+
+(P) The lexer got into a bad state at a case modifier.
+
+=item panic: INTERPCONCAT
+
+(P) The lexer got into a bad state parsing a string with brackets.
+
+=item panic: last
+
+(P) We popped the context stack to a block context, and then discovered
+it wasn't a block context.
+
+=item panic: leave_scope clearsv
+
+(P) A writable lexical variable became read-only somehow within the scope.
+
+=item panic: leave_scope inconsistency
+
+(P) The savestack probably got out of sync. At least, there was an
+invalid enum on the top of it.
+
+=item panic: malloc
+
+(P) Something requested a negative number of bytes of malloc.
+
+=item panic: mapstart
+
+(P) The compiler is screwed up with respect to the map() function.
+
+=item panic: null array
+
+(P) One of the internal array routines was passed a null AV pointer.
+
+=item panic: pad_alloc
+
+(P) The compiler got confused about which scratch pad it was allocating
+and freeing temporaries and lexicals from.
+
+=item panic: pad_free curpad
+
+(P) The compiler got confused about which scratch pad it was allocating
+and freeing temporaries and lexicals from.
+
+=item panic: pad_free po
+
+(P) An invalid scratch pad offset was detected internally.
+
+=item panic: pad_reset curpad
+
+(P) The compiler got confused about which scratch pad it was allocating
+and freeing temporaries and lexicals from.
+
+=item panic: pad_sv po
+
+(P) An invalid scratch pad offset was detected internally.
+
+=item panic: pad_swipe curpad
+
+(P) The compiler got confused about which scratch pad it was allocating
+and freeing temporaries and lexicals from.
+
+=item panic: pad_swipe po
+
+(P) An invalid scratch pad offset was detected internally.
+
+=item panic: pp_iter
+
+(P) The foreach iterator got called in a non-loop context frame.
+
+=item panic: realloc
+
+(P) Something requested a negative number of bytes of realloc.
+
+=item panic: restartop
+
+(P) Some internal routine requested a goto (or something like it), and
+didn't supply the destination.
+
+=item panic: return
+
+(P) We popped the context stack to a subroutine or eval context, and
+then discovered it wasn't a subroutine or eval context.
+
+=item panic: scan_num
+
+(P) scan_num() got called on something that wasn't a number.
+
+=item panic: sv_insert
+
+(P) The sv_insert() routine was told to remove more string than there
+was string.
+
+=item panic: top_env
+
+(P) The compiler attempted to do a goto, or something weird like that.
+
+=item panic: yylex
+
+(P) The lexer got into a bad state while processing a case modifier.
+
+=item Parentheses missing around "%s" list
+
+(W) You said something like
+
+ my $foo, $bar = @_;
+
+when you meant
+
+ my ($foo, $bar) = @_;
+
+Remember that "my" and "local" bind closer than comma.
+
+=item Perl %3.3f required--this is only version %s, stopped
+
+(F) The module in question uses features of a version of Perl more recent
+than the currently running version. How long has it been since you upgraded,
+anyway? See L<perlfunc/require>.
+
+=item Permission denied
+
+(F) The setuid emulator in suidperl decided you were up to no good.
+
+=item pid %d not a child
+
+(W) A warning peculiar to VMS. Waitpid() was asked to wait for a process which
+isn't a subprocess of the current process. While this is fine from VMS'
+perspective, it's probably not what you intended.
+
+=item POSIX getpgrp can't take an argument
+
+(F) Your C compiler uses POSIX getpgrp(), which takes no argument, unlike
+the BSD version, which takes a pid.
+
+=item Possible attempt to put comments in qw() list
+
+(W) qw() lists contain items separated by whitespace; as with literal
+strings, comment characters are not ignored, but are instead treated
+as literal data. (You may have used different delimiters than the
+parentheses shown here; braces are also frequently used.)
+
+You probably wrote something like this:
+
+ @list = qw(
+ a # a comment
+ b # another comment
+ );
+
+when you should have written this:
+
+ @list = qw(
+ a
+ b
+ );
+
+If you really want comments, build your list the
+old-fashioned way, with quotes and commas:
+
+ @list = (
+ 'a', # a comment
+ 'b', # another comment
+ );
+
+=item Possible attempt to separate words with commas
+
+(W) qw() lists contain items separated by whitespace; therefore commas
+aren't needed to separate the items. (You may have used different
+delimiters than the parentheses shown here; braces are also frequently
+used.)
+
+You probably wrote something like this:
+
+ qw! a, b, c !;
+
+which puts literal commas into some of the list items. Write it without
+commas if you don't want them to appear in your data:
+
+ qw! a b c !;
+
+=item Possible memory corruption: %s overflowed 3rd argument
+
+(F) An ioctl() or fcntl() returned more than Perl was bargaining for.
+Perl guesses a reasonable buffer size, but puts a sentinel byte at the
+end of the buffer just in case. This sentinel byte got clobbered, and
+Perl assumes that memory is now corrupted. See L<perlfunc/ioctl>.
+
+=item Precedence problem: open %s should be open(%s)
+
+(S) The old irregular construct
+
+ open FOO || die;
+
+is now misinterpreted as
+
+ open(FOO || die);
+
+because of the strict regularization of Perl 5's grammar into unary
+and list operators. (The old open was a little of both.) You must
+put parentheses around the filehandle, or use the new "or" operator
+instead of "||".
+
+=item print on closed filehandle %s
+
+(W) The filehandle you're printing on got itself closed sometime before now.
+Check your logic flow.
+
+=item printf on closed filehandle %s
+
+(W) The filehandle you're writing to got itself closed sometime before now.
+Check your logic flow.
+
+=item Probable precedence problem on %s
+
+(W) The compiler found a bareword where it expected a conditional,
+which often indicates that an || or && was parsed as part of the
+last argument of the previous construct, for example:
+
+ open FOO || die;
+
+=item Prototype mismatch: %s vs %s
+
+(S) The subroutine being declared or defined had previously been declared
+or defined with a different function prototype.
+
+=item Range iterator outside integer range
+
+(F) One (or both) of the numeric arguments to the range operator ".."
+are outside the range which can be represented by integers internally.
+One possible workaround is to force Perl to use magical string
+increment by prepending "0" to your numbers.
+
+=item Read on closed filehandle E<lt>%sE<gt>
+
+(W) The filehandle you're reading from got itself closed sometime before now.
+Check your logic flow.
+
+=item Reallocation too large: %lx
+
+(F) You can't allocate more than 64K on an MS-DOS machine.
+
+=item Recompile perl with B<-D>DEBUGGING to use B<-D> switch
+
+(F) You can't use the B<-D> option unless the code to produce the
+desired output is compiled into Perl, which entails some overhead,
+which is why it's currently left out of your copy.
+
+=item Recursive inheritance detected in package '%s'
+
+(F) More than 100 levels of inheritance were used. Probably indicates
+an unintended loop in your inheritance hierarchy.
+
+=item Recursive inheritance detected while looking for method '%s' in package '%s'
+
+(F) More than 100 levels of inheritance were encountered while invoking a
+method. Probably indicates an unintended loop in your inheritance hierarchy.
+
+=item Reference found where even-sized list expected
+
+(W) You gave a single reference where Perl was expecting a list with
+an even number of elements (for assignment to a hash). This
+usually means that you used the anon hash constructor when you meant
+to use parens. In any case, a hash requires key/value B<pairs>.
+
+ %hash = { one => 1, two => 2, }; # WRONG
+ %hash = [ qw/ an anon array / ]; # WRONG
+ %hash = ( one => 1, two => 2, ); # right
+ %hash = qw( one 1 two 2 ); # also fine
+
+=item Reference miscount in sv_replace()
+
+(W) The internal sv_replace() function was handed a new SV with a
+reference count of other than 1.
+
+=item regexp *+ operand could be empty
+
+(F) The part of the regexp subject to either the * or + quantifier
+could match an empty string.
+
+=item regexp memory corruption
+
+(P) The regular expression engine got confused by what the regular
+expression compiler gave it.
+
+=item regexp out of space
+
+(P) A "can't happen" error, because safemalloc() should have caught it earlier.
+
+=item regexp too big
+
+(F) The current implementation of regular expressions uses shorts as
+address offsets within a string. Unfortunately this means that if
+the regular expression compiles to longer than 32767, it'll blow up.
+Usually when you want a regular expression this big, there is a better
+way to do it with multiple statements. See L<perlre>.
+
+=item Reversed %s= operator
+
+(W) You wrote your assignment operator backwards. The = must always
+comes last, to avoid ambiguity with subsequent unary operators.
+
+=item Runaway format
+
+(F) Your format contained the ~~ repeat-until-blank sequence, but it
+produced 200 lines at once, and the 200th line looked exactly like the
+199th line. Apparently you didn't arrange for the arguments to exhaust
+themselves, either by using ^ instead of @ (for scalar variables), or by
+shifting or popping (for array variables). See L<perlform>.
+
+=item Scalar value @%s[%s] better written as $%s[%s]
+
+(W) You've used an array slice (indicated by @) to select a single element of
+an array. Generally it's better to ask for a scalar value (indicated by $).
+The difference is that C<$foo[&bar]> always behaves like a scalar, both when
+assigning to it and when evaluating its argument, while C<@foo[&bar]> behaves
+like a list when you assign to it, and provides a list context to its
+subscript, which can do weird things if you're expecting only one subscript.
+
+On the other hand, if you were actually hoping to treat the array
+element as a list, you need to look into how references work, because
+Perl will not magically convert between scalars and lists for you. See
+L<perlref>.
+
+=item Scalar value @%s{%s} better written as $%s{%s}
+
+(W) You've used a hash slice (indicated by @) to select a single element of
+a hash. Generally it's better to ask for a scalar value (indicated by $).
+The difference is that C<$foo{&bar}> always behaves like a scalar, both when
+assigning to it and when evaluating its argument, while C<@foo{&bar}> behaves
+like a list when you assign to it, and provides a list context to its
+subscript, which can do weird things if you're expecting only one subscript.
+
+On the other hand, if you were actually hoping to treat the hash
+element as a list, you need to look into how references work, because
+Perl will not magically convert between scalars and lists for you. See
+L<perlref>.
+
+=item Script is not setuid/setgid in suidperl
+
+(F) Oddly, the suidperl program was invoked on a script without a setuid
+or setgid bit set. This doesn't make much sense.
+
+=item Search pattern not terminated
+
+(F) The lexer couldn't find the final delimiter of a // or m{}
+construct. Remember that bracketing delimiters count nesting level.
+Missing the leading C<$> from a variable C<$m> may cause this error.
+
+=item %sseek() on unopened file
+
+(W) You tried to use the seek() or sysseek() function on a filehandle that
+was either never opened or has since been closed.
+
+=item select not implemented
+
+(F) This machine doesn't implement the select() system call.
+
+=item sem%s not implemented
+
+(F) You don't have System V semaphore IPC on your system.
+
+=item semi-panic: attempt to dup freed string
+
+(S) The internal newSVsv() routine was called to duplicate a scalar
+that had previously been marked as free.
+
+=item Semicolon seems to be missing
+
+(W) A nearby syntax error was probably caused by a missing semicolon,
+or possibly some other missing operator, such as a comma.
+
+=item Send on closed socket
+
+(W) The filehandle you're sending to got itself closed sometime before now.
+Check your logic flow.
+
+=item Sequence (? incomplete
+
+(F) A regular expression ended with an incomplete extension (?.
+See L<perlre>.
+
+=item Sequence (?#... not terminated
+
+(F) A regular expression comment must be terminated by a closing
+parenthesis. Embedded parentheses aren't allowed. See L<perlre>.
+
+=item Sequence (?%s...) not implemented
+
+(F) A proposed regular expression extension has the character reserved
+but has not yet been written. See L<perlre>.
+
+=item Sequence (?%s...) not recognized
+
+(F) You used a regular expression extension that doesn't make sense.
+See L<perlre>.
+
+=item Server error
+
+Also known as "500 Server error".
+
+B<This is a CGI error, not a Perl error>.
+
+You need to make sure your script is executable, is accessible by the user
+CGI is running the script under (which is probably not the user account you
+tested it under), does not rely on any environment variables (like PATH)
+from the user it isn't running under, and isn't in a location where the CGI
+server can't find it, basically, more or less. Please see the following
+for more information:
+
+ http://www.perl.com/perl/faq/idiots-guide.html
+ http://www.perl.com/perl/faq/perl-cgi-faq.html
+ ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
+ http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
+ http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
+
+=item setegid() not implemented
+
+(F) You tried to assign to C<$)>, and your operating system doesn't support
+the setegid() system call (or equivalent), or at least Configure didn't
+think so.
+
+=item seteuid() not implemented
+
+(F) You tried to assign to C<$E<gt>>, and your operating system doesn't support
+the seteuid() system call (or equivalent), or at least Configure didn't
+think so.
+
+=item setrgid() not implemented
+
+(F) You tried to assign to C<$(>, and your operating system doesn't support
+the setrgid() system call (or equivalent), or at least Configure didn't
+think so.
+
+=item setruid() not implemented
+
+(F) You tried to assign to C<$E<lt>>, and your operating system doesn't support
+the setruid() system call (or equivalent), or at least Configure didn't
+think so.
+
+=item Setuid/gid script is writable by world
+
+(F) The setuid emulator won't run a script that is writable by the world,
+because the world might have written on it already.
+
+=item shm%s not implemented
+
+(F) You don't have System V shared memory IPC on your system.
+
+=item shutdown() on closed fd
+
+(W) You tried to do a shutdown on a closed socket. Seems a bit superfluous.
+
+=item SIG%s handler "%s" not defined
+
+(W) The signal handler named in %SIG doesn't, in fact, exist. Perhaps you
+put it into the wrong package?
+
+=item sort is now a reserved word
+
+(F) An ancient error message that almost nobody ever runs into anymore.
+But before sort was a keyword, people sometimes used it as a filehandle.
+
+=item Sort subroutine didn't return a numeric value
+
+(F) A sort comparison routine must return a number. You probably blew
+it by not using C<E<lt>=E<gt>> or C<cmp>, or by not using them correctly.
+See L<perlfunc/sort>.
+
+=item Sort subroutine didn't return single value
+
+(F) A sort comparison subroutine may not return a list value with more
+or less than one element. See L<perlfunc/sort>.
+
+=item Split loop
+
+(P) The split was looping infinitely. (Obviously, a split shouldn't iterate
+more times than there are characters of input, which is what happened.)
+See L<perlfunc/split>.
+
+=item Stat on unopened file E<lt>%sE<gt>
+
+(W) You tried to use the stat() function (or an equivalent file test)
+on a filehandle that was either never opened or has since been closed.
+
+=item Statement unlikely to be reached
+
+(W) You did an exec() with some statement after it other than a die().
+This is almost always an error, because exec() never returns unless
+there was a failure. You probably wanted to use system() instead,
+which does return. To suppress this warning, put the exec() in a block
+by itself.
+
+=item Stub found while resolving method `%s' overloading `%s' in package `%s'
+
+(P) Overloading resolution over @ISA tree may be broken by importation stubs.
+Stubs should never be implicitely created, but explicit calls to C<can>
+may break this.
+
+=item Subroutine %s redefined
+
+(W) You redefined a subroutine. To suppress this warning, say
+
+ {
+ local $^W = 0;
+ eval "sub name { ... }";
+ }
+
+=item Substitution loop
+
+(P) The substitution was looping infinitely. (Obviously, a
+substitution shouldn't iterate more times than there are characters of
+input, which is what happened.) See the discussion of substitution in
+L<perlop/"Quote and Quote-like Operators">.
+
+=item Substitution pattern not terminated
+
+(F) The lexer couldn't find the interior delimiter of a s/// or s{}{}
+construct. Remember that bracketing delimiters count nesting level.
+Missing the leading C<$> from variable C<$s> may cause this error.
+
+=item Substitution replacement not terminated
+
+(F) The lexer couldn't find the final delimiter of a s/// or s{}{}
+construct. Remember that bracketing delimiters count nesting level.
+Missing the leading C<$> from variable C<$s> may cause this error.
+
+=item substr outside of string
+
+(S),(W) You tried to reference a substr() that pointed outside of a
+string. That is, the absolute value of the offset was larger than the
+length of the string. See L<perlfunc/substr>. This warning is
+mandatory if substr is used in an lvalue context (as the left hand side
+of an assignment or as a subroutine argument for example).
+
+=item suidperl is no longer needed since %s
+
+(F) Your Perl was compiled with B<-D>SETUID_SCRIPTS_ARE_SECURE_NOW, but a
+version of the setuid emulator somehow got run anyway.
+
+=item syntax error
+
+(F) Probably means you had a syntax error. Common reasons include:
+
+ A keyword is misspelled.
+ A semicolon is missing.
+ A comma is missing.
+ An opening or closing parenthesis is missing.
+ An opening or closing brace is missing.
+ A closing quote is missing.
+
+Often there will be another error message associated with the syntax
+error giving more information. (Sometimes it helps to turn on B<-w>.)
+The error message itself often tells you where it was in the line when
+it decided to give up. Sometimes the actual error is several tokens
+before this, because Perl is good at understanding random input.
+Occasionally the line number may be misleading, and once in a blue moon
+the only way to figure out what's triggering the error is to call
+C<perl -c> repeatedly, chopping away half the program each time to see
+if the error went away. Sort of the cybernetic version of S<20 questions>.
+
+=item syntax error at line %d: `%s' unexpected
+
+(A) You've accidentally run your script through the Bourne shell
+instead of Perl. Check the #! line, or manually feed your script
+into Perl yourself.
+
+=item System V %s is not implemented on this machine
+
+(F) You tried to do something with a function beginning with "sem",
+"shm", or "msg" but that System V IPC is not implemented in your
+machine. In some machines the functionality can exist but be
+unconfigured. Consult your system support.
+
+=item Syswrite on closed filehandle
+
+(W) The filehandle you're writing to got itself closed sometime before now.
+Check your logic flow.
+
+=item Target of goto is too deeply nested
+
+(F) You tried to use C<goto> to reach a label that was too deeply
+nested for Perl to reach. Perl is doing you a favor by refusing.
+
+=item tell() on unopened file
+
+(W) You tried to use the tell() function on a filehandle that was either
+never opened or has since been closed.
+
+=item Test on unopened file E<lt>%sE<gt>
+
+(W) You tried to invoke a file test operator on a filehandle that isn't
+open. Check your logic. See also L<perlfunc/-X>.
+
+=item That use of $[ is unsupported
+
+(F) Assignment to C<$[> is now strictly circumscribed, and interpreted as
+a compiler directive. You may say only one of
+
+ $[ = 0;
+ $[ = 1;
+ ...
+ local $[ = 0;
+ local $[ = 1;
+ ...
+
+This is to prevent the problem of one module changing the array base
+out from under another module inadvertently. See L<perlvar/$[>.
+
+=item The %s function is unimplemented
+
+The function indicated isn't implemented on this architecture, according
+to the probings of Configure.
+
+=item The crypt() function is unimplemented due to excessive paranoia
+
+(F) Configure couldn't find the crypt() function on your machine,
+probably because your vendor didn't supply it, probably because they
+think the U.S. Government thinks it's a secret, or at least that they
+will continue to pretend that it is. And if you quote me on that, I
+will deny it.
+
+=item The stat preceding C<-l _> wasn't an lstat
+
+(F) It makes no sense to test the current stat buffer for symbolic linkhood
+if the last stat that wrote to the stat buffer already went past
+the symlink to get to the real file. Use an actual filename instead.
+
+=item times not implemented
+
+(F) Your version of the C library apparently doesn't do times(). I suspect
+you're not running on Unix.
+
+=item Too few args to syscall
+
+(F) There has to be at least one argument to syscall() to specify the
+system call to call, silly dilly.
+
+=item Too late for "B<-T>" option
+
+(X) The #! line (or local equivalent) in a Perl script contains the
+B<-T> option, but Perl was not invoked with B<-T> in its command line.
+This is an error because, by the time Perl discovers a B<-T> in a
+script, it's too late to properly taint everything from the environment.
+So Perl gives up.
+
+If the Perl script is being executed as a command using the #!
+mechanism (or its local equivalent), this error can usually be fixed
+by editing the #! line so that the B<-T> option is a part of Perl's
+first argument: e.g. change C<perl -n -T> to C<perl -T -n>.
+
+If the Perl script is being executed as C<perl scriptname>, then the
+B<-T> option must appear on the command line: C<perl -T scriptname>.
+
+=item Too late for "-%s" option
+
+(X) The #! line (or local equivalent) in a Perl script contains the
+B<-M> or B<-m> option. This is an error because B<-M> and B<-m> options
+are not intended for use inside scripts. Use the C<use> pragma instead.
+
+=item Too many ('s
+
+=item Too many )'s
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item Too many args to syscall
+
+(F) Perl supports a maximum of only 14 args to syscall().
+
+=item Too many arguments for %s
+
+(F) The function requires fewer arguments than you specified.
+
+=item trailing \ in regexp
+
+(F) The regular expression ends with an unbackslashed backslash. Backslash
+it. See L<perlre>.
+
+=item Transliteration pattern not terminated
+
+(F) The lexer couldn't find the interior delimiter of a tr/// or tr[][]
+or y/// or y[][] construct. Missing the leading C<$> from variables
+C<$tr> or C<$y> may cause this error.
+
+=item Transliteration replacement not terminated
+
+(F) The lexer couldn't find the final delimiter of a tr/// or tr[][]
+construct.
+
+=item truncate not implemented
+
+(F) Your machine doesn't implement a file truncation mechanism that
+Configure knows about.
+
+=item Type of arg %d to %s must be %s (not %s)
+
+(F) This function requires the argument in that position to be of a
+certain type. Arrays must be @NAME or C<@{EXPR}>. Hashes must be
+%NAME or C<%{EXPR}>. No implicit dereferencing is allowed--use the
+{EXPR} forms as an explicit dereference. See L<perlref>.
+
+=item umask: argument is missing initial 0
+
+(W) A umask of 222 is incorrect. It should be 0222, because octal
+literals always start with 0 in Perl, as in C.
+
+=item umask not implemented
+
+(F) Your machine doesn't implement the umask function and you tried
+to use it to restrict permissions for yourself (EXPR & 0700).
+
+=item Unable to create sub named "%s"
+
+(F) You attempted to create or access a subroutine with an illegal name.
+
+=item Unbalanced context: %d more PUSHes than POPs
+
+(W) The exit code detected an internal inconsistency in how many execution
+contexts were entered and left.
+
+=item Unbalanced saves: %d more saves than restores
+
+(W) The exit code detected an internal inconsistency in how many
+values were temporarily localized.
+
+=item Unbalanced scopes: %d more ENTERs than LEAVEs
+
+(W) The exit code detected an internal inconsistency in how many blocks
+were entered and left.
+
+=item Unbalanced tmps: %d more allocs than frees
+
+(W) The exit code detected an internal inconsistency in how many mortal
+scalars were allocated and freed.
+
+=item Undefined format "%s" called
+
+(F) The format indicated doesn't seem to exist. Perhaps it's really in
+another package? See L<perlform>.
+
+=item Undefined sort subroutine "%s" called
+
+(F) The sort comparison routine specified doesn't seem to exist. Perhaps
+it's in a different package? See L<perlfunc/sort>.
+
+=item Undefined subroutine &%s called
+
+(F) The subroutine indicated hasn't been defined, or if it was, it
+has since been undefined.
+
+=item Undefined subroutine called
+
+(F) The anonymous subroutine you're trying to call hasn't been defined,
+or if it was, it has since been undefined.
+
+=item Undefined subroutine in sort
+
+(F) The sort comparison routine specified is declared but doesn't seem to
+have been defined yet. See L<perlfunc/sort>.
+
+=item Undefined top format "%s" called
+
+(F) The format indicated doesn't seem to exist. Perhaps it's really in
+another package? See L<perlform>.
+
+=item Undefined value assigned to typeglob
+
+(W) An undefined value was assigned to a typeglob, a la C<*foo = undef>.
+This does nothing. It's possible that you really mean C<undef *foo>.
+
+=item unexec of %s into %s failed!
+
+(F) The unexec() routine failed for some reason. See your local FSF
+representative, who probably put it there in the first place.
+
+=item Unknown BYTEORDER
+
+(F) There are no byte-swapping functions for a machine with this byte order.
+
+=item unmatched () in regexp
+
+(F) Unbackslashed parentheses must always be balanced in regular
+expressions. If you're a vi user, the % key is valuable for finding
+the matching parenthesis. See L<perlre>.
+
+=item Unmatched right bracket
+
+(F) The lexer counted more closing curly brackets (braces) than opening
+ones, so you're probably missing an opening bracket. As a general
+rule, you'll find the missing one (so to speak) near the place you were
+last editing.
+
+=item unmatched [] in regexp
+
+(F) The brackets around a character class must match. If you wish to
+include a closing bracket in a character class, backslash it or put it first.
+See L<perlre>.
+
+=item Unquoted string "%s" may clash with future reserved word
+
+(W) You used a bareword that might someday be claimed as a reserved word.
+It's best to put such a word in quotes, or capitalize it somehow, or insert
+an underbar into it. You might also declare it as a subroutine.
+
+=item Unrecognized character %s
+
+(F) The Perl parser has no idea what to do with the specified character
+in your Perl script (or eval). Perhaps you tried to run a compressed
+script, a binary program, or a directory as a Perl program.
+
+=item Unrecognized signal name "%s"
+
+(F) You specified a signal name to the kill() function that was not recognized.
+Say C<kill -l> in your shell to see the valid signal names on your system.
+
+=item Unrecognized switch: -%s (-h will show valid options)
+
+(F) You specified an illegal option to Perl. Don't do that.
+(If you think you didn't do that, check the #! line to see if it's
+supplying the bad switch on your behalf.)
+
+=item Unsuccessful %s on filename containing newline
+
+(W) A file operation was attempted on a filename, and that operation
+failed, PROBABLY because the filename contained a newline, PROBABLY
+because you forgot to chop() or chomp() it off. See L<perlfunc/chomp>.
+
+=item Unsupported directory function "%s" called
+
+(F) Your machine doesn't support opendir() and readdir().
+
+=item Unsupported function fork
+
+(F) Your version of executable does not support forking.
+
+Note that under some systems, like OS/2, there may be different flavors of
+Perl executables, some of which may support fork, some not. Try changing
+the name you call Perl by to C<perl_>, C<perl__>, and so on.
+
+=item Unsupported function %s
+
+(F) This machine doesn't implement the indicated function, apparently.
+At least, Configure doesn't think so.
+
+=item Unsupported socket function "%s" called
+
+(F) Your machine doesn't support the Berkeley socket mechanism, or at
+least that's what Configure thought.
+
+=item Unterminated E<lt>E<gt> operator
+
+(F) The lexer saw a left angle bracket in a place where it was expecting
+a term, so it's looking for the corresponding right angle bracket, and not
+finding it. Chances are you left some needed parentheses out earlier in
+the line, and you really meant a "less than".
+
+=item Use of "$$<digit>" to mean "${$}<digit>" is deprecated
+
+(D) Perl versions before 5.004 misinterpreted any type marker followed
+by "$" and a digit. For example, "$$0" was incorrectly taken to mean
+"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004.
+
+However, the developers of Perl 5.004 could not fix this bug completely,
+because at least two widely-used modules depend on the old meaning of
+"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the
+old (broken) way inside strings; but it generates this message as a
+warning. And in Perl 5.005, this special treatment will cease.
+
+=item Use of $# is deprecated
+
+(D) This was an ill-advised attempt to emulate a poorly defined B<awk> feature.
+Use an explicit printf() or sprintf() instead.
+
+=item Use of $* is deprecated
+
+(D) This variable magically turned on multi-line pattern matching, both for
+you and for any luckless subroutine that you happen to call. You should
+use the new C<//m> and C<//s> modifiers now to do that without the dangerous
+action-at-a-distance effects of C<$*>.
+
+=item Use of %s in printf format not supported
+
+(F) You attempted to use a feature of printf that is accessible from
+only C. This usually means there's a better way to do it in Perl.
+
+=item Use of bare E<lt>E<lt> to mean E<lt>E<lt>"" is deprecated
+
+(D) You are now encouraged to use the explicitly quoted form if you
+wish to use an empty line as the terminator of the here-document.
+
+=item Use of implicit split to @_ is deprecated
+
+(D) It makes a lot of work for the compiler when you clobber a
+subroutine's argument list, so it's better if you assign the results of
+a split() explicitly to an array (or list).
+
+=item Use of inherited AUTOLOAD for non-method %s() is deprecated
+
+(D) As an (ahem) accidental feature, C<AUTOLOAD> subroutines are looked
+up as methods (using the C<@ISA> hierarchy) even when the subroutines to
+be autoloaded were called as plain functions (e.g. C<Foo::bar()>), not
+as methods (e.g. C<Foo-E<gt>bar()> or C<$obj-E<gt>bar()>).
+
+This bug will be rectified in Perl 5.005, which will use method lookup
+only for methods' C<AUTOLOAD>s. However, there is a significant base
+of existing code that may be using the old behavior. So, as an
+interim step, Perl 5.004 issues an optional warning when non-methods
+use inherited C<AUTOLOAD>s.
+
+The simple rule is: Inheritance will not work when autoloading
+non-methods. The simple fix for old code is: In any module that used to
+depend on inheriting C<AUTOLOAD> for non-methods from a base class named
+C<BaseClass>, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup.
+
+In code that currently says C<use AutoLoader; @ISA = qw(AutoLoader);> you
+should remove AutoLoader from @ISA and change C<use AutoLoader;> to
+C<use AutoLoader 'AUTOLOAD';>.
+
+=item Use of reserved word "%s" is deprecated
+
+(D) The indicated bareword is a reserved word. Future versions of perl
+may use it as a keyword, so you're better off either explicitly quoting
+the word in a manner appropriate for its context of use, or using a
+different name altogether. The warning can be suppressed for subroutine
+names by either adding a C<&> prefix, or using a package qualifier,
+e.g. C<&our()>, or C<Foo::our()>.
+
+=item Use of %s is deprecated
+
+(D) The construct indicated is no longer recommended for use, generally
+because there's a better way to do it, and also because the old way has
+bad side effects.
+
+=item Use of uninitialized value
+
+(W) An undefined value was used as if it were already defined. It was
+interpreted as a "" or a 0, but maybe it was a mistake. To suppress this
+warning assign an initial value to your variables.
+
+=item Useless use of "re" pragma
+
+(W) You did C<use re;> without any arguments. That isn't very useful.
+
+=item Useless use of %s in void context
+
+(W) You did something without a side effect in a context that does nothing
+with the return value, such as a statement that doesn't return a value
+from a block, or the left side of a scalar comma operator. Very often
+this points not to stupidity on your part, but a failure of Perl to parse
+your program the way you thought it would. For example, you'd get this
+if you mixed up your C precedence with Python precedence and said
+
+ $one, $two = 1, 2;
+
+when you meant to say
+
+ ($one, $two) = (1, 2);
+
+Another common error is to use ordinary parentheses to construct a list
+reference when you should be using square or curly brackets, for
+example, if you say
+
+ $array = (1,2);
+
+when you should have said
+
+ $array = [1,2];
+
+The square brackets explicitly turn a list value into a scalar value,
+while parentheses do not. So when a parenthesized list is evaluated in
+a scalar context, the comma is treated like C's comma operator, which
+throws away the left argument, which is not what you want. See
+L<perlref> for more on this.
+
+=item untie attempted while %d inner references still exist
+
+(W) A copy of the object returned from C<tie> (or C<tied>) was still
+valid when C<untie> was called.
+
+=item Value of %s can be "0"; test with defined()
+
+(W) In a conditional expression, you used <HANDLE>, <*> (glob), C<each()>,
+or C<readdir()> as a boolean value. Each of these constructs can return a
+value of "0"; that would make the conditional expression false, which is
+probably not what you intended. When using these constructs in conditional
+expressions, test their values with the C<defined> operator.
+
+=item Variable "%s" is not imported%s
+
+(F) While "use strict" in effect, you referred to a global variable
+that you apparently thought was imported from another module, because
+something else of the same name (usually a subroutine) is exported
+by that module. It usually means you put the wrong funny character
+on the front of your variable.
+
+=item Variable "%s" may be unavailable
+
+(W) An inner (nested) I<anonymous> subroutine is inside a I<named>
+subroutine, and outside that is another subroutine; and the anonymous
+(innermost) subroutine is referencing a lexical variable defined in
+the outermost subroutine. For example:
+
+ sub outermost { my $a; sub middle { sub { $a } } }
+
+If the anonymous subroutine is called or referenced (directly or
+indirectly) from the outermost subroutine, it will share the variable
+as you would expect. But if the anonymous subroutine is called or
+referenced when the outermost subroutine is not active, it will see
+the value of the shared variable as it was before and during the
+*first* call to the outermost subroutine, which is probably not what
+you want.
+
+In these circumstances, it is usually best to make the middle
+subroutine anonymous, using the C<sub {}> syntax. Perl has specific
+support for shared variables in nested anonymous subroutines; a named
+subroutine in between interferes with this feature.
+
+=item Variable "%s" will not stay shared
+
+(W) An inner (nested) I<named> subroutine is referencing a lexical
+variable defined in an outer subroutine.
+
+When the inner subroutine is called, it will probably see the value of
+the outer subroutine's variable as it was before and during the
+*first* call to the outer subroutine; in this case, after the first
+call to the outer subroutine is complete, the inner and outer
+subroutines will no longer share a common value for the variable. In
+other words, the variable will no longer be shared.
+
+Furthermore, if the outer subroutine is anonymous and references a
+lexical variable outside itself, then the outer and inner subroutines
+will I<never> share the given variable.
+
+This problem can usually be solved by making the inner subroutine
+anonymous, using the C<sub {}> syntax. When inner anonymous subs that
+reference variables in outer subroutines are called or referenced,
+they are automatically rebound to the current values of such
+variables.
+
+=item Variable syntax
+
+(A) You've accidentally run your script through B<csh> instead
+of Perl. Check the #! line, or manually feed your script into
+Perl yourself.
+
+=item perl: warning: Setting locale failed.
+
+(S) The whole warning message will look something like:
+
+ perl: warning: Setting locale failed.
+ perl: warning: Please check that your locale settings:
+ LC_ALL = "En_US",
+ LANG = (unset)
+ are supported and installed on your system.
+ perl: warning: Falling back to the standard locale ("C").
+
+Exactly what were the failed locale settings varies. In the above the
+settings were that the LC_ALL was "En_US" and the LANG had no value.
+This error means that Perl detected that you and/or your system
+administrator have set up the so-called variable system but Perl could
+not use those settings. This was not dead serious, fortunately: there
+is a "default locale" called "C" that Perl can and will use, the
+script will be run. Before you really fix the problem, however, you
+will get the same error message each time you run Perl. How to really
+fix the problem can be found in L<perllocale> section B<LOCALE PROBLEMS>.
+
+=item Warning: something's wrong
+
+(W) You passed warn() an empty string (the equivalent of C<warn "">) or
+you called it with no args and C<$_> was empty.
+
+=item Warning: unable to close filehandle %s properly
+
+(S) The implicit close() done by an open() got an error indication on the
+close(). This usually indicates your file system ran out of disk space.
+
+=item Warning: Use of "%s" without parentheses is ambiguous
+
+(S) You wrote a unary operator followed by something that looks like a
+binary operator that could also have been interpreted as a term or
+unary operator. For instance, if you know that the rand function
+has a default argument of 1.0, and you write
+
+ rand + 5;
+
+you may THINK you wrote the same thing as
+
+ rand() + 5;
+
+but in actual fact, you got
+
+ rand(+5);
+
+So put in parentheses to say what you really mean.
+
+=item Write on closed filehandle
+
+(W) The filehandle you're writing to got itself closed sometime before now.
+Check your logic flow.
+
+=item X outside of string
+
+(F) You had a pack template that specified a relative position before
+the beginning of the string being unpacked. See L<perlfunc/pack>.
+
+=item x outside of string
+
+(F) You had a pack template that specified a relative position after
+the end of the string being unpacked. See L<perlfunc/pack>.
+
+=item Xsub "%s" called in sort
+
+(F) The use of an external subroutine as a sort comparison is not yet supported.
+
+=item Xsub called in sort
+
+(F) The use of an external subroutine as a sort comparison is not yet supported.
+
+=item You can't use C<-l> on a filehandle
+
+(F) A filehandle represents an opened file, and when you opened the file it
+already went past any symlink you are presumably trying to look for.
+Use a filename instead.
+
+=item YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!
+
+(F) And you probably never will, because you probably don't have the
+sources to your kernel, and your vendor probably doesn't give a rip
+about what you want. Your best bet is to use the wrapsuid script in
+the eg directory to put a setuid C wrapper around your script.
+
+=item You need to quote "%s"
+
+(W) You assigned a bareword as a signal handler name. Unfortunately, you
+already have a subroutine of that name declared, which means that Perl 5
+will try to call the subroutine when the assignment is executed, which is
+probably not what you want. (If it IS what you want, put an & in front.)
+
+=item [gs]etsockopt() on closed fd
+
+(W) You tried to get or set a socket option on a closed socket.
+Did you forget to check the return value of your socket() call?
+See L<perlfunc/getsockopt>.
+
+=item \1 better written as $1
+
+(W) Outside of patterns, backreferences live on as variables. The use
+of backslashes is grandfathered on the right-hand side of a
+substitution, but stylistically it's better to use the variable form
+because other Perl programmers will expect it, and it works better
+if there are more than 9 backreferences.
+
+=item '|' and 'E<lt>' may not both be specified on command line
+
+(F) An error peculiar to VMS. Perl does its own command line redirection, and
+found that STDIN was a pipe, and that you also tried to redirect STDIN using
+'E<lt>'. Only one STDIN stream to a customer, please.
+
+=item '|' and 'E<gt>' may not both be specified on command line
+
+(F) An error peculiar to VMS. Perl does its own command line redirection, and
+thinks you tried to redirect stdout both to a file and into a pipe to another
+command. You need to choose one or the other, though nothing's stopping you
+from piping into a program or Perl script which 'splits' output into two
+streams, such as
+
+ open(OUT,">$ARGV[0]") or die "Can't write to $ARGV[0]: $!";
+ while (<STDIN>) {
+ print;
+ print OUT;
+ }
+ close OUT;
+
+=item Got an error from DosAllocMem
+
+(P) An error peculiar to OS/2. Most probably you're using an obsolete
+version of Perl, and this should not happen anyway.
+
+=item Malformed PERLLIB_PREFIX
+
+(F) An error peculiar to OS/2. PERLLIB_PREFIX should be of the form
+
+ prefix1;prefix2
+
+or
+
+ prefix1 prefix2
+
+with nonempty prefix1 and prefix2. If C<prefix1> is indeed a prefix
+of a builtin library search path, prefix2 is substituted. The error
+may appear if components are not found, or are too long. See
+"PERLLIB_PREFIX" in F<README.os2>.
+
+=item PERL_SH_DIR too long
+
+(F) An error peculiar to OS/2. PERL_SH_DIR is the directory to find the
+C<sh>-shell in. See "PERL_SH_DIR" in F<README.os2>.
+
+=item Process terminated by SIG%s
+
+(W) This is a standard message issued by OS/2 applications, while *nix
+applications die in silence. It is considered a feature of the OS/2
+port. One can easily disable this by appropriate sighandlers, see
+L<perlipc/"Signals">. See also "Process terminated by SIGTERM/SIGINT"
+in F<README.os2>.
+
+=back
+
diff --git a/contrib/perl5/pod/perldsc.pod b/contrib/perl5/pod/perldsc.pod
new file mode 100644
index 0000000..d0cc335
--- /dev/null
+++ b/contrib/perl5/pod/perldsc.pod
@@ -0,0 +1,832 @@
+=head1 NAME
+
+perldsc - Perl Data Structures Cookbook
+
+=head1 DESCRIPTION
+
+The single feature most sorely lacking in the Perl programming language
+prior to its 5.0 release was complex data structures. Even without direct
+language support, some valiant programmers did manage to emulate them, but
+it was hard work and not for the faint of heart. You could occasionally
+get away with the C<$m{$LoL,$b}> notation borrowed from I<awk> in which the
+keys are actually more like a single concatenated string C<"$LoL$b">, but
+traversal and sorting were difficult. More desperate programmers even
+hacked Perl's internal symbol table directly, a strategy that proved hard
+to develop and maintain--to put it mildly.
+
+The 5.0 release of Perl let us have complex data structures. You
+may now write something like this and all of a sudden, you'd have a array
+with three dimensions!
+
+ for $x (1 .. 10) {
+ for $y (1 .. 10) {
+ for $z (1 .. 10) {
+ $LoL[$x][$y][$z] =
+ $x ** $y + $z;
+ }
+ }
+ }
+
+Alas, however simple this may appear, underneath it's a much more
+elaborate construct than meets the eye!
+
+How do you print it out? Why can't you say just C<print @LoL>? How do
+you sort it? How can you pass it to a function or get one of these back
+from a function? Is is an object? Can you save it to disk to read
+back later? How do you access whole rows or columns of that matrix? Do
+all the values have to be numeric?
+
+As you see, it's quite easy to become confused. While some small portion
+of the blame for this can be attributed to the reference-based
+implementation, it's really more due to a lack of existing documentation with
+examples designed for the beginner.
+
+This document is meant to be a detailed but understandable treatment of the
+many different sorts of data structures you might want to develop. It
+should also serve as a cookbook of examples. That way, when you need to
+create one of these complex data structures, you can just pinch, pilfer, or
+purloin a drop-in example from here.
+
+Let's look at each of these possible constructs in detail. There are separate
+sections on each of the following:
+
+=over 5
+
+=item * arrays of arrays
+
+=item * hashes of arrays
+
+=item * arrays of hashes
+
+=item * hashes of hashes
+
+=item * more elaborate constructs
+
+=back
+
+But for now, let's look at general issues common to all
+these types of data structures.
+
+=head1 REFERENCES
+
+The most important thing to understand about all data structures in Perl
+-- including multidimensional arrays--is that even though they might
+appear otherwise, Perl C<@ARRAY>s and C<%HASH>es are all internally
+one-dimensional. They can hold only scalar values (meaning a string,
+number, or a reference). They cannot directly contain other arrays or
+hashes, but instead contain I<references> to other arrays or hashes.
+
+You can't use a reference to a array or hash in quite the same way that you
+would a real array or hash. For C or C++ programmers unused to
+distinguishing between arrays and pointers to the same, this can be
+confusing. If so, just think of it as the difference between a structure
+and a pointer to a structure.
+
+You can (and should) read more about references in the perlref(1) man
+page. Briefly, references are rather like pointers that know what they
+point to. (Objects are also a kind of reference, but we won't be needing
+them right away--if ever.) This means that when you have something which
+looks to you like an access to a two-or-more-dimensional array and/or hash,
+what's really going on is that the base type is
+merely a one-dimensional entity that contains references to the next
+level. It's just that you can I<use> it as though it were a
+two-dimensional one. This is actually the way almost all C
+multidimensional arrays work as well.
+
+ $list[7][12] # array of arrays
+ $list[7]{string} # array of hashes
+ $hash{string}[7] # hash of arrays
+ $hash{string}{'another string'} # hash of hashes
+
+Now, because the top level contains only references, if you try to print
+out your array in with a simple print() function, you'll get something
+that doesn't look very nice, like this:
+
+ @LoL = ( [2, 3], [4, 5, 7], [0] );
+ print $LoL[1][2];
+ 7
+ print @LoL;
+ ARRAY(0x83c38)ARRAY(0x8b194)ARRAY(0x8b1d0)
+
+
+That's because Perl doesn't (ever) implicitly dereference your variables.
+If you want to get at the thing a reference is referring to, then you have
+to do this yourself using either prefix typing indicators, like
+C<${$blah}>, C<@{$blah}>, C<@{$blah[$i]}>, or else postfix pointer arrows,
+like C<$a-E<gt>[3]>, C<$h-E<gt>{fred}>, or even C<$ob-E<gt>method()-E<gt>[3]>.
+
+=head1 COMMON MISTAKES
+
+The two most common mistakes made in constructing something like
+an array of arrays is either accidentally counting the number of
+elements or else taking a reference to the same memory location
+repeatedly. Here's the case where you just get the count instead
+of a nested array:
+
+ for $i (1..10) {
+ @list = somefunc($i);
+ $LoL[$i] = @list; # WRONG!
+ }
+
+That's just the simple case of assigning a list to a scalar and getting
+its element count. If that's what you really and truly want, then you
+might do well to consider being a tad more explicit about it, like this:
+
+ for $i (1..10) {
+ @list = somefunc($i);
+ $counts[$i] = scalar @list;
+ }
+
+Here's the case of taking a reference to the same memory location
+again and again:
+
+ for $i (1..10) {
+ @list = somefunc($i);
+ $LoL[$i] = \@list; # WRONG!
+ }
+
+So, what's the big problem with that? It looks right, doesn't it?
+After all, I just told you that you need an array of references, so by
+golly, you've made me one!
+
+Unfortunately, while this is true, it's still broken. All the references
+in @LoL refer to the I<very same place>, and they will therefore all hold
+whatever was last in @list! It's similar to the problem demonstrated in
+the following C program:
+
+ #include <pwd.h>
+ main() {
+ struct passwd *getpwnam(), *rp, *dp;
+ rp = getpwnam("root");
+ dp = getpwnam("daemon");
+
+ printf("daemon name is %s\nroot name is %s\n",
+ dp->pw_name, rp->pw_name);
+ }
+
+Which will print
+
+ daemon name is daemon
+ root name is daemon
+
+The problem is that both C<rp> and C<dp> are pointers to the same location
+in memory! In C, you'd have to remember to malloc() yourself some new
+memory. In Perl, you'll want to use the array constructor C<[]> or the
+hash constructor C<{}> instead. Here's the right way to do the preceding
+broken code fragments:
+
+ for $i (1..10) {
+ @list = somefunc($i);
+ $LoL[$i] = [ @list ];
+ }
+
+The square brackets make a reference to a new array with a I<copy>
+of what's in @list at the time of the assignment. This is what
+you want.
+
+Note that this will produce something similar, but it's
+much harder to read:
+
+ for $i (1..10) {
+ @list = 0 .. $i;
+ @{$LoL[$i]} = @list;
+ }
+
+Is it the same? Well, maybe so--and maybe not. The subtle difference
+is that when you assign something in square brackets, you know for sure
+it's always a brand new reference with a new I<copy> of the data.
+Something else could be going on in this new case with the C<@{$LoL[$i]}}>
+dereference on the left-hand-side of the assignment. It all depends on
+whether C<$LoL[$i]> had been undefined to start with, or whether it
+already contained a reference. If you had already populated @LoL with
+references, as in
+
+ $LoL[3] = \@another_list;
+
+Then the assignment with the indirection on the left-hand-side would
+use the existing reference that was already there:
+
+ @{$LoL[3]} = @list;
+
+Of course, this I<would> have the "interesting" effect of clobbering
+@another_list. (Have you ever noticed how when a programmer says
+something is "interesting", that rather than meaning "intriguing",
+they're disturbingly more apt to mean that it's "annoying",
+"difficult", or both? :-)
+
+So just remember always to use the array or hash constructors with C<[]>
+or C<{}>, and you'll be fine, although it's not always optimally
+efficient.
+
+Surprisingly, the following dangerous-looking construct will
+actually work out fine:
+
+ for $i (1..10) {
+ my @list = somefunc($i);
+ $LoL[$i] = \@list;
+ }
+
+That's because my() is more of a run-time statement than it is a
+compile-time declaration I<per se>. This means that the my() variable is
+remade afresh each time through the loop. So even though it I<looks> as
+though you stored the same variable reference each time, you actually did
+not! This is a subtle distinction that can produce more efficient code at
+the risk of misleading all but the most experienced of programmers. So I
+usually advise against teaching it to beginners. In fact, except for
+passing arguments to functions, I seldom like to see the gimme-a-reference
+operator (backslash) used much at all in code. Instead, I advise
+beginners that they (and most of the rest of us) should try to use the
+much more easily understood constructors C<[]> and C<{}> instead of
+relying upon lexical (or dynamic) scoping and hidden reference-counting to
+do the right thing behind the scenes.
+
+In summary:
+
+ $LoL[$i] = [ @list ]; # usually best
+ $LoL[$i] = \@list; # perilous; just how my() was that list?
+ @{ $LoL[$i] } = @list; # way too tricky for most programmers
+
+
+=head1 CAVEAT ON PRECEDENCE
+
+Speaking of things like C<@{$LoL[$i]}>, the following are actually the
+same thing:
+
+ $listref->[2][2] # clear
+ $$listref[2][2] # confusing
+
+That's because Perl's precedence rules on its five prefix dereferencers
+(which look like someone swearing: C<$ @ * % &>) make them bind more
+tightly than the postfix subscripting brackets or braces! This will no
+doubt come as a great shock to the C or C++ programmer, who is quite
+accustomed to using C<*a[i]> to mean what's pointed to by the I<i'th>
+element of C<a>. That is, they first take the subscript, and only then
+dereference the thing at that subscript. That's fine in C, but this isn't C.
+
+The seemingly equivalent construct in Perl, C<$$listref[$i]> first does
+the deref of C<$listref>, making it take $listref as a reference to an
+array, and then dereference that, and finally tell you the I<i'th> value
+of the array pointed to by $LoL. If you wanted the C notion, you'd have to
+write C<${$LoL[$i]}> to force the C<$LoL[$i]> to get evaluated first
+before the leading C<$> dereferencer.
+
+=head1 WHY YOU SHOULD ALWAYS C<use strict>
+
+If this is starting to sound scarier than it's worth, relax. Perl has
+some features to help you avoid its most common pitfalls. The best
+way to avoid getting confused is to start every program like this:
+
+ #!/usr/bin/perl -w
+ use strict;
+
+This way, you'll be forced to declare all your variables with my() and
+also disallow accidental "symbolic dereferencing". Therefore if you'd done
+this:
+
+ my $listref = [
+ [ "fred", "barney", "pebbles", "bambam", "dino", ],
+ [ "homer", "bart", "marge", "maggie", ],
+ [ "george", "jane", "elroy", "judy", ],
+ ];
+
+ print $listref[2][2];
+
+The compiler would immediately flag that as an error I<at compile time>,
+because you were accidentally accessing C<@listref>, an undeclared
+variable, and it would thereby remind you to write instead:
+
+ print $listref->[2][2]
+
+=head1 DEBUGGING
+
+Before version 5.002, the standard Perl debugger didn't do a very nice job of
+printing out complex data structures. With 5.002 or above, the
+debugger includes several new features, including command line editing as
+well as the C<x> command to dump out complex data structures. For
+example, given the assignment to $LoL above, here's the debugger output:
+
+ DB<1> x $LoL
+ $LoL = ARRAY(0x13b5a0)
+ 0 ARRAY(0x1f0a24)
+ 0 'fred'
+ 1 'barney'
+ 2 'pebbles'
+ 3 'bambam'
+ 4 'dino'
+ 1 ARRAY(0x13b558)
+ 0 'homer'
+ 1 'bart'
+ 2 'marge'
+ 3 'maggie'
+ 2 ARRAY(0x13b540)
+ 0 'george'
+ 1 'jane'
+ 2 'elroy'
+ 3 'judy'
+
+=head1 CODE EXAMPLES
+
+Presented with little comment (these will get their own manpages someday)
+here are short code examples illustrating access of various
+types of data structures.
+
+=head1 LISTS OF LISTS
+
+=head2 Declaration of a LIST OF LISTS
+
+ @LoL = (
+ [ "fred", "barney" ],
+ [ "george", "jane", "elroy" ],
+ [ "homer", "marge", "bart" ],
+ );
+
+=head2 Generation of a LIST OF LISTS
+
+ # reading from file
+ while ( <> ) {
+ push @LoL, [ split ];
+ }
+
+ # calling a function
+ for $i ( 1 .. 10 ) {
+ $LoL[$i] = [ somefunc($i) ];
+ }
+
+ # using temp vars
+ for $i ( 1 .. 10 ) {
+ @tmp = somefunc($i);
+ $LoL[$i] = [ @tmp ];
+ }
+
+ # add to an existing row
+ push @{ $LoL[0] }, "wilma", "betty";
+
+=head2 Access and Printing of a LIST OF LISTS
+
+ # one element
+ $LoL[0][0] = "Fred";
+
+ # another element
+ $LoL[1][1] =~ s/(\w)/\u$1/;
+
+ # print the whole thing with refs
+ for $aref ( @LoL ) {
+ print "\t [ @$aref ],\n";
+ }
+
+ # print the whole thing with indices
+ for $i ( 0 .. $#LoL ) {
+ print "\t [ @{$LoL[$i]} ],\n";
+ }
+
+ # print the whole thing one at a time
+ for $i ( 0 .. $#LoL ) {
+ for $j ( 0 .. $#{ $LoL[$i] } ) {
+ print "elt $i $j is $LoL[$i][$j]\n";
+ }
+ }
+
+=head1 HASHES OF LISTS
+
+=head2 Declaration of a HASH OF LISTS
+
+ %HoL = (
+ flintstones => [ "fred", "barney" ],
+ jetsons => [ "george", "jane", "elroy" ],
+ simpsons => [ "homer", "marge", "bart" ],
+ );
+
+=head2 Generation of a HASH OF LISTS
+
+ # reading from file
+ # flintstones: fred barney wilma dino
+ while ( <> ) {
+ next unless s/^(.*?):\s*//;
+ $HoL{$1} = [ split ];
+ }
+
+ # reading from file; more temps
+ # flintstones: fred barney wilma dino
+ while ( $line = <> ) {
+ ($who, $rest) = split /:\s*/, $line, 2;
+ @fields = split ' ', $rest;
+ $HoL{$who} = [ @fields ];
+ }
+
+ # calling a function that returns a list
+ for $group ( "simpsons", "jetsons", "flintstones" ) {
+ $HoL{$group} = [ get_family($group) ];
+ }
+
+ # likewise, but using temps
+ for $group ( "simpsons", "jetsons", "flintstones" ) {
+ @members = get_family($group);
+ $HoL{$group} = [ @members ];
+ }
+
+ # append new members to an existing family
+ push @{ $HoL{"flintstones"} }, "wilma", "betty";
+
+=head2 Access and Printing of a HASH OF LISTS
+
+ # one element
+ $HoL{flintstones}[0] = "Fred";
+
+ # another element
+ $HoL{simpsons}[1] =~ s/(\w)/\u$1/;
+
+ # print the whole thing
+ foreach $family ( keys %HoL ) {
+ print "$family: @{ $HoL{$family} }\n"
+ }
+
+ # print the whole thing with indices
+ foreach $family ( keys %HoL ) {
+ print "family: ";
+ foreach $i ( 0 .. $#{ $HoL{$family} } ) {
+ print " $i = $HoL{$family}[$i]";
+ }
+ print "\n";
+ }
+
+ # print the whole thing sorted by number of members
+ foreach $family ( sort { @{$HoL{$b}} <=> @{$HoL{$a}} } keys %HoL ) {
+ print "$family: @{ $HoL{$family} }\n"
+ }
+
+ # print the whole thing sorted by number of members and name
+ foreach $family ( sort {
+ @{$HoL{$b}} <=> @{$HoL{$a}}
+ ||
+ $a cmp $b
+ } keys %HoL )
+ {
+ print "$family: ", join(", ", sort @{ $HoL{$family} }), "\n";
+ }
+
+=head1 LISTS OF HASHES
+
+=head2 Declaration of a LIST OF HASHES
+
+ @LoH = (
+ {
+ Lead => "fred",
+ Friend => "barney",
+ },
+ {
+ Lead => "george",
+ Wife => "jane",
+ Son => "elroy",
+ },
+ {
+ Lead => "homer",
+ Wife => "marge",
+ Son => "bart",
+ }
+ );
+
+=head2 Generation of a LIST OF HASHES
+
+ # reading from file
+ # format: LEAD=fred FRIEND=barney
+ while ( <> ) {
+ $rec = {};
+ for $field ( split ) {
+ ($key, $value) = split /=/, $field;
+ $rec->{$key} = $value;
+ }
+ push @LoH, $rec;
+ }
+
+
+ # reading from file
+ # format: LEAD=fred FRIEND=barney
+ # no temp
+ while ( <> ) {
+ push @LoH, { split /[\s+=]/ };
+ }
+
+ # calling a function that returns a key,value list, like
+ # "lead","fred","daughter","pebbles"
+ while ( %fields = getnextpairset() ) {
+ push @LoH, { %fields };
+ }
+
+ # likewise, but using no temp vars
+ while (<>) {
+ push @LoH, { parsepairs($_) };
+ }
+
+ # add key/value to an element
+ $LoH[0]{pet} = "dino";
+ $LoH[2]{pet} = "santa's little helper";
+
+=head2 Access and Printing of a LIST OF HASHES
+
+ # one element
+ $LoH[0]{lead} = "fred";
+
+ # another element
+ $LoH[1]{lead} =~ s/(\w)/\u$1/;
+
+ # print the whole thing with refs
+ for $href ( @LoH ) {
+ print "{ ";
+ for $role ( keys %$href ) {
+ print "$role=$href->{$role} ";
+ }
+ print "}\n";
+ }
+
+ # print the whole thing with indices
+ for $i ( 0 .. $#LoH ) {
+ print "$i is { ";
+ for $role ( keys %{ $LoH[$i] } ) {
+ print "$role=$LoH[$i]{$role} ";
+ }
+ print "}\n";
+ }
+
+ # print the whole thing one at a time
+ for $i ( 0 .. $#LoH ) {
+ for $role ( keys %{ $LoH[$i] } ) {
+ print "elt $i $role is $LoH[$i]{$role}\n";
+ }
+ }
+
+=head1 HASHES OF HASHES
+
+=head2 Declaration of a HASH OF HASHES
+
+ %HoH = (
+ flintstones => {
+ lead => "fred",
+ pal => "barney",
+ },
+ jetsons => {
+ lead => "george",
+ wife => "jane",
+ "his boy" => "elroy",
+ },
+ simpsons => {
+ lead => "homer",
+ wife => "marge",
+ kid => "bart",
+ },
+ );
+
+=head2 Generation of a HASH OF HASHES
+
+ # reading from file
+ # flintstones: lead=fred pal=barney wife=wilma pet=dino
+ while ( <> ) {
+ next unless s/^(.*?):\s*//;
+ $who = $1;
+ for $field ( split ) {
+ ($key, $value) = split /=/, $field;
+ $HoH{$who}{$key} = $value;
+ }
+
+
+ # reading from file; more temps
+ while ( <> ) {
+ next unless s/^(.*?):\s*//;
+ $who = $1;
+ $rec = {};
+ $HoH{$who} = $rec;
+ for $field ( split ) {
+ ($key, $value) = split /=/, $field;
+ $rec->{$key} = $value;
+ }
+ }
+
+ # calling a function that returns a key,value hash
+ for $group ( "simpsons", "jetsons", "flintstones" ) {
+ $HoH{$group} = { get_family($group) };
+ }
+
+ # likewise, but using temps
+ for $group ( "simpsons", "jetsons", "flintstones" ) {
+ %members = get_family($group);
+ $HoH{$group} = { %members };
+ }
+
+ # append new members to an existing family
+ %new_folks = (
+ wife => "wilma",
+ pet => "dino",
+ );
+
+ for $what (keys %new_folks) {
+ $HoH{flintstones}{$what} = $new_folks{$what};
+ }
+
+=head2 Access and Printing of a HASH OF HASHES
+
+ # one element
+ $HoH{flintstones}{wife} = "wilma";
+
+ # another element
+ $HoH{simpsons}{lead} =~ s/(\w)/\u$1/;
+
+ # print the whole thing
+ foreach $family ( keys %HoH ) {
+ print "$family: { ";
+ for $role ( keys %{ $HoH{$family} } ) {
+ print "$role=$HoH{$family}{$role} ";
+ }
+ print "}\n";
+ }
+
+ # print the whole thing somewhat sorted
+ foreach $family ( sort keys %HoH ) {
+ print "$family: { ";
+ for $role ( sort keys %{ $HoH{$family} } ) {
+ print "$role=$HoH{$family}{$role} ";
+ }
+ print "}\n";
+ }
+
+
+ # print the whole thing sorted by number of members
+ foreach $family ( sort { keys %{$HoH{$b}} <=> keys %{$HoH{$a}} } keys %HoH ) {
+ print "$family: { ";
+ for $role ( sort keys %{ $HoH{$family} } ) {
+ print "$role=$HoH{$family}{$role} ";
+ }
+ print "}\n";
+ }
+
+ # establish a sort order (rank) for each role
+ $i = 0;
+ for ( qw(lead wife son daughter pal pet) ) { $rank{$_} = ++$i }
+
+ # now print the whole thing sorted by number of members
+ foreach $family ( sort { keys %{ $HoH{$b} } <=> keys %{ $HoH{$a} } } keys %HoH ) {
+ print "$family: { ";
+ # and print these according to rank order
+ for $role ( sort { $rank{$a} <=> $rank{$b} } keys %{ $HoH{$family} } ) {
+ print "$role=$HoH{$family}{$role} ";
+ }
+ print "}\n";
+ }
+
+
+=head1 MORE ELABORATE RECORDS
+
+=head2 Declaration of MORE ELABORATE RECORDS
+
+Here's a sample showing how to create and use a record whose fields are of
+many different sorts:
+
+ $rec = {
+ TEXT => $string,
+ SEQUENCE => [ @old_values ],
+ LOOKUP => { %some_table },
+ THATCODE => \&some_function,
+ THISCODE => sub { $_[0] ** $_[1] },
+ HANDLE => \*STDOUT,
+ };
+
+ print $rec->{TEXT};
+
+ print $rec->{LIST}[0];
+ $last = pop @ { $rec->{SEQUENCE} };
+
+ print $rec->{LOOKUP}{"key"};
+ ($first_k, $first_v) = each %{ $rec->{LOOKUP} };
+
+ $answer = $rec->{THATCODE}->($arg);
+ $answer = $rec->{THISCODE}->($arg1, $arg2);
+
+ # careful of extra block braces on fh ref
+ print { $rec->{HANDLE} } "a string\n";
+
+ use FileHandle;
+ $rec->{HANDLE}->autoflush(1);
+ $rec->{HANDLE}->print(" a string\n");
+
+=head2 Declaration of a HASH OF COMPLEX RECORDS
+
+ %TV = (
+ flintstones => {
+ series => "flintstones",
+ nights => [ qw(monday thursday friday) ],
+ members => [
+ { name => "fred", role => "lead", age => 36, },
+ { name => "wilma", role => "wife", age => 31, },
+ { name => "pebbles", role => "kid", age => 4, },
+ ],
+ },
+
+ jetsons => {
+ series => "jetsons",
+ nights => [ qw(wednesday saturday) ],
+ members => [
+ { name => "george", role => "lead", age => 41, },
+ { name => "jane", role => "wife", age => 39, },
+ { name => "elroy", role => "kid", age => 9, },
+ ],
+ },
+
+ simpsons => {
+ series => "simpsons",
+ nights => [ qw(monday) ],
+ members => [
+ { name => "homer", role => "lead", age => 34, },
+ { name => "marge", role => "wife", age => 37, },
+ { name => "bart", role => "kid", age => 11, },
+ ],
+ },
+ );
+
+=head2 Generation of a HASH OF COMPLEX RECORDS
+
+ # reading from file
+ # this is most easily done by having the file itself be
+ # in the raw data format as shown above. perl is happy
+ # to parse complex data structures if declared as data, so
+ # sometimes it's easiest to do that
+
+ # here's a piece by piece build up
+ $rec = {};
+ $rec->{series} = "flintstones";
+ $rec->{nights} = [ find_days() ];
+
+ @members = ();
+ # assume this file in field=value syntax
+ while (<>) {
+ %fields = split /[\s=]+/;
+ push @members, { %fields };
+ }
+ $rec->{members} = [ @members ];
+
+ # now remember the whole thing
+ $TV{ $rec->{series} } = $rec;
+
+ ###########################################################
+ # now, you might want to make interesting extra fields that
+ # include pointers back into the same data structure so if
+ # change one piece, it changes everywhere, like for examples
+ # if you wanted a {kids} field that was an array reference
+ # to a list of the kids' records without having duplicate
+ # records and thus update problems.
+ ###########################################################
+ foreach $family (keys %TV) {
+ $rec = $TV{$family}; # temp pointer
+ @kids = ();
+ for $person ( @{ $rec->{members} } ) {
+ if ($person->{role} =~ /kid|son|daughter/) {
+ push @kids, $person;
+ }
+ }
+ # REMEMBER: $rec and $TV{$family} point to same data!!
+ $rec->{kids} = [ @kids ];
+ }
+
+ # you copied the list, but the list itself contains pointers
+ # to uncopied objects. this means that if you make bart get
+ # older via
+
+ $TV{simpsons}{kids}[0]{age}++;
+
+ # then this would also change in
+ print $TV{simpsons}{members}[2]{age};
+
+ # because $TV{simpsons}{kids}[0] and $TV{simpsons}{members}[2]
+ # both point to the same underlying anonymous hash table
+
+ # print the whole thing
+ foreach $family ( keys %TV ) {
+ print "the $family";
+ print " is on during @{ $TV{$family}{nights} }\n";
+ print "its members are:\n";
+ for $who ( @{ $TV{$family}{members} } ) {
+ print " $who->{name} ($who->{role}), age $who->{age}\n";
+ }
+ print "it turns out that $TV{$family}{lead} has ";
+ print scalar ( @{ $TV{$family}{kids} } ), " kids named ";
+ print join (", ", map { $_->{name} } @{ $TV{$family}{kids} } );
+ print "\n";
+ }
+
+=head1 Database Ties
+
+You cannot easily tie a multilevel data structure (such as a hash of
+hashes) to a dbm file. The first problem is that all but GDBM and
+Berkeley DB have size limitations, but beyond that, you also have problems
+with how references are to be represented on disk. One experimental
+module that does partially attempt to address this need is the MLDBM
+module. Check your nearest CPAN site as described in L<perlmodlib> for
+source code to MLDBM.
+
+=head1 SEE ALSO
+
+perlref(1), perllol(1), perldata(1), perlobj(1)
+
+=head1 AUTHOR
+
+Tom Christiansen <F<tchrist@perl.com>>
+
+Last update:
+Wed Oct 23 04:57:50 MET DST 1996
diff --git a/contrib/perl5/pod/perlembed.pod b/contrib/perl5/pod/perlembed.pod
new file mode 100644
index 0000000..c09d6e3
--- /dev/null
+++ b/contrib/perl5/pod/perlembed.pod
@@ -0,0 +1,1029 @@
+=head1 NAME
+
+perlembed - how to embed perl in your C program
+
+=head1 DESCRIPTION
+
+=head2 PREAMBLE
+
+Do you want to:
+
+=over 5
+
+=item B<Use C from Perl?>
+
+Read L<perlxstut>, L<perlxs>, L<h2xs>, and L<perlguts>.
+
+=item B<Use a Unix program from Perl?>
+
+Read about back-quotes and about C<system> and C<exec> in L<perlfunc>.
+
+=item B<Use Perl from Perl?>
+
+Read about L<perlfunc/do> and L<perlfunc/eval> and L<perlfunc/require>
+and L<perlfunc/use>.
+
+=item B<Use C from C?>
+
+Rethink your design.
+
+=item B<Use Perl from C?>
+
+Read on...
+
+=back
+
+=head2 ROADMAP
+
+=over 5
+
+L<Compiling your C program>
+
+L<Adding a Perl interpreter to your C program>
+
+L<Calling a Perl subroutine from your C program>
+
+L<Evaluating a Perl statement from your C program>
+
+L<Performing Perl pattern matches and substitutions from your C program>
+
+L<Fiddling with the Perl stack from your C program>
+
+L<Maintaining a persistent interpreter>
+
+L<Maintaining multiple interpreter instances>
+
+L<Using Perl modules, which themselves use C libraries, from your C program>
+
+L<Embedding Perl under Win32>
+
+=back
+
+=head2 Compiling your C program
+
+If you have trouble compiling the scripts in this documentation,
+you're not alone. The cardinal rule: COMPILE THE PROGRAMS IN EXACTLY
+THE SAME WAY THAT YOUR PERL WAS COMPILED. (Sorry for yelling.)
+
+Also, every C program that uses Perl must link in the I<perl library>.
+What's that, you ask? Perl is itself written in C; the perl library
+is the collection of compiled C programs that were used to create your
+perl executable (I</usr/bin/perl> or equivalent). (Corollary: you
+can't use Perl from your C program unless Perl has been compiled on
+your machine, or installed properly--that's why you shouldn't blithely
+copy Perl executables from machine to machine without also copying the
+I<lib> directory.)
+
+When you use Perl from C, your C program will--usually--allocate,
+"run", and deallocate a I<PerlInterpreter> object, which is defined by
+the perl library.
+
+If your copy of Perl is recent enough to contain this documentation
+(version 5.002 or later), then the perl library (and I<EXTERN.h> and
+I<perl.h>, which you'll also need) will reside in a directory
+that looks like this:
+
+ /usr/local/lib/perl5/your_architecture_here/CORE
+
+or perhaps just
+
+ /usr/local/lib/perl5/CORE
+
+or maybe something like
+
+ /usr/opt/perl5/CORE
+
+Execute this statement for a hint about where to find CORE:
+
+ perl -MConfig -e 'print $Config{archlib}'
+
+Here's how you'd compile the example in the next section,
+L<Adding a Perl interpreter to your C program>, on my Linux box:
+
+ % gcc -O2 -Dbool=char -DHAS_BOOL -I/usr/local/include
+ -I/usr/local/lib/perl5/i586-linux/5.003/CORE
+ -L/usr/local/lib/perl5/i586-linux/5.003/CORE
+ -o interp interp.c -lperl -lm
+
+(That's all one line.) On my DEC Alpha running old 5.003_05, the
+incantation is a bit different:
+
+ % cc -O2 -Olimit 2900 -DSTANDARD_C -I/usr/local/include
+ -I/usr/local/lib/perl5/alpha-dec_osf/5.00305/CORE
+ -L/usr/local/lib/perl5/alpha-dec_osf/5.00305/CORE -L/usr/local/lib
+ -D__LANGUAGE_C__ -D_NO_PROTO -o interp interp.c -lperl -lm
+
+How can you figure out what to add? Assuming your Perl is post-5.001,
+execute a C<perl -V> command and pay special attention to the "cc" and
+"ccflags" information.
+
+You'll have to choose the appropriate compiler (I<cc>, I<gcc>, et al.) for
+your machine: C<perl -MConfig -e 'print $Config{cc}'> will tell you what
+to use.
+
+You'll also have to choose the appropriate library directory
+(I</usr/local/lib/...>) for your machine. If your compiler complains
+that certain functions are undefined, or that it can't locate
+I<-lperl>, then you need to change the path following the C<-L>. If it
+complains that it can't find I<EXTERN.h> and I<perl.h>, you need to
+change the path following the C<-I>.
+
+You may have to add extra libraries as well. Which ones?
+Perhaps those printed by
+
+ perl -MConfig -e 'print $Config{libs}'
+
+Provided your perl binary was properly configured and installed the
+B<ExtUtils::Embed> module will determine all of this information for
+you:
+
+ % cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+If the B<ExtUtils::Embed> module isn't part of your Perl distribution,
+you can retrieve it from
+http://www.perl.com/perl/CPAN/modules/by-module/ExtUtils::Embed. (If
+this documentation came from your Perl distribution, then you're
+running 5.004 or better and you already have it.)
+
+The B<ExtUtils::Embed> kit on CPAN also contains all source code for
+the examples in this document, tests, additional examples and other
+information you may find useful.
+
+=head2 Adding a Perl interpreter to your C program
+
+In a sense, perl (the C program) is a good example of embedding Perl
+(the language), so I'll demonstrate embedding with I<miniperlmain.c>,
+included in the source distribution. Here's a bastardized, nonportable
+version of I<miniperlmain.c> containing the essentials of embedding:
+
+ #include <EXTERN.h> /* from the Perl distribution */
+ #include <perl.h> /* from the Perl distribution */
+
+ static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
+
+ int main(int argc, char **argv, char **env)
+ {
+ my_perl = perl_alloc();
+ perl_construct(my_perl);
+ perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
+ perl_run(my_perl);
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ }
+
+Notice that we don't use the C<env> pointer. Normally handed to
+C<perl_parse> as its final argument, C<env> here is replaced by
+C<NULL>, which means that the current environment will be used.
+
+Now compile this program (I'll call it I<interp.c>) into an executable:
+
+ % cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+After a successful compilation, you'll be able to use I<interp> just
+like perl itself:
+
+ % interp
+ print "Pretty Good Perl \n";
+ print "10890 - 9801 is ", 10890 - 9801;
+ <CTRL-D>
+ Pretty Good Perl
+ 10890 - 9801 is 1089
+
+or
+
+ % interp -e 'printf("%x", 3735928559)'
+ deadbeef
+
+You can also read and execute Perl statements from a file while in the
+midst of your C program, by placing the filename in I<argv[1]> before
+calling I<perl_run>.
+
+=head2 Calling a Perl subroutine from your C program
+
+To call individual Perl subroutines, you can use any of the B<perl_call_*>
+functions documented in L<perlcall>.
+In this example we'll use C<perl_call_argv>.
+
+That's shown below, in a program I'll call I<showtime.c>.
+
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ static PerlInterpreter *my_perl;
+
+ int main(int argc, char **argv, char **env)
+ {
+ char *args[] = { NULL };
+ my_perl = perl_alloc();
+ perl_construct(my_perl);
+
+ perl_parse(my_perl, NULL, argc, argv, NULL);
+
+ /*** skipping perl_run() ***/
+
+ perl_call_argv("showtime", G_DISCARD | G_NOARGS, args);
+
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ }
+
+where I<showtime> is a Perl subroutine that takes no arguments (that's the
+I<G_NOARGS>) and for which I'll ignore the return value (that's the
+I<G_DISCARD>). Those flags, and others, are discussed in L<perlcall>.
+
+I'll define the I<showtime> subroutine in a file called I<showtime.pl>:
+
+ print "I shan't be printed.";
+
+ sub showtime {
+ print time;
+ }
+
+Simple enough. Now compile and run:
+
+ % cc -o showtime showtime.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+ % showtime showtime.pl
+ 818284590
+
+yielding the number of seconds that elapsed between January 1, 1970
+(the beginning of the Unix epoch), and the moment I began writing this
+sentence.
+
+In this particular case we don't have to call I<perl_run>, but in
+general it's considered good practice to ensure proper initialization
+of library code, including execution of all object C<DESTROY> methods
+and package C<END {}> blocks.
+
+If you want to pass arguments to the Perl subroutine, you can add
+strings to the C<NULL>-terminated C<args> list passed to
+I<perl_call_argv>. For other data types, or to examine return values,
+you'll need to manipulate the Perl stack. That's demonstrated in the
+last section of this document: L<Fiddling with the Perl stack from
+your C program>.
+
+=head2 Evaluating a Perl statement from your C program
+
+Perl provides two API functions to evaluate pieces of Perl code.
+These are L<perlguts/perl_eval_sv> and L<perlguts/perl_eval_pv>.
+
+Arguably, these are the only routines you'll ever need to execute
+snippets of Perl code from within your C program. Your code can be as
+long as you wish; it can contain multiple statements; it can employ
+L<perlfunc/use>, L<perlfunc/require>, and L<perlfunc/do> to
+include external Perl files.
+
+I<perl_eval_pv> lets us evaluate individual Perl strings, and then
+extract variables for coercion into C types. The following program,
+I<string.c>, executes three Perl strings, extracting an C<int> from
+the first, a C<float> from the second, and a C<char *> from the third.
+
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ static PerlInterpreter *my_perl;
+
+ main (int argc, char **argv, char **env)
+ {
+ char *embedding[] = { "", "-e", "0" };
+
+ my_perl = perl_alloc();
+ perl_construct( my_perl );
+
+ perl_parse(my_perl, NULL, 3, embedding, NULL);
+ perl_run(my_perl);
+
+ /** Treat $a as an integer **/
+ perl_eval_pv("$a = 3; $a **= 2", TRUE);
+ printf("a = %d\n", SvIV(perl_get_sv("a", FALSE)));
+
+ /** Treat $a as a float **/
+ perl_eval_pv("$a = 3.14; $a **= 2", TRUE);
+ printf("a = %f\n", SvNV(perl_get_sv("a", FALSE)));
+
+ /** Treat $a as a string **/
+ perl_eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
+ printf("a = %s\n", SvPV(perl_get_sv("a", FALSE), PL_na));
+
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ }
+
+All of those strange functions with I<sv> in their names help convert Perl scalars to C types. They're described in L<perlguts>.
+
+If you compile and run I<string.c>, you'll see the results of using
+I<SvIV()> to create an C<int>, I<SvNV()> to create a C<float>, and
+I<SvPV()> to create a string:
+
+ a = 9
+ a = 9.859600
+ a = Just Another Perl Hacker
+
+In the example above, we've created a global variable to temporarily
+store the computed value of our eval'd expression. It is also
+possible and in most cases a better strategy to fetch the return value
+from I<perl_eval_pv()> instead. Example:
+
+ ...
+ SV *val = perl_eval_pv("reverse 'rekcaH lreP rehtonA tsuJ'", TRUE);
+ printf("%s\n", SvPV(val,PL_na));
+ ...
+
+This way, we avoid namespace pollution by not creating global
+variables and we've simplified our code as well.
+
+=head2 Performing Perl pattern matches and substitutions from your C program
+
+The I<perl_eval_sv()> function lets us evaluate strings of Perl code, so we can
+define some functions that use it to "specialize" in matches and
+substitutions: I<match()>, I<substitute()>, and I<matches()>.
+
+ I32 match(SV *string, char *pattern);
+
+Given a string and a pattern (e.g., C<m/clasp/> or C</\b\w*\b/>, which
+in your C program might appear as "/\\b\\w*\\b/"), match()
+returns 1 if the string matches the pattern and 0 otherwise.
+
+ int substitute(SV **string, char *pattern);
+
+Given a pointer to an C<SV> and an C<=~> operation (e.g.,
+C<s/bob/robert/g> or C<tr[A-Z][a-z]>), substitute() modifies the string
+within the C<AV> at according to the operation, returning the number of substitutions
+made.
+
+ int matches(SV *string, char *pattern, AV **matches);
+
+Given an C<SV>, a pattern, and a pointer to an empty C<AV>,
+matches() evaluates C<$string =~ $pattern> in an array context, and
+fills in I<matches> with the array elements, returning the number of matches found.
+
+Here's a sample program, I<match.c>, that uses all three (long lines have
+been wrapped here):
+
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ /** my_perl_eval_sv(code, error_check)
+ ** kinda like perl_eval_sv(),
+ ** but we pop the return value off the stack
+ **/
+ SV* my_perl_eval_sv(SV *sv, I32 croak_on_error)
+ {
+ dSP;
+ SV* retval;
+
+ PUSHMARK(SP);
+ perl_eval_sv(sv, G_SCALAR);
+
+ SPAGAIN;
+ retval = POPs;
+ PUTBACK;
+
+ if (croak_on_error && SvTRUE(ERRSV))
+ croak(SvPVx(ERRSV, PL_na));
+
+ return retval;
+ }
+
+ /** match(string, pattern)
+ **
+ ** Used for matches in a scalar context.
+ **
+ ** Returns 1 if the match was successful; 0 otherwise.
+ **/
+
+ I32 match(SV *string, char *pattern)
+ {
+ SV *command = NEWSV(1099, 0), *retval;
+
+ sv_setpvf(command, "my $string = '%s'; $string =~ %s",
+ SvPV(string,PL_na), pattern);
+
+ retval = my_perl_eval_sv(command, TRUE);
+ SvREFCNT_dec(command);
+
+ return SvIV(retval);
+ }
+
+ /** substitute(string, pattern)
+ **
+ ** Used for =~ operations that modify their left-hand side (s/// and tr///)
+ **
+ ** Returns the number of successful matches, and
+ ** modifies the input string if there were any.
+ **/
+
+ I32 substitute(SV **string, char *pattern)
+ {
+ SV *command = NEWSV(1099, 0), *retval;
+
+ sv_setpvf(command, "$string = '%s'; ($string =~ %s)",
+ SvPV(*string,PL_na), pattern);
+
+ retval = my_perl_eval_sv(command, TRUE);
+ SvREFCNT_dec(command);
+
+ *string = perl_get_sv("string", FALSE);
+ return SvIV(retval);
+ }
+
+ /** matches(string, pattern, matches)
+ **
+ ** Used for matches in an array context.
+ **
+ ** Returns the number of matches,
+ ** and fills in **matches with the matching substrings
+ **/
+
+ I32 matches(SV *string, char *pattern, AV **match_list)
+ {
+ SV *command = NEWSV(1099, 0);
+ I32 num_matches;
+
+ sv_setpvf(command, "my $string = '%s'; @array = ($string =~ %s)",
+ SvPV(string,PL_na), pattern);
+
+ my_perl_eval_sv(command, TRUE);
+ SvREFCNT_dec(command);
+
+ *match_list = perl_get_av("array", FALSE);
+ num_matches = av_len(*match_list) + 1; /** assume $[ is 0 **/
+
+ return num_matches;
+ }
+
+ main (int argc, char **argv, char **env)
+ {
+ PerlInterpreter *my_perl = perl_alloc();
+ char *embedding[] = { "", "-e", "0" };
+ AV *match_list;
+ I32 num_matches, i;
+ SV *text = NEWSV(1099,0);
+
+ perl_construct(my_perl);
+ perl_parse(my_perl, NULL, 3, embedding, NULL);
+
+ sv_setpv(text, "When he is at a convenience store and the bill comes to some amount like 76 cents, Maynard is aware that there is something he *should* do, something that will enable him to get back a quarter, but he has no idea *what*. He fumbles through his red squeezey changepurse and gives the boy three extra pennies with his dollar, hoping that he might luck into the correct amount. The boy gives him back two of his own pennies and then the big shiny quarter that is his prize. -RICHH");
+
+ if (match(text, "m/quarter/")) /** Does text contain 'quarter'? **/
+ printf("match: Text contains the word 'quarter'.\n\n");
+ else
+ printf("match: Text doesn't contain the word 'quarter'.\n\n");
+
+ if (match(text, "m/eighth/")) /** Does text contain 'eighth'? **/
+ printf("match: Text contains the word 'eighth'.\n\n");
+ else
+ printf("match: Text doesn't contain the word 'eighth'.\n\n");
+
+ /** Match all occurrences of /wi../ **/
+ num_matches = matches(text, "m/(wi..)/g", &match_list);
+ printf("matches: m/(wi..)/g found %d matches...\n", num_matches);
+
+ for (i = 0; i < num_matches; i++)
+ printf("match: %s\n", SvPV(*av_fetch(match_list, i, FALSE),PL_na));
+ printf("\n");
+
+ /** Remove all vowels from text **/
+ num_matches = substitute(&text, "s/[aeiou]//gi");
+ if (num_matches) {
+ printf("substitute: s/[aeiou]//gi...%d substitutions made.\n",
+ num_matches);
+ printf("Now text is: %s\n\n", SvPV(text,PL_na));
+ }
+
+ /** Attempt a substitution **/
+ if (!substitute(&text, "s/Perl/C/")) {
+ printf("substitute: s/Perl/C...No substitution made.\n\n");
+ }
+
+ SvREFCNT_dec(text);
+ PL_perl_destruct_level = 1;
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ }
+
+which produces the output (again, long lines have been wrapped here)
+
+ match: Text contains the word 'quarter'.
+
+ match: Text doesn't contain the word 'eighth'.
+
+ matches: m/(wi..)/g found 2 matches...
+ match: will
+ match: with
+
+ substitute: s/[aeiou]//gi...139 substitutions made.
+ Now text is: Whn h s t cnvnnc str nd th bll cms t sm mnt lk 76 cnts,
+ Mynrd s wr tht thr s smthng h *shld* d, smthng tht wll nbl hm t gt bck
+ qrtr, bt h hs n d *wht*. H fmbls thrgh hs rd sqzy chngprs nd gvs th by
+ thr xtr pnns wth hs dllr, hpng tht h mght lck nt th crrct mnt. Th by gvs
+ hm bck tw f hs wn pnns nd thn th bg shny qrtr tht s hs prz. -RCHH
+
+ substitute: s/Perl/C...No substitution made.
+
+=head2 Fiddling with the Perl stack from your C program
+
+When trying to explain stacks, most computer science textbooks mumble
+something about spring-loaded columns of cafeteria plates: the last
+thing you pushed on the stack is the first thing you pop off. That'll
+do for our purposes: your C program will push some arguments onto "the Perl
+stack", shut its eyes while some magic happens, and then pop the
+results--the return value of your Perl subroutine--off the stack.
+
+First you'll need to know how to convert between C types and Perl
+types, with newSViv() and sv_setnv() and newAV() and all their
+friends. They're described in L<perlguts>.
+
+Then you'll need to know how to manipulate the Perl stack. That's
+described in L<perlcall>.
+
+Once you've understood those, embedding Perl in C is easy.
+
+Because C has no builtin function for integer exponentiation, let's
+make Perl's ** operator available to it (this is less useful than it
+sounds, because Perl implements ** with C's I<pow()> function). First
+I'll create a stub exponentiation function in I<power.pl>:
+
+ sub expo {
+ my ($a, $b) = @_;
+ return $a ** $b;
+ }
+
+Now I'll create a C program, I<power.c>, with a function
+I<PerlPower()> that contains all the perlguts necessary to push the
+two arguments into I<expo()> and to pop the return value out. Take a
+deep breath...
+
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ static PerlInterpreter *my_perl;
+
+ static void
+ PerlPower(int a, int b)
+ {
+ dSP; /* initialize stack pointer */
+ ENTER; /* everything created after here */
+ SAVETMPS; /* ...is a temporary variable. */
+ PUSHMARK(SP); /* remember the stack pointer */
+ XPUSHs(sv_2mortal(newSViv(a))); /* push the base onto the stack */
+ XPUSHs(sv_2mortal(newSViv(b))); /* push the exponent onto stack */
+ PUTBACK; /* make local stack pointer global */
+ perl_call_pv("expo", G_SCALAR); /* call the function */
+ SPAGAIN; /* refresh stack pointer */
+ /* pop the return value from stack */
+ printf ("%d to the %dth power is %d.\n", a, b, POPi);
+ PUTBACK;
+ FREETMPS; /* free that return value */
+ LEAVE; /* ...and the XPUSHed "mortal" args.*/
+ }
+
+ int main (int argc, char **argv, char **env)
+ {
+ char *my_argv[] = { "", "power.pl" };
+
+ my_perl = perl_alloc();
+ perl_construct( my_perl );
+
+ perl_parse(my_perl, NULL, 2, my_argv, (char **)NULL);
+ perl_run(my_perl);
+
+ PerlPower(3, 4); /*** Compute 3 ** 4 ***/
+
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ }
+
+
+
+Compile and run:
+
+ % cc -o power power.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+ % power
+ 3 to the 4th power is 81.
+
+=head2 Maintaining a persistent interpreter
+
+When developing interactive and/or potentially long-running
+applications, it's a good idea to maintain a persistent interpreter
+rather than allocating and constructing a new interpreter multiple
+times. The major reason is speed: since Perl will only be loaded into
+memory once.
+
+However, you have to be more cautious with namespace and variable
+scoping when using a persistent interpreter. In previous examples
+we've been using global variables in the default package C<main>. We
+knew exactly what code would be run, and assumed we could avoid
+variable collisions and outrageous symbol table growth.
+
+Let's say your application is a server that will occasionally run Perl
+code from some arbitrary file. Your server has no way of knowing what
+code it's going to run. Very dangerous.
+
+If the file is pulled in by C<perl_parse()>, compiled into a newly
+constructed interpreter, and subsequently cleaned out with
+C<perl_destruct()> afterwards, you're shielded from most namespace
+troubles.
+
+One way to avoid namespace collisions in this scenario is to translate
+the filename into a guaranteed-unique package name, and then compile
+the code into that package using L<perlfunc/eval>. In the example
+below, each file will only be compiled once. Or, the application
+might choose to clean out the symbol table associated with the file
+after it's no longer needed. Using L<perlcall/perl_call_argv>, We'll
+call the subroutine C<Embed::Persistent::eval_file> which lives in the
+file C<persistent.pl> and pass the filename and boolean cleanup/cache
+flag as arguments.
+
+Note that the process will continue to grow for each file that it
+uses. In addition, there might be C<AUTOLOAD>ed subroutines and other
+conditions that cause Perl's symbol table to grow. You might want to
+add some logic that keeps track of the process size, or restarts
+itself after a certain number of requests, to ensure that memory
+consumption is minimized. You'll also want to scope your variables
+with L<perlfunc/my> whenever possible.
+
+
+ package Embed::Persistent;
+ #persistent.pl
+
+ use strict;
+ use vars '%Cache';
+ use Symbol qw(delete_package);
+
+ sub valid_package_name {
+ my($string) = @_;
+ $string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
+ # second pass only for words starting with a digit
+ $string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
+
+ # Dress it up as a real package name
+ $string =~ s|/|::|g;
+ return "Embed" . $string;
+ }
+
+ sub eval_file {
+ my($filename, $delete) = @_;
+ my $package = valid_package_name($filename);
+ my $mtime = -M $filename;
+ if(defined $Cache{$package}{mtime}
+ &&
+ $Cache{$package}{mtime} <= $mtime)
+ {
+ # we have compiled this subroutine already,
+ # it has not been updated on disk, nothing left to do
+ print STDERR "already compiled $package->handler\n";
+ }
+ else {
+ local *FH;
+ open FH, $filename or die "open '$filename' $!";
+ local($/) = undef;
+ my $sub = <FH>;
+ close FH;
+
+ #wrap the code into a subroutine inside our unique package
+ my $eval = qq{package $package; sub handler { $sub; }};
+ {
+ # hide our variables within this block
+ my($filename,$mtime,$package,$sub);
+ eval $eval;
+ }
+ die $@ if $@;
+
+ #cache it unless we're cleaning out each time
+ $Cache{$package}{mtime} = $mtime unless $delete;
+ }
+
+ eval {$package->handler;};
+ die $@ if $@;
+
+ delete_package($package) if $delete;
+
+ #take a look if you want
+ #print Devel::Symdump->rnew($package)->as_string, $/;
+ }
+
+ 1;
+
+ __END__
+
+ /* persistent.c */
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ /* 1 = clean out filename's symbol table after each request, 0 = don't */
+ #ifndef DO_CLEAN
+ #define DO_CLEAN 0
+ #endif
+
+ static PerlInterpreter *perl = NULL;
+
+ int
+ main(int argc, char **argv, char **env)
+ {
+ char *embedding[] = { "", "persistent.pl" };
+ char *args[] = { "", DO_CLEAN, NULL };
+ char filename [1024];
+ int exitstatus = 0;
+
+ if((perl = perl_alloc()) == NULL) {
+ fprintf(stderr, "no memory!");
+ exit(1);
+ }
+ perl_construct(perl);
+
+ exitstatus = perl_parse(perl, NULL, 2, embedding, NULL);
+
+ if(!exitstatus) {
+ exitstatus = perl_run(perl);
+
+ while(printf("Enter file name: ") && gets(filename)) {
+
+ /* call the subroutine, passing it the filename as an argument */
+ args[0] = filename;
+ perl_call_argv("Embed::Persistent::eval_file",
+ G_DISCARD | G_EVAL, args);
+
+ /* check $@ */
+ if(SvTRUE(ERRSV))
+ fprintf(stderr, "eval error: %s\n", SvPV(ERRSV,PL_na));
+ }
+ }
+
+ PL_perl_destruct_level = 0;
+ perl_destruct(perl);
+ perl_free(perl);
+ exit(exitstatus);
+ }
+
+Now compile:
+
+ % cc -o persistent persistent.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+Here's a example script file:
+
+ #test.pl
+ my $string = "hello";
+ foo($string);
+
+ sub foo {
+ print "foo says: @_\n";
+ }
+
+Now run:
+
+ % persistent
+ Enter file name: test.pl
+ foo says: hello
+ Enter file name: test.pl
+ already compiled Embed::test_2epl->handler
+ foo says: hello
+ Enter file name: ^C
+
+=head2 Maintaining multiple interpreter instances
+
+Some rare applications will need to create more than one interpreter
+during a session. Such an application might sporadically decide to
+release any resources associated with the interpreter.
+
+The program must take care to ensure that this takes place I<before>
+the next interpreter is constructed. By default, the global variable
+C<PL_perl_destruct_level> is set to C<0>, since extra cleaning isn't
+needed when a program has only one interpreter.
+
+Setting C<PL_perl_destruct_level> to C<1> makes everything squeaky clean:
+
+ PL_perl_destruct_level = 1;
+
+ while(1) {
+ ...
+ /* reset global variables here with PL_perl_destruct_level = 1 */
+ perl_construct(my_perl);
+ ...
+ /* clean and reset _everything_ during perl_destruct */
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ ...
+ /* let's go do it again! */
+ }
+
+When I<perl_destruct()> is called, the interpreter's syntax parse tree
+and symbol tables are cleaned up, and global variables are reset.
+
+Now suppose we have more than one interpreter instance running at the
+same time. This is feasible, but only if you used the
+C<-DMULTIPLICITY> flag when building Perl. By default, that sets
+C<PL_perl_destruct_level> to C<1>.
+
+Let's give it a try:
+
+
+ #include <EXTERN.h>
+ #include <perl.h>
+
+ /* we're going to embed two interpreters */
+ /* we're going to embed two interpreters */
+
+ #define SAY_HELLO "-e", "print qq(Hi, I'm $^X\n)"
+
+ int main(int argc, char **argv, char **env)
+ {
+ PerlInterpreter
+ *one_perl = perl_alloc(),
+ *two_perl = perl_alloc();
+ char *one_args[] = { "one_perl", SAY_HELLO };
+ char *two_args[] = { "two_perl", SAY_HELLO };
+
+ perl_construct(one_perl);
+ perl_construct(two_perl);
+
+ perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
+ perl_parse(two_perl, NULL, 3, two_args, (char **)NULL);
+
+ perl_run(one_perl);
+ perl_run(two_perl);
+
+ perl_destruct(one_perl);
+ perl_destruct(two_perl);
+
+ perl_free(one_perl);
+ perl_free(two_perl);
+ }
+
+
+Compile as usual:
+
+ % cc -o multiplicity multiplicity.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+Run it, Run it:
+
+ % multiplicity
+ Hi, I'm one_perl
+ Hi, I'm two_perl
+
+=head2 Using Perl modules, which themselves use C libraries, from your C program
+
+If you've played with the examples above and tried to embed a script
+that I<use()>s a Perl module (such as I<Socket>) which itself uses a C or C++ library,
+this probably happened:
+
+
+ Can't load module Socket, dynamic loading not available in this perl.
+ (You may need to build a new perl executable which either supports
+ dynamic loading or has the Socket module statically linked into it.)
+
+
+What's wrong?
+
+Your interpreter doesn't know how to communicate with these extensions
+on its own. A little glue will help. Up until now you've been
+calling I<perl_parse()>, handing it NULL for the second argument:
+
+ perl_parse(my_perl, NULL, argc, my_argv, NULL);
+
+That's where the glue code can be inserted to create the initial contact between
+Perl and linked C/C++ routines. Let's take a look some pieces of I<perlmain.c>
+to see how Perl does this:
+
+
+ #ifdef __cplusplus
+ # define EXTERN_C extern "C"
+ #else
+ # define EXTERN_C extern
+ #endif
+
+ static void xs_init _((void));
+
+ EXTERN_C void boot_DynaLoader _((CV* cv));
+ EXTERN_C void boot_Socket _((CV* cv));
+
+
+ EXTERN_C void
+ xs_init()
+ {
+ char *file = __FILE__;
+ /* DynaLoader is a special case */
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+ newXS("Socket::bootstrap", boot_Socket, file);
+ }
+
+Simply put: for each extension linked with your Perl executable
+(determined during its initial configuration on your
+computer or when adding a new extension),
+a Perl subroutine is created to incorporate the extension's
+routines. Normally, that subroutine is named
+I<Module::bootstrap()> and is invoked when you say I<use Module>. In
+turn, this hooks into an XSUB, I<boot_Module>, which creates a Perl
+counterpart for each of the extension's XSUBs. Don't worry about this
+part; leave that to the I<xsubpp> and extension authors. If your
+extension is dynamically loaded, DynaLoader creates I<Module::bootstrap()>
+for you on the fly. In fact, if you have a working DynaLoader then there
+is rarely any need to link in any other extensions statically.
+
+
+Once you have this code, slap it into the second argument of I<perl_parse()>:
+
+
+ perl_parse(my_perl, xs_init, argc, my_argv, NULL);
+
+
+Then compile:
+
+ % cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+
+ % interp
+ use Socket;
+ use SomeDynamicallyLoadedModule;
+
+ print "Now I can use extensions!\n"'
+
+B<ExtUtils::Embed> can also automate writing the I<xs_init> glue code.
+
+ % perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c
+ % cc -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`
+ % cc -c interp.c `perl -MExtUtils::Embed -e ccopts`
+ % cc -o interp perlxsi.o interp.o `perl -MExtUtils::Embed -e ldopts`
+
+Consult L<perlxs> and L<perlguts> for more details.
+
+=head1 Embedding Perl under Win32
+
+At the time of this writing (5.004), there are two versions of Perl
+which run under Win32. (The two versions are merging in 5.005.)
+Interfacing to ActiveState's Perl library is quite different from the
+examples in this documentation, as significant changes were made to
+the internal Perl API. However, it is possible to embed ActiveState's
+Perl runtime. For details, see the Perl for Win32 FAQ at
+http://www.perl.com/perl/faq/win32/Perl_for_Win32_FAQ.html.
+
+With the "official" Perl version 5.004 or higher, all the examples
+within this documentation will compile and run untouched, although
+the build process is slightly different between Unix and Win32.
+
+For starters, backticks don't work under the Win32 native command shell.
+The ExtUtils::Embed kit on CPAN ships with a script called
+B<genmake>, which generates a simple makefile to build a program from
+a single C source file. It can be used like this:
+
+ C:\ExtUtils-Embed\eg> perl genmake interp.c
+ C:\ExtUtils-Embed\eg> nmake
+ C:\ExtUtils-Embed\eg> interp -e "print qq{I'm embedded in Win32!\n}"
+
+You may wish to use a more robust environment such as the Microsoft
+Developer Studio. In this case, run this to generate perlxsi.c:
+
+ perl -MExtUtils::Embed -e xsinit
+
+Create a new project and Insert -> Files into Project: perlxsi.c,
+perl.lib, and your own source files, e.g. interp.c. Typically you'll
+find perl.lib in B<C:\perl\lib\CORE>, if not, you should see the
+B<CORE> directory relative to C<perl -V:archlib>. The studio will
+also need this path so it knows where to find Perl include files.
+This path can be added via the Tools -> Options -> Directories menu.
+Finally, select Build -> Build interp.exe and you're ready to go.
+
+=head1 MORAL
+
+You can sometimes I<write faster code> in C, but
+you can always I<write code faster> in Perl. Because you can use
+each from the other, combine them as you wish.
+
+
+=head1 AUTHOR
+
+Jon Orwant <F<orwant@tpj.com>> and Doug MacEachern
+<F<dougm@osf.org>>, with small contributions from Tim Bunce, Tom
+Christiansen, Guy Decoux, Hallvard Furuseth, Dov Grobgeld, and Ilya
+Zakharevich.
+
+Doug MacEachern has an article on embedding in Volume 1, Issue 4 of
+The Perl Journal (http://tpj.com). Doug is also the developer of the
+most widely-used Perl embedding: the mod_perl system
+(perl.apache.org), which embeds Perl in the Apache web server.
+Oracle, Binary Evolution, ActiveState, and Ben Sugars's nsapi_perl
+have used this model for Oracle, Netscape and Internet Information
+Server Perl plugins.
+
+July 22, 1998
+
+=head1 COPYRIGHT
+
+Copyright (C) 1995, 1996, 1997, 1998 Doug MacEachern and Jon Orwant. All
+Rights Reserved.
+
+Permission is granted to make and distribute verbatim copies of this
+documentation provided the copyright notice and this permission notice are
+preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+documentation under the conditions for verbatim copying, provided also
+that they are marked clearly as modified versions, that the authors'
+names and title are unchanged (though subtitles and additional
+authors' names may be added), and that the entire resulting derived
+work is distributed under the terms of a permission notice identical
+to this one.
+
+Permission is granted to copy and distribute translations of this
+documentation into another language, under the above conditions for
+modified versions.
diff --git a/contrib/perl5/pod/perlfaq.pod b/contrib/perl5/pod/perlfaq.pod
new file mode 100644
index 0000000..e6be112
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq.pod
@@ -0,0 +1,172 @@
+=head1 NAME
+
+perlfaq - frequently asked questions about Perl ($Date: 1998/08/05 12:09:32 $)
+
+=head1 DESCRIPTION
+
+This document is structured into the following sections:
+
+=over
+
+=item perlfaq: Structural overview of the FAQ.
+
+This document.
+
+=item L<perlfaq1>: General Questions About Perl
+
+Very general, high-level information about Perl.
+
+=item L<perlfaq2>: Obtaining and Learning about Perl
+
+Where to find source and documentation to Perl, support,
+and related matters.
+
+=item L<perlfaq3>: Programming Tools
+
+Programmer tools and programming support.
+
+=item L<perlfaq4>: Data Manipulation
+
+Manipulating numbers, dates, strings, arrays, hashes, and
+miscellaneous data issues.
+
+=item L<perlfaq5>: Files and Formats
+
+I/O and the "f" issues: filehandles, flushing, formats and footers.
+
+=item L<perlfaq6>: Regexps
+
+Pattern matching and regular expressions.
+
+=item L<perlfaq7>: General Perl Language Issues
+
+General Perl language issues that don't clearly fit into any of the
+other sections.
+
+=item L<perlfaq8>: System Interaction
+
+Interprocess communication (IPC), control over the user-interface
+(keyboard, screen and pointing devices).
+
+=item L<perlfaq9>: Networking
+
+Networking, the Internet, and a few on the web.
+
+=back
+
+=head2 Where to get this document
+
+This document is posted regularly to comp.lang.perl.announce and
+several other related newsgroups. It is available in a variety of
+formats from CPAN in the /CPAN/doc/FAQs/FAQ/ directory, or on the web
+at http://www.perl.com/perl/faq/ .
+
+=head2 How to contribute to this document
+
+You may mail corrections, additions, and suggestions to
+perlfaq-suggestions@perl.com . This alias should not be
+used to I<ask> FAQs. It's for fixing the current FAQ.
+
+=head2 What will happen if you mail your Perl programming problems to the authors
+
+Your questions will probably go unread, unless they're suggestions of
+new questions to add to the FAQ, in which case they should have gone
+to the perlfaq-suggestions@perl.com instead.
+
+You should have read section 2 of this faq. There you would have
+learned that comp.lang.perl.misc is the appropriate place to go for
+free advice. If your question is really important and you require a
+prompt and correct answer, you should hire a consultant.
+
+=head1 Credits
+
+When I first began the Perl FAQ in the late 80s, I never realized it
+would have grown to over a hundred pages, nor that Perl would ever become
+so popular and widespread. This document could not have been written
+without the tremendous help provided by Larry Wall and the rest of the
+Perl Porters.
+
+=head1 Author and Copyright Information
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+=head2 Bundled Distributions
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in these files
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
+
+=head2 Disclaimer
+
+This information is offered in good faith and in the hope that it may
+be of use, but is not guaranteed to be correct, up to date, or suitable
+for any particular purpose whatsoever. The authors accept no liability
+in respect of this information or its use.
+
+=head1 Changes
+
+=over 4
+
+=item 22/June/98
+
+Significant changes throughout in preparation for the 5.005
+release.
+
+=item 24/April/97
+
+Style and whitespace changes from Chip, new question on reading one
+character at a time from a terminal using POSIX from Tom.
+
+=item 23/April/97
+
+Added http://www.oasis.leo.org/perl/ to L<perlfaq2>. Style fix to
+L<perlfaq3>. Added floating point precision, fixed complex number
+arithmetic, cross-references, caveat for Text::Wrap, alternative
+answer for initial capitalizing, fixed incorrect regexp, added example
+of Tie::IxHash to L<perlfaq4>. Added example of passing and storing
+filehandles, added commify to L<perlfaq5>. Restored variable suicide,
+and added mass commenting to L<perlfaq7>. Added Net::Telnet, fixed
+backticks, added reader/writer pair to telnet question, added FindBin,
+grouped module questions together in L<perlfaq8>. Expanded caveats
+for the simple URL extractor, gave LWP example, added CGI security
+question, expanded on the mail address answer in L<perlfaq9>.
+
+=item 25/March/97
+
+Added more info to the binary distribution section of L<perlfaq2>.
+Added Net::Telnet to L<perlfaq6>. Fixed typos in L<perlfaq8>. Added
+mail sending example to L<perlfaq9>. Added Merlyn's columns to
+L<perlfaq2>.
+
+=item 18/March/97
+
+Added the DATE to the NAME section, indicating which sections have
+changed.
+
+Mentioned SIGPIPE and L<perlipc> in the forking open answer in
+L<perlfaq8>.
+
+Fixed description of a regular expression in L<perlfaq4>.
+
+=item 17/March/97 Version
+
+Various typos fixed throughout.
+
+Added new question on Perl BNF on L<perlfaq7>.
+
+=item Initial Release: 11/March/97
+
+This is the initial release of version 3 of the FAQ; consequently there
+have been no changes since its initial release.
+
+=back
diff --git a/contrib/perl5/pod/perlfaq1.pod b/contrib/perl5/pod/perlfaq1.pod
new file mode 100644
index 0000000..5a95f19
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq1.pod
@@ -0,0 +1,268 @@
+=head1 NAME
+
+perlfaq1 - General Questions About Perl ($Revision: 1.15 $, $Date: 1998/08/05 11:52:24 $)
+
+=head1 DESCRIPTION
+
+This section of the FAQ answers very general, high-level questions
+about Perl.
+
+=head2 What is Perl?
+
+Perl is a high-level programming language with an eclectic heritage
+written by Larry Wall and a cast of thousands. It derives from the
+ubiquitous C programming language and to a lesser extent from sed,
+awk, the Unix shell, and at least a dozen other tools and languages.
+Perl's process, file, and text manipulation facilities make it
+particularly well-suited for tasks involving quick prototyping, system
+utilities, software tools, system management tasks, database access,
+graphical programming, networking, and world wide web programming.
+These strengths make it especially popular with system administrators
+and CGI script authors, but mathematicians, geneticists, journalists,
+and even managers also use Perl. Maybe you should, too.
+
+=head2 Who supports Perl? Who develops it? Why is it free?
+
+The original culture of the pre-populist Internet and the deeply-held
+beliefs of Perl's author, Larry Wall, gave rise to the free and open
+distribution policy of perl. Perl is supported by its users. The
+core, the standard Perl library, the optional modules, and the
+documentation you're reading now were all written by volunteers. See
+the personal note at the end of the README file in the perl source
+distribution for more details. See L<perlhist> (new as of 5.005)
+for Perl's milestone releases.
+
+In particular, the core development team (known as the Perl
+Porters) are a rag-tag band of highly altruistic individuals
+committed to producing better software for free than you
+could hope to purchase for money. You may snoop on pending
+developments via news://genetics.upenn.edu/perl.porters-gw/ and
+http://www.frii.com/~gnat/perl/porters/summary.html.
+
+While the GNU project includes Perl in its distributions, there's no
+such thing as "GNU Perl". Perl is not produced nor maintained by the
+Free Software Foundation. Perl's licensing terms are also more open
+than GNU software's tend to be.
+
+You can get commercial support of Perl if you wish, although for most
+users the informal support will more than suffice. See the answer to
+"Where can I buy a commercial version of perl?" for more information.
+
+=head2 Which version of Perl should I use?
+
+You should definitely use version 5. Version 4 is old, limited, and
+no longer maintained; its last patch (4.036) was in 1992. The most
+recent production release is 5.005_01. Further references to the Perl
+language in this document refer to this production release unless
+otherwise specified. There may be one or more official bug fixes for
+5.005_01 by the time you read this, and also perhaps some experimental
+versions on the way to the next release.
+
+=head2 What are perl4 and perl5?
+
+Perl4 and perl5 are informal names for different versions of the Perl
+programming language. It's easier to say "perl5" than it is to say
+"the 5(.004) release of Perl", but some people have interpreted this
+to mean there's a language called "perl5", which isn't the case.
+Perl5 is merely the popular name for the fifth major release (October 1994),
+while perl4 was the fourth major release (March 1991). There was also a
+perl1 (in January 1988), a perl2 (June 1988), and a perl3 (October 1989).
+
+The 5.0 release is, essentially, a complete rewrite of the perl source
+code from the ground up. It has been modularized, object-oriented,
+tweaked, trimmed, and optimized until it almost doesn't look like the
+old code. However, the interface is mostly the same, and compatibility
+with previous releases is very high.
+
+To avoid the "what language is perl5?" confusion, some people prefer to
+simply use "perl" to refer to the latest version of perl and avoid using
+"perl5" altogether. It's not really that big a deal, though.
+
+See L<perlhist> for a history of Perl revisions.
+
+=head2 How stable is Perl?
+
+Production releases, which incorporate bug fixes and new functionality,
+are widely tested before release. Since the 5.000 release, we have
+averaged only about one production release per year.
+
+Larry and the Perl development team occasionally make changes to the
+internal core of the language, but all possible efforts are made toward
+backward compatibility. While not quite all perl4 scripts run flawlessly
+under perl5, an update to perl should nearly never invalidate a program
+written for an earlier version of perl (barring accidental bug fixes
+and the rare new keyword).
+
+=head2 Is Perl difficult to learn?
+
+No, Perl is easy to start learning -- and easy to keep learning. It looks
+like most programming languages you're likely to have experience
+with, so if you've ever written an C program, an awk script, a shell
+script, or even BASIC program, you're already part way there.
+
+Most tasks only require a small subset of the Perl language. One of
+the guiding mottos for Perl development is "there's more than one way
+to do it" (TMTOWTDI, sometimes pronounced "tim toady"). Perl's
+learning curve is therefore shallow (easy to learn) and long (there's
+a whole lot you can do if you really want).
+
+Finally, Perl is (frequently) an interpreted language. This means
+that you can write your programs and test them without an intermediate
+compilation step, allowing you to experiment and test/debug quickly
+and easily. This ease of experimentation flattens the learning curve
+even more.
+
+Things that make Perl easier to learn: Unix experience, almost any kind
+of programming experience, an understanding of regular expressions, and
+the ability to understand other people's code. If there's something you
+need to do, then it's probably already been done, and a working example is
+usually available for free. Don't forget the new perl modules, either.
+They're discussed in Part 3 of this FAQ, along with the CPAN, which is
+discussed in Part 2.
+
+=head2 How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?
+
+Favorably in some areas, unfavorably in others. Precisely which areas
+are good and bad is often a personal choice, so asking this question
+on Usenet runs a strong risk of starting an unproductive Holy War.
+
+Probably the best thing to do is try to write equivalent code to do a
+set of tasks. These languages have their own newsgroups in which you
+can learn about (but hopefully not argue about) them.
+
+=head2 Can I do [task] in Perl?
+
+Perl is flexible and extensible enough for you to use on almost any
+task, from one-line file-processing tasks to complex systems. For
+many people, Perl serves as a great replacement for shell scripting.
+For others, it serves as a convenient, high-level replacement for most
+of what they'd program in low-level languages like C or C++. It's
+ultimately up to you (and possibly your management ...) which tasks
+you'll use Perl for and which you won't.
+
+If you have a library that provides an API, you can make any component
+of it available as just another Perl function or variable using a Perl
+extension written in C or C++ and dynamically linked into your main
+perl interpreter. You can also go the other direction, and write your
+main program in C or C++, and then link in some Perl code on the fly,
+to create a powerful application.
+
+That said, there will always be small, focused, special-purpose
+languages dedicated to a specific problem domain that are simply more
+convenient for certain kinds of problems. Perl tries to be all things
+to all people, but nothing special to anyone. Examples of specialized
+languages that come to mind include prolog and matlab.
+
+=head2 When shouldn't I program in Perl?
+
+When your manager forbids it -- but do consider replacing them :-).
+
+Actually, one good reason is when you already have an existing
+application written in another language that's all done (and done
+well), or you have an application language specifically designed for a
+certain task (e.g. prolog, make).
+
+For various reasons, Perl is probably not well-suited for real-time
+embedded systems, low-level operating systems development work like
+device drivers or context-switching code, complex multithreaded
+shared-memory applications, or extremely large applications. You'll
+notice that perl is not itself written in Perl.
+
+The new native-code compiler for Perl may reduce the limitations given
+in the previous statement to some degree, but understand that Perl
+remains fundamentally a dynamically typed language, and not a
+statically typed one. You certainly won't be chastized if you don't
+trust nuclear-plant or brain-surgery monitoring code to it. And
+Larry will sleep easier, too -- Wall Street programs not
+withstanding. :-)
+
+=head2 What's the difference between "perl" and "Perl"?
+
+One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
+signify the language proper and "perl" the implementation of it,
+i.e. the current interpreter. Hence Tom's quip that "Nothing but perl
+can parse Perl." You may or may not choose to follow this usage. For
+example, parallelism means "awk and perl" and "Python and Perl" look
+ok, while "awk and Perl" and "Python and perl" do not.
+
+=head2 Is it a Perl program or a Perl script?
+
+It doesn't matter.
+
+In "standard terminology" a I<program> has been compiled to physical
+machine code once, and can then be be run multiple times, whereas a
+I<script> must be translated by a program each time it's used. Perl
+programs, however, are usually neither strictly compiled nor strictly
+interpreted. They can be compiled to a byte code form (something of a
+Perl virtual machine) or to completely different languages, like C or
+assembly language. You can't tell just by looking whether the source
+is destined for a pure interpreter, a parse-tree interpreter, a byte
+code interpreter, or a native-code compiler, so it's hard to give a
+definitive answer here.
+
+=head2 What is a JAPH?
+
+These are the "just another perl hacker" signatures that some people
+sign their postings with. About 100 of the of the earlier ones are
+available from http://www.perl.com/CPAN/misc/japh .
+
+=head2 Where can I get a list of Larry Wall witticisms?
+
+Over a hundred quips by Larry, from postings of his or source code,
+can be found at http://www.perl.com/CPAN/misc/lwall-quotes .
+
+=head2 How can I convince my sysadmin/supervisor/employees to use version (5/5.005/Perl instead of some other language)?
+
+If your manager or employees are wary of unsupported software, or
+software which doesn't officially ship with your Operating System, you
+might try to appeal to their self-interest. If programmers can be
+more productive using and utilizing Perl constructs, functionality,
+simplicity, and power, then the typical manager/supervisor/employee
+may be persuaded. Regarding using Perl in general, it's also
+sometimes helpful to point out that delivery times may be reduced
+using Perl, as compared to other languages.
+
+If you have a project which has a bottleneck, especially in terms of
+translation or testing, Perl almost certainly will provide a viable,
+and quick solution. In conjunction with any persuasion effort, you
+should not fail to point out that Perl is used, quite extensively, and
+with extremely reliable and valuable results, at many large computer
+software and/or hardware companies throughout the world. In fact,
+many Unix vendors now ship Perl by default, and support is usually
+just a news-posting away, if you can't find the answer in the
+I<comprehensive> documentation, including this FAQ.
+
+If you face reluctance to upgrading from an older version of perl,
+then point out that version 4 is utterly unmaintained and unsupported
+by the Perl Development Team. Another big sell for Perl5 is the large
+number of modules and extensions which greatly reduce development time
+for any given task. Also mention that the difference between version
+4 and version 5 of Perl is like the difference between awk and C++.
+(Well, ok, maybe not quite that distinct, but you get the idea.) If
+you want support and a reasonable guarantee that what you're
+developing will continue to work in the future, then you have to run
+the supported version. That probably means running the 5.005 release,
+although 5.004 isn't that bad (it's just one year and one release
+behind). Several important bugs were fixed from the 5.000 through
+5.003 versions, though, so try upgrading past them if possible.
+
+Of particular note is the massive bughunt for buffer overflow
+problems that went into the 5.004 release. All releases prior to
+that, including perl4, are considered insecure and should be upgraded
+as soon as possible.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as an integrated part of the Standard Distribution
+of Perl or of its documentation (printed or otherwise), this works is
+covered under Perl's Artistic Licence. For separate distributions of
+all or part of this FAQ outside of that, see L<perlfaq>.
+
+Irrespective of its distribution, all code examples here are public
+domain. You are permitted and encouraged to use this code and any
+derivatives thereof in your own programs for fun or for profit as you
+see fit. A simple comment in the code giving credit to the FAQ would
+be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq2.pod b/contrib/perl5/pod/perlfaq2.pod
new file mode 100644
index 0000000..918e936
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq2.pod
@@ -0,0 +1,499 @@
+=head1 NAME
+
+perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.25 $, $Date: 1998/08/05 11:47:25 $)
+
+=head1 DESCRIPTION
+
+This section of the FAQ answers questions about where to find
+source and documentation for Perl, support, and
+related matters.
+
+=head2 What machines support Perl? Where do I get it?
+
+The standard release of Perl (the one maintained by the perl
+development team) is distributed only in source code form. You
+can find this at http://www.perl.com/CPAN/src/latest.tar.gz, which
+in standard Internet format (a gzipped archive in POSIX tar format).
+
+Perl builds and runs on a bewildering number of platforms. Virtually
+all known and current Unix derivatives are supported (Perl's native
+platform), as are proprietary systems like VMS, DOS, OS/2, Windows,
+QNX, BeOS, and the Amiga. There are also the beginnings of support
+for MPE/iX.
+
+Binary distributions for some proprietary platforms, including
+Apple systems can be found http://www.perl.com/CPAN/ports/ directory.
+Because these are not part of the standard distribution, they may
+and in fact do differ from the base Perl port in a variety of ways.
+You'll have to check their respective release notes to see just
+what the differences are. These differences can be either positive
+(e.g. extensions for the features of the particular platform that
+are not supported in the source release of perl) or negative (e.g.
+might be based upon a less current source release of perl).
+
+A useful FAQ for Win32 Perl users is
+http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
+
+=head2 How can I get a binary version of Perl?
+
+If you don't have a C compiler because for whatever reasons your
+vendor did not include one with your system, the best thing to do is
+grab a binary version of gcc from the net and use that to compile perl
+with. CPAN only has binaries for systems that are terribly hard to
+get free compilers for, not for Unix systems.
+
+Your first stop should be http://www.perl.com/CPAN/ports to see what
+information is already available. A simple installation guide for
+MS-DOS is available at http://www.cs.ruu.nl/~piet/perl5dos.html , and
+similarly for Windows 3.1 at http://www.cs.ruu.nl/~piet/perlwin3.html
+.
+
+=head2 I don't have a C compiler on my system. How can I compile perl?
+
+Since you don't have a C compiler, you're doomed and your vendor
+should be sacrificed to the Sun gods. But that doesn't help you.
+
+What you need to do is get a binary version of gcc for your system
+first. Consult the Usenet FAQs for your operating system for
+information on where to get such a binary version.
+
+=head2 I copied the Perl binary from one machine to another, but scripts don't work.
+
+That's probably because you forgot libraries, or library paths differ.
+You really should build the whole distribution on the machine it will
+eventually live on, and then type C<make install>. Most other
+approaches are doomed to failure.
+
+One simple way to check that things are in the right place is to print out
+the hard-coded @INC which perl is looking for.
+
+ perl -e 'print join("\n",@INC)'
+
+If this command lists any paths which don't exist on your system, then you
+may need to move the appropriate libraries to these locations, or create
+symlinks, aliases, or shortcuts appropriately.
+
+You might also want to check out L<perlfaq8/"How do I keep my own
+module/library directory?">.
+
+=head2 I grabbed the sources and tried to compile but gdbm/dynamic loading/malloc/linking/... failed. How do I make it work?
+
+Read the F<INSTALL> file, which is part of the source distribution.
+It describes in detail how to cope with most idiosyncracies that the
+Configure script can't work around for any given system or
+architecture.
+
+=head2 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
+
+CPAN stands for Comprehensive Perl Archive Network, a huge archive
+replicated on dozens of machines all over the world. CPAN contains
+source code, non-native ports, documentation, scripts, and many
+third-party modules and extensions, designed for everything from
+commercial database interfaces to keyboard/screen control to web
+walking and CGI scripts. The master machine for CPAN is
+ftp://ftp.funet.fi/pub/languages/perl/CPAN/, but you can use the
+address http://www.perl.com/CPAN/CPAN.html to fetch a copy from a
+"site near you". See http://www.perl.com/CPAN (without a slash at the
+end) for how this process works.
+
+CPAN/path/... is a naming convention for files available on CPAN
+sites. CPAN indicates the base directory of a CPAN mirror, and the
+rest of the path is the path from that directory to the file. For
+instance, if you're using ftp://ftp.funet.fi/pub/languages/perl/CPAN
+as your CPAN site, the file CPAN/misc/japh file is downloadable as
+ftp://ftp.funet.fi/pub/languages/perl/CPAN/misc/japh .
+
+Considering that there are hundreds of existing modules in the
+archive, one probably exists to do nearly anything you can think of.
+Current categories under CPAN/modules/by-category/ include perl core
+modules; development support; operating system interfaces; networking,
+devices, and interprocess communication; data type utilities; database
+interfaces; user interfaces; interfaces to other languages; filenames,
+file systems, and file locking; internationalization and locale; world
+wide web support; server and daemon utilities; archiving and
+compression; image manipulation; mail and news; control flow
+utilities; filehandle and I/O; Microsoft Windows modules; and
+miscellaneous modules.
+
+=head2 Is there an ISO or ANSI certified version of Perl?
+
+Certainly not. Larry expects that he'll be certified before Perl is.
+
+=head2 Where can I get information on Perl?
+
+The complete Perl documentation is available with the perl distribution.
+If you have perl installed locally, you probably have the documentation
+installed as well: type C<man perl> if you're on a system resembling Unix.
+This will lead you to other important man pages, including how to set your
+$MANPATH. If you're not on a Unix system, access to the documentation
+will be different; for example, it might be only in HTML format. But all
+proper perl installations have fully-accessible documentation.
+
+You might also try C<perldoc perl> in case your system doesn't
+have a proper man command, or it's been misinstalled. If that doesn't
+work, try looking in /usr/local/lib/perl5/pod for documentation.
+
+If all else fails, consult the CPAN/doc directory, which contains the
+complete documentation in various formats, including native pod,
+troff, html, and plain text. There's also a web page at
+http://www.perl.com/perl/info/documentation.html that might help.
+
+Many good books have been written about Perl -- see the section below
+for more details.
+
+=head2 What are the Perl newsgroups on USENET? Where do I post questions?
+
+The now defunct comp.lang.perl newsgroup has been superseded by the
+following groups:
+
+ comp.lang.perl.announce Moderated announcement group
+ comp.lang.perl.misc Very busy group about Perl in general
+ comp.lang.perl.moderated Moderated discussion group
+ comp.lang.perl.modules Use and development of Perl modules
+ comp.lang.perl.tk Using Tk (and X) from Perl
+
+ comp.infosystems.www.authoring.cgi Writing CGI scripts for the Web.
+
+Actually, the moderated group hasn't passed yet, but we're
+keeping our fingers crossed.
+
+There is also USENET gateway to the mailing list used by the crack
+Perl development team (perl5-porters) at
+news://news.perl.com/perl.porters-gw/ .
+
+=head2 Where should I post source code?
+
+You should post source code to whichever group is most appropriate,
+but feel free to cross-post to comp.lang.perl.misc. If you want to
+cross-post to alt.sources, please make sure it follows their posting
+standards, including setting the Followup-To header line to NOT
+include alt.sources; see their FAQ for details.
+
+If you're just looking for software, first use Alta Vista, Deja News, and
+search CPAN. This is faster and more productive than just posting
+a request.
+
+=head2 Perl Books
+
+A number of books on Perl and/or CGI programming are available. A few of
+these are good, some are ok, but many aren't worth your money. Tom
+Christiansen maintains a list of these books, some with extensive
+reviews, at http://www.perl.com/perl/critiques/index.html.
+
+The incontestably definitive reference book on Perl, written by
+the creator of Perl, is now in its second edition:
+
+ Programming Perl (the "Camel Book"):
+ Authors: Larry Wall, Tom Christiansen, and Randal Schwartz
+ ISBN 1-56592-149-6 (English)
+ ISBN 4-89052-384-7 (Japanese)
+ URL: http://www.oreilly.com/catalog/pperl2/
+ (French, German, Italian, and Hungarian translations also
+ available)
+
+The companion volume to the Camel containing thousands
+of real-world examples, mini-tutorials, and complete programs
+(first premiering at the 1998 Perl Conference), is:
+
+ The Perl Cookbook (the "Ram Book"):
+ Authors: Tom Christiansen and Nathan Torkington,
+ with Foreword by Larry Wall
+ ISBN: 1-56592-243-3
+ URL: http://perl.oreilly.com/cookbook/
+
+If you're already a hard-core systems programmer, then the Camel Book
+might suffice for you to learn Perl from. But if you're not, check
+out:
+
+ Learning Perl (the "Llama Book"):
+ Authors: Randal Schwartz and Tom Christiansen
+ with Foreword by Larry Wall
+ ISBN: 1-56592-284-0
+ URL: http://www.oreilly.com/catalog/lperl2/
+
+Despite the picture at the URL above, the second edition of "Llama
+Book" really has a blue cover, and is updated for the 5.004 release
+of Perl. Various foreign language editions are available, including
+I<Learning Perl on Win32 Systems> (the Gecko Book).
+
+If you're not an accidental programmer, but a more serious and possibly
+even degreed computer scientist who doesn't need as much hand-holding as
+we try to provide in the Llama or its defurred cousin the Gecko, please
+check out the delightful book, I<Perl: The Programmer's Companion>,
+written by Nigel Chapman.
+
+You can order O'Reilly books directly from O'Reilly & Associates,
+1-800-998-9938. Local/overseas is 1-707-829-0515. If you can
+locate an O'Reilly order form, you can also fax to 1-707-829-0104.
+See http://www.ora.com/ on the Web.
+
+What follows is a list of the books that the FAQ authors found personally
+useful. Your mileage may (but, we hope, probably won't) vary.
+
+Recommended books on (or muchly on) Perl follow; those marked with
+a star may be ordered from O'Reilly.
+
+=over
+
+=item References
+
+ *Programming Perl
+ by Larry Wall, Tom Christiansen, and Randal L. Schwartz
+
+ *Perl 5 Desktop Reference
+ By Johan Vromans
+
+=item Tutorials
+
+ *Learning Perl [2nd edition]
+ by Randal L. Schwartz and Tom Christiansen
+ with foreword by Larry Wall
+
+ *Learning Perl on Win32 Systems
+ by Randal L. Schwartz, Erik Olson, and Tom Christiansen,
+ with foreword by Larry Wall
+
+ Perl: The Programmer's Companion
+ by Nigel Chapman
+
+ Cross-Platform Perl
+ by Eric F. Johnson
+
+ MacPerl: Power and Ease
+ by Vicki Brown and Chris Nandor, foreword by Matthias Neeracher
+
+=item Task-Oriented
+
+ *The Perl Cookbook
+ by Tom Christiansen and Nathan Torkington
+ with foreword by Larry Wall
+
+ Perl5 Interactive Course [2nd edition]
+ by Jon Orwant
+
+ *Advanced Perl Programming
+ by Sriram Srinivasan
+
+ Effective Perl Programming
+ by Joseph Hall
+
+=item Special Topics
+
+ *Mastering Regular Expressions
+ by Jeffrey Friedl
+
+ How to Set up and Maintain a World Wide Web Site [2nd edition]
+ by Lincoln Stein
+
+=back
+
+=head2 Perl in Magazines
+
+The first and only periodical devoted to All Things Perl, I<The
+Perl Journal> contains tutorials, demonstrations, case studies,
+announcements, contests, and much more. TPJ has columns on web
+development, databases, Win32 Perl, graphical programming, regular
+expressions, and networking, and sponsors the Obfuscated Perl
+Contest. It is published quarterly under the gentle hand of its
+editor, Jon Orwant. See http://www.tpj.com/ or send mail to
+subscriptions@tpj.com.
+
+Beyond this, magazines that frequently carry high-quality articles
+on Perl are I<Web Techniques> (see http://www.webtechniques.com/),
+I<Performance Computing> (http://www.performance-computing.com/), and Usenix's
+newsletter/magazine to its members, I<login:>, at http://www.usenix.org/.
+Randal's Web Technique's columns are available on the web at
+http://www.stonehenge.com/merlyn/WebTechniques/.
+
+=head2 Perl on the Net: FTP and WWW Access
+
+To get the best (and possibly cheapest) performance, pick a site from
+the list below and use it to grab the complete list of mirror sites.
+From there you can find the quickest site for you. Remember, the
+following list is I<not> the complete list of CPAN mirrors.
+
+ http://www.perl.com/CPAN (redirects to another mirror)
+ http://www.perl.org/CPAN
+ ftp://ftp.funet.fi/pub/languages/perl/CPAN/
+ http://www.cs.ruu.nl/pub/PERL/CPAN/
+ ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
+
+=head2 What mailing lists are there for perl?
+
+Most of the major modules (tk, CGI, libwww-perl) have their own
+mailing lists. Consult the documentation that came with the module for
+subscription information. The following are a list of mailing lists
+related to perl itself.
+
+If you subscribe to a mailing list, it behooves you to know how to
+unsubscribe from it. Strident pleas to the list itself to get you off
+will not be favorably received.
+
+=over 4
+
+=item MacPerl
+
+There is a mailing list for discussing Macintosh Perl. Contact
+"mac-perl-request@iis.ee.ethz.ch".
+
+Also see Matthias Neeracher's (the creator and maintainer of MacPerl)
+webpage at http://www.iis.ee.ethz.ch/~neeri/macintosh/perl.html for
+many links to interesting MacPerl sites, and the applications/MPW
+tools, precompiled.
+
+=item Perl5-Porters
+
+The core development team have a mailing list for discussing fixes and
+changes to the language. Send mail to
+"perl5-porters-request@perl.org" with help in the body of the message
+for information on subscribing.
+
+=item NTPerl
+
+This list is used to discuss issues involving Win32 Perl 5 (Windows NT
+and Win95). Subscribe by mailing ListManager@ActiveWare.com with the
+message body:
+
+ subscribe Perl-Win32-Users
+
+The list software, also written in perl, will automatically determine
+your address, and subscribe you automatically. To unsubscribe, mail
+the following in the message body to the same address like so:
+
+ unsubscribe Perl-Win32-Users
+
+You can also check http://www.activeware.com/ and select "Mailing Lists"
+to join or leave this list.
+
+=item Perl-Packrats
+
+Discussion related to archiving of perl materials, particularly the
+Comprehensive Perl Archive Network (CPAN). Subscribe by emailing
+majordomo@cis.ufl.edu:
+
+ subscribe perl-packrats
+
+The list software, also written in perl, will automatically determine
+your address, and subscribe you automatically. To unsubscribe, simple
+prepend the same command with an "un", and mail to the same address
+like so:
+
+ unsubscribe perl-packrats
+
+=back
+
+=head2 Archives of comp.lang.perl.misc
+
+Have you tried Deja News or Alta Vista?
+
+ftp.cis.ufl.edu:/pub/perl/comp.lang.perl.*/monthly has an almost
+complete collection dating back to 12/89 (missing 08/91 through
+12/93). They are kept as one large file for each month.
+
+You'll probably want more a sophisticated query and retrieval mechanism
+than a file listing, preferably one that allows you to retrieve
+articles using a fast-access indices, keyed on at least author, date,
+subject, thread (as in "trn") and probably keywords. The best
+solution the FAQ authors know of is the MH pick command, but it is
+very slow to select on 18000 articles.
+
+If you have, or know where can be found, the missing sections, please
+let perlfaq-suggestions@perl.com know.
+
+=head2 Where can I buy a commercial version of Perl?
+
+In a sense, Perl already I<is> commercial software: It has a licence
+that you can grab and carefully read to your manager. It is
+distributed in releases and comes in well-defined packages. There is a
+very large user community and an extensive literature. The
+comp.lang.perl.* newsgroups and several of the mailing lists provide
+free answers to your questions in near real-time. Perl has
+traditionally been supported by Larry, dozens of software designers
+and developers, and thousands of programmers, all working for free
+to create a useful thing to make life better for everyone.
+
+However, these answers may not suffice for managers who require a
+purchase order from a company whom they can sue should anything go
+wrong. Or maybe they need very serious hand-holding and contractual
+obligations. Shrink-wrapped CDs with perl on them are available from
+several sources if that will help.
+
+Or you can purchase a real support contract. Although Cygnus historically
+provided this service, they no longer sell support contracts for Perl.
+Instead, the Paul Ingram Group will be taking up the slack through The
+Perl Clinic. The following is a commercial from them:
+
+"Do you need professional support for Perl and/or Oraperl? Do you need
+a support contract with defined levels of service? Do you want to pay
+only for what you need?
+
+"The Paul Ingram Group has provided quality software development and
+support services to some of the world's largest corporations for ten
+years. We are now offering the same quality support services for Perl
+at The Perl Clinic. This service is led by Tim Bunce, an active perl
+porter since 1994 and well known as the author and maintainer of the
+DBI, DBD::Oracle, and Oraperl modules and author/co-maintainer of The
+Perl 5 Module List. We also offer Oracle users support for Perl5
+Oraperl and related modules (which Oracle is planning to ship as part
+of Oracle Web Server 3). 20% of the profit from our Perl support work
+will be donated to The Perl Institute."
+
+For more information, contact the The Perl Clinic:
+
+ Tel: +44 1483 424424
+ Fax: +44 1483 419419
+ Web: http://www.perl.co.uk/
+ Email: perl-support-info@perl.co.uk or Tim.Bunce@ig.co.uk
+
+See also www.perl.com for updates on training and support.
+
+=head2 Where do I send bug reports?
+
+If you are reporting a bug in the perl interpreter or the modules
+shipped with perl, use the I<perlbug> program in the perl distribution or
+mail your report to perlbug@perl.com.
+
+If you are posting a bug with a non-standard port (see the answer to
+"What platforms is Perl available for?"), a binary distribution, or a
+non-standard module (such as Tk, CGI, etc), then please see the
+documentation that came with it to determine the correct place to post
+bugs.
+
+Read the perlbug(1) man page (perl5.004 or later) for more information.
+
+=head2 What is perl.com? perl.org? The Perl Institute?
+
+The perl.com domain is managed by Tom Christiansen, who created it as a
+public service long before perl.org came about. Despite the name, it's a
+pretty non-commercial site meant to be a clearinghouse for information
+about all things Perlian, accepting no paid advertisements, bouncy
+happy gifs, or silly java applets on its pages. The Perl Home Page at
+http://www.perl.com/ is currently hosted on a T3 line courtesy of Songline
+Systems, a software-oriented subsidiary of O'Reilly and Associates.
+
+perl.org is the official vehicle for The Perl Institute. The motto of
+TPI is "helping people help Perl help people" (or something like
+that). It's a non-profit organization supporting development,
+documentation, and dissemination of perl.
+
+=head2 How do I learn about object-oriented Perl programming?
+
+L<perltoot> (distributed with 5.004 or later) is a good place to start.
+Also, L<perlobj>, L<perlref>, and L<perlmod> are useful references,
+while L<perlbot> has some excellent tips and tricks.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as an integrated part of the Standard Distribution
+of Perl or of its documentation (printed or otherwise), this works is
+covered under Perl's Artistic Licence. For separate distributions of
+all or part of this FAQ outside of that, see L<perlfaq>.
+
+Irrespective of its distribution, all code examples here are public
+domain. You are permitted and encouraged to use this code and any
+derivatives thereof in your own programs for fun or for profit as you
+see fit. A simple comment in the code giving credit to the FAQ would
+be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq3.pod b/contrib/perl5/pod/perlfaq3.pod
new file mode 100644
index 0000000..d06f2be
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq3.pod
@@ -0,0 +1,595 @@
+=head1 NAME
+
+perlfaq3 - Programming Tools ($Revision: 1.29 $, $Date: 1998/08/05 11:57:04 $)
+
+=head1 DESCRIPTION
+
+This section of the FAQ answers questions related to programmer tools
+and programming support.
+
+=head2 How do I do (anything)?
+
+Have you looked at CPAN (see L<perlfaq2>)? The chances are that
+someone has already written a module that can solve your problem.
+Have you read the appropriate man pages? Here's a brief index:
+
+ Basics perldata, perlvar, perlsyn, perlop, perlsub
+ Execution perlrun, perldebug
+ Functions perlfunc
+ Objects perlref, perlmod, perlobj, perltie
+ Data Structures perlref, perllol, perldsc
+ Modules perlmod, perlmodlib, perlsub
+ Regexps perlre, perlfunc, perlop, perllocale
+ Moving to perl5 perltrap, perl
+ Linking w/C perlxstut, perlxs, perlcall, perlguts, perlembed
+ Various http://www.perl.com/CPAN/doc/FMTEYEWTK/index.html
+ (not a man-page but still useful)
+
+L<perltoc> provides a crude table of contents for the perl man page set.
+
+=head2 How can I use Perl interactively?
+
+The typical approach uses the Perl debugger, described in the
+perldebug(1) man page, on an ``empty'' program, like this:
+
+ perl -de 42
+
+Now just type in any legal Perl code, and it will be immediately
+evaluated. You can also examine the symbol table, get stack
+backtraces, check variable values, set breakpoints, and other
+operations typically found in symbolic debuggers.
+
+=head2 Is there a Perl shell?
+
+In general, no. The Shell.pm module (distributed with perl) makes
+perl try commands which aren't part of the Perl language as shell
+commands. perlsh from the source distribution is simplistic and
+uninteresting, but may still be what you want.
+
+=head2 How do I debug my Perl programs?
+
+Have you used C<-w>? It enables warnings for dubious practices.
+
+Have you tried C<use strict>? It prevents you from using symbolic
+references, makes you predeclare any subroutines that you call as bare
+words, and (probably most importantly) forces you to predeclare your
+variables with C<my> or C<use vars>.
+
+Did you check the returns of each and every system call? The operating
+system (and thus Perl) tells you whether they worked or not, and if not
+why.
+
+ open(FH, "> /etc/cantwrite")
+ or die "Couldn't write to /etc/cantwrite: $!\n";
+
+Did you read L<perltrap>? It's full of gotchas for old and new Perl
+programmers, and even has sections for those of you who are upgrading
+from languages like I<awk> and I<C>.
+
+Have you tried the Perl debugger, described in L<perldebug>? You can
+step through your program and see what it's doing and thus work out
+why what it's doing isn't what it should be doing.
+
+=head2 How do I profile my Perl programs?
+
+You should get the Devel::DProf module from CPAN, and also use
+Benchmark.pm from the standard distribution. Benchmark lets you time
+specific portions of your code, while Devel::DProf gives detailed
+breakdowns of where your code spends its time.
+
+Here's a sample use of Benchmark:
+
+ use Benchmark;
+
+ @junk = `cat /etc/motd`;
+ $count = 10_000;
+
+ timethese($count, {
+ 'map' => sub { my @a = @junk;
+ map { s/a/b/ } @a;
+ return @a
+ },
+ 'for' => sub { my @a = @junk;
+ local $_;
+ for (@a) { s/a/b/ };
+ return @a },
+ });
+
+This is what it prints (on one machine--your results will be dependent
+on your hardware, operating system, and the load on your machine):
+
+ Benchmark: timing 10000 iterations of for, map...
+ for: 4 secs ( 3.97 usr 0.01 sys = 3.98 cpu)
+ map: 6 secs ( 4.97 usr 0.00 sys = 4.97 cpu)
+
+=head2 How do I cross-reference my Perl programs?
+
+The B::Xref module, shipped with the new, alpha-release Perl compiler
+(not the general distribution prior to the 5.005 release), can be used
+to generate cross-reference reports for Perl programs.
+
+ perl -MO=Xref[,OPTIONS] scriptname.plx
+
+=head2 Is there a pretty-printer (formatter) for Perl?
+
+There is no program that will reformat Perl as much as indent(1) does
+for C. The complex feedback between the scanner and the parser (this
+feedback is what confuses the vgrind and emacs programs) makes it
+challenging at best to write a stand-alone Perl parser.
+
+Of course, if you simply follow the guidelines in L<perlstyle>, you
+shouldn't need to reformat. The habit of formatting your code as you
+write it will help prevent bugs. Your editor can and should help you
+with this. The perl-mode for emacs can provide a remarkable amount of
+help with most (but not all) code, and even less programmable editors
+can provide significant assistance.
+
+If you are used to using I<vgrind> program for printing out nice code
+to a laser printer, you can take a stab at this using
+http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry, but the
+results are not particularly satisfying for sophisticated code.
+
+=head2 Is there a ctags for Perl?
+
+There's a simple one at
+http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz which may do
+the trick.
+
+=head2 Where can I get Perl macros for vi?
+
+For a complete version of Tom Christiansen's vi configuration file,
+see http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc,
+the standard benchmark file for vi emulators. This runs best with nvi,
+the current version of vi out of Berkeley, which incidentally can be built
+with an embedded Perl interpreter -- see http://www.perl.com/CPAN/src/misc.
+
+=head2 Where can I get perl-mode for emacs?
+
+Since Emacs version 19 patchlevel 22 or so, there have been both a
+perl-mode.el and support for the perl debugger built in. These should
+come with the standard Emacs 19 distribution.
+
+In the perl source directory, you'll find a directory called "emacs",
+which contains a cperl-mode that color-codes keywords, provides
+context-sensitive help, and other nifty things.
+
+Note that the perl-mode of emacs will have fits with C<"main'foo">
+(single quote), and mess up the indentation and hilighting. You
+should be using C<"main::foo"> in new Perl code anyway, so this
+shouldn't be an issue.
+
+=head2 How can I use curses with Perl?
+
+The Curses module from CPAN provides a dynamically loadable object
+module interface to a curses library. A small demo can be found at the
+directory http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/rep;
+this program repeats a command and updates the screen as needed, rendering
+B<rep ps axu> similar to B<top>.
+
+=head2 How can I use X or Tk with Perl?
+
+Tk is a completely Perl-based, object-oriented interface to the Tk toolkit
+that doesn't force you to use Tcl just to get at Tk. Sx is an interface
+to the Athena Widget set. Both are available from CPAN. See the
+directory http://www.perl.com/CPAN/modules/by-category/08_User_Interfaces/
+
+Invaluable for Perl/Tk programming are: the Perl/Tk FAQ at
+http://w4.lns.cornell.edu/~pvhp/ptk/ptkTOC.html , the Perl/Tk Reference
+Guide available at
+http://www.perl.com/CPAN-local/authors/Stephen_O_Lidie/ , and the
+online manpages at
+http://www-users.cs.umn.edu/~amundson/perl/perltk/toc.html .
+
+=head2 How can I generate simple menus without using CGI or Tk?
+
+The http://www.perl.com/CPAN/authors/id/SKUNZ/perlmenu.v4.0.tar.gz
+module, which is curses-based, can help with this.
+
+=head2 What is undump?
+
+See the next questions.
+
+=head2 How can I make my Perl program run faster?
+
+The best way to do this is to come up with a better algorithm. This
+can often make a dramatic difference. Chapter 8 in the Camel has some
+efficiency tips in it you might want to look at. Jon Bentley's book
+``Programming Pearls'' (that's not a misspelling!) has some good tips
+on optimization, too. Advice on benchmarking boils down to: benchmark
+and profile to make sure you're optimizing the right part, look for
+better algorithms instead of microtuning your code, and when all else
+fails consider just buying faster hardware.
+
+A different approach is to autoload seldom-used Perl code. See the
+AutoSplit and AutoLoader modules in the standard distribution for
+that. Or you could locate the bottleneck and think about writing just
+that part in C, the way we used to take bottlenecks in C code and
+write them in assembler. Similar to rewriting in C is the use of
+modules that have critical sections written in C (for instance, the
+PDL module from CPAN).
+
+In some cases, it may be worth it to use the backend compiler to
+produce byte code (saving compilation time) or compile into C, which
+will certainly save compilation time and sometimes a small amount (but
+not much) execution time. See the question about compiling your Perl
+programs for more on the compiler--the wins aren't as obvious as you'd
+hope.
+
+If you're currently linking your perl executable to a shared I<libc.so>,
+you can often gain a 10-25% performance benefit by rebuilding it to
+link with a static libc.a instead. This will make a bigger perl
+executable, but your Perl programs (and programmers) may thank you for
+it. See the F<INSTALL> file in the source distribution for more
+information.
+
+Unsubstantiated reports allege that Perl interpreters that use sfio
+outperform those that don't (for IO intensive applications). To try
+this, see the F<INSTALL> file in the source distribution, especially
+the ``Selecting File IO mechanisms'' section.
+
+The undump program was an old attempt to speed up your Perl program
+by storing the already-compiled form to disk. This is no longer
+a viable option, as it only worked on a few architectures, and
+wasn't a good solution anyway.
+
+=head2 How can I make my Perl program take less memory?
+
+When it comes to time-space tradeoffs, Perl nearly always prefers to
+throw memory at a problem. Scalars in Perl use more memory than
+strings in C, arrays take more that, and hashes use even more. While
+there's still a lot to be done, recent releases have been addressing
+these issues. For example, as of 5.004, duplicate hash keys are
+shared amongst all hashes using them, so require no reallocation.
+
+In some cases, using substr() or vec() to simulate arrays can be
+highly beneficial. For example, an array of a thousand booleans will
+take at least 20,000 bytes of space, but it can be turned into one
+125-byte bit vector for a considerable memory savings. The standard
+Tie::SubstrHash module can also help for certain types of data
+structure. If you're working with specialist data structures
+(matrices, for instance) modules that implement these in C may use
+less memory than equivalent Perl modules.
+
+Another thing to try is learning whether your Perl was compiled with
+the system malloc or with Perl's builtin malloc. Whichever one it
+is, try using the other one and see whether this makes a difference.
+Information about malloc is in the F<INSTALL> file in the source
+distribution. You can find out whether you are using perl's malloc by
+typing C<perl -V:usemymalloc>.
+
+=head2 Is it unsafe to return a pointer to local data?
+
+No, Perl's garbage collection system takes care of this.
+
+ sub makeone {
+ my @a = ( 1 .. 10 );
+ return \@a;
+ }
+
+ for $i ( 1 .. 10 ) {
+ push @many, makeone();
+ }
+
+ print $many[4][5], "\n";
+
+ print "@many\n";
+
+=head2 How can I free an array or hash so my program shrinks?
+
+You can't. On most operating systems, memory allocated to a program
+can never be returned to the system. That's why long-running programs
+sometimes re-exec themselves. Some operating systems (notably, FreeBSD)
+allegedly reclaim large chunks of memory that is no longer used, but
+it doesn't appear to happen with Perl (yet). The Mac appears to be the
+only platform that will reliably (albeit, slowly) return memory to the OS.
+
+However, judicious use of my() on your variables will help make sure
+that they go out of scope so that Perl can free up their storage for
+use in other parts of your program. A global variable, of course, never
+goes out of scope, so you can't get its space automatically reclaimed,
+although undef()ing and/or delete()ing it will achieve the same effect.
+In general, memory allocation and de-allocation isn't something you can
+or should be worrying about much in Perl, but even this capability
+(preallocation of data types) is in the works.
+
+=head2 How can I make my CGI script more efficient?
+
+Beyond the normal measures described to make general Perl programs
+faster or smaller, a CGI program has additional issues. It may be run
+several times per second. Given that each time it runs it will need
+to be re-compiled and will often allocate a megabyte or more of system
+memory, this can be a killer. Compiling into C B<isn't going to help
+you> because the process start-up overhead is where the bottleneck is.
+
+There are two popular ways to avoid this overhead. One solution
+involves running the Apache HTTP server (available from
+http://www.apache.org/) with either of the mod_perl or mod_fastcgi
+plugin modules.
+
+With mod_perl and the Apache::Registry module (distributed with
+mod_perl), httpd will run with an embedded Perl interpreter which
+pre-compiles your script and then executes it within the same address
+space without forking. The Apache extension also gives Perl access to
+the internal server API, so modules written in Perl can do just about
+anything a module written in C can. For more on mod_perl, see
+http://perl.apache.org/
+
+With the FCGI module (from CPAN), a Perl executable compiled with sfio
+(see the F<INSTALL> file in the distribution) and the mod_fastcgi
+module (available from http://www.fastcgi.com/) each of your perl
+scripts becomes a permanent CGI daemon process.
+
+Both of these solutions can have far-reaching effects on your system
+and on the way you write your CGI scripts, so investigate them with
+care.
+
+See http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/ .
+
+A non-free, commerical product, ``The Velocity Engine for Perl'',
+(http://www.binevolve.com/ or http://www.binevolve.com/bine/vep) might
+also be worth looking at. It will allow you to increase the performance
+of your perl scripts, upto 25 times faster than normal CGI perl by
+running in persistent perl mode, or 4 to 5 times faster without any
+modification to your existing CGI scripts. Fully functional evaluation
+copies are available from the web site.
+
+=head2 How can I hide the source for my Perl program?
+
+Delete it. :-) Seriously, there are a number of (mostly
+unsatisfactory) solutions with varying levels of ``security''.
+
+First of all, however, you I<can't> take away read permission, because
+the source code has to be readable in order to be compiled and
+interpreted. (That doesn't mean that a CGI script's source is
+readable by people on the web, though, only by people with access to
+the filesystem) So you have to leave the permissions at the socially
+friendly 0755 level.
+
+Some people regard this as a security problem. If your program does
+insecure things, and relies on people not knowing how to exploit those
+insecurities, it is not secure. It is often possible for someone to
+determine the insecure things and exploit them without viewing the
+source. Security through obscurity, the name for hiding your bugs
+instead of fixing them, is little security indeed.
+
+You can try using encryption via source filters (Filter::* from CPAN),
+but crackers might be able to decrypt it. You can try using the byte
+code compiler and interpreter described below, but crackers might be
+able to de-compile it. You can try using the native-code compiler
+described below, but crackers might be able to disassemble it. These
+pose varying degrees of difficulty to people wanting to get at your
+code, but none can definitively conceal it (this is true of every
+language, not just Perl).
+
+If you're concerned about people profiting from your code, then the
+bottom line is that nothing but a restrictive licence will give you
+legal security. License your software and pepper it with threatening
+statements like ``This is unpublished proprietary software of XYZ Corp.
+Your access to it does not give you permission to use it blah blah
+blah.'' We are not lawyers, of course, so you should see a lawyer if
+you want to be sure your licence's wording will stand up in court.
+
+=head2 How can I compile my Perl program into byte code or C?
+
+Malcolm Beattie has written a multifunction backend compiler,
+available from CPAN, that can do both these things. It is included
+in the perl5.005 release, but is still considered experimental.
+This means it's fun to play with if you're a programmer but not
+really for people looking for turn-key solutions.
+
+Merely compiling into C does not in and of itself guarantee that your
+code will run very much faster. That's because except for lucky cases
+where a lot of native type inferencing is possible, the normal Perl
+run time system is still present and so your program will take just as
+long to run and be just as big. Most programs save little more than
+compilation time, leaving execution no more than 10-30% faster. A few
+rare programs actually benefit significantly (like several times
+faster), but this takes some tweaking of your code.
+
+You'll probably be astonished to learn that the current version of the
+compiler generates a compiled form of your script whose executable is
+just as big as the original perl executable, and then some. That's
+because as currently written, all programs are prepared for a full
+eval() statement. You can tremendously reduce this cost by building a
+shared I<libperl.so> library and linking against that. See the
+F<INSTALL> podfile in the perl source distribution for details. If
+you link your main perl binary with this, it will make it miniscule.
+For example, on one author's system, F</usr/bin/perl> is only 11k in
+size!
+
+In general, the compiler will do nothing to make a Perl program smaller,
+faster, more portable, or more secure. In fact, it will usually hurt
+all of those. The executable will be bigger, your VM system may take
+longer to load the whole thing, the binary is fragile and hard to fix,
+and compilation never stopped software piracy in the form of crackers,
+viruses, or bootleggers. The real advantage of the compiler is merely
+packaging, and once you see the size of what it makes (well, unless
+you use a shared I<libperl.so>), you'll probably want a complete
+Perl install anyway.
+
+=head2 How can I get C<#!perl> to work on [MS-DOS,NT,...]?
+
+For OS/2 just use
+
+ extproc perl -S -your_switches
+
+as the first line in C<*.cmd> file (C<-S> due to a bug in cmd.exe's
+`extproc' handling). For DOS one should first invent a corresponding
+batch file, and codify it in C<ALTERNATIVE_SHEBANG> (see the
+F<INSTALL> file in the source distribution for more information).
+
+The Win95/NT installation, when using the ActiveState port of Perl,
+will modify the Registry to associate the C<.pl> extension with the
+perl interpreter. If you install another port (Gurusaramy Sarathy's
+is the recommended Win95/NT port), or (eventually) build your own
+Win95/NT Perl using WinGCC, then you'll have to modify the Registry
+yourself.
+
+Macintosh perl scripts will have the the appropriate Creator and
+Type, so that double-clicking them will invoke the perl application.
+
+I<IMPORTANT!>: Whatever you do, PLEASE don't get frustrated, and just
+throw the perl interpreter into your cgi-bin directory, in order to
+get your scripts working for a web server. This is an EXTREMELY big
+security risk. Take the time to figure out how to do it correctly.
+
+=head2 Can I write useful perl programs on the command line?
+
+Yes. Read L<perlrun> for more information. Some examples follow.
+(These assume standard Unix shell quoting rules.)
+
+ # sum first and last fields
+ perl -lane 'print $F[0] + $F[-1]' *
+
+ # identify text files
+ perl -le 'for(@ARGV) {print if -f && -T _}' *
+
+ # remove (most) comments from C program
+ perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
+
+ # make file a month younger than today, defeating reaper daemons
+ perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
+
+ # find first unused uid
+ perl -le '$i++ while getpwuid($i); print $i'
+
+ # display reasonable manpath
+ echo $PATH | perl -nl -072 -e '
+ s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
+
+Ok, the last one was actually an obfuscated perl entry. :-)
+
+=head2 Why don't perl one-liners work on my DOS/Mac/VMS system?
+
+The problem is usually that the command interpreters on those systems
+have rather different ideas about quoting than the Unix shells under
+which the one-liners were created. On some systems, you may have to
+change single-quotes to double ones, which you must I<NOT> do on Unix
+or Plan9 systems. You might also have to change a single % to a %%.
+
+For example:
+
+ # Unix
+ perl -e 'print "Hello world\n"'
+
+ # DOS, etc.
+ perl -e "print \"Hello world\n\""
+
+ # Mac
+ print "Hello world\n"
+ (then Run "Myscript" or Shift-Command-R)
+
+ # VMS
+ perl -e "print ""Hello world\n"""
+
+The problem is that none of this is reliable: it depends on the
+command interpreter. Under Unix, the first two often work. Under DOS,
+it's entirely possible neither works. If 4DOS was the command shell,
+you'd probably have better luck like this:
+
+ perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
+
+Under the Mac, it depends which environment you are using. The MacPerl
+shell, or MPW, is much like Unix shells in its support for several
+quoting variants, except that it makes free use of the Mac's non-ASCII
+characters as control characters.
+
+There is no general solution to all of this. It is a mess, pure and
+simple. Sucks to be away from Unix, huh? :-)
+
+[Some of this answer was contributed by Kenneth Albanowski.]
+
+=head2 Where can I learn about CGI or Web programming in Perl?
+
+For modules, get the CGI or LWP modules from CPAN. For textbooks,
+see the two especially dedicated to web stuff in the question on
+books. For problems and questions related to the web, like ``Why
+do I get 500 Errors'' or ``Why doesn't it run from the browser right
+when it runs fine on the command line'', see these sources:
+
+ WWW Security FAQ
+ http://www.w3.org/Security/Faq/
+
+ Web FAQ
+ http://www.boutell.com/faq/
+
+ CGI FAQ
+ http://www.webthing.com/page.cgi/cgifaq
+
+ HTTP Spec
+ http://www.w3.org/pub/WWW/Protocols/HTTP/
+
+ HTML Spec
+ http://www.w3.org/TR/REC-html40/
+ http://www.w3.org/pub/WWW/MarkUp/
+
+ CGI Spec
+ http://www.w3.org/CGI/
+
+ CGI Security FAQ
+ http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
+
+
+=head2 Where can I learn about object-oriented Perl programming?
+
+L<perltoot> is a good place to start, and you can use L<perlobj> and
+L<perlbot> for reference. Perltoot didn't come out until the 5.004
+release, but you can get a copy (in pod, html, or postscript) from
+http://www.perl.com/CPAN/doc/FMTEYEWTK/ .
+
+=head2 Where can I learn about linking C with Perl? [h2xs, xsubpp]
+
+If you want to call C from Perl, start with L<perlxstut>,
+moving on to L<perlxs>, L<xsubpp>, and L<perlguts>. If you want to
+call Perl from C, then read L<perlembed>, L<perlcall>, and
+L<perlguts>. Don't forget that you can learn a lot from looking at
+how the authors of existing extension modules wrote their code and
+solved their problems.
+
+=head2 I've read perlembed, perlguts, etc., but I can't embed perl in
+my C program, what am I doing wrong?
+
+Download the ExtUtils::Embed kit from CPAN and run `make test'. If
+the tests pass, read the pods again and again and again. If they
+fail, see L<perlbug> and send a bugreport with the output of
+C<make test TEST_VERBOSE=1> along with C<perl -V>.
+
+=head2 When I tried to run my script, I got this message. What does it
+mean?
+
+L<perldiag> has a complete list of perl's error messages and warnings,
+with explanatory text. You can also use the splain program (distributed
+with perl) to explain the error messages:
+
+ perl program 2>diag.out
+ splain [-v] [-p] diag.out
+
+or change your program to explain the messages for you:
+
+ use diagnostics;
+
+or
+
+ use diagnostics -verbose;
+
+=head2 What's MakeMaker?
+
+This module (part of the standard perl distribution) is designed to
+write a Makefile for an extension module from a Makefile.PL. For more
+information, see L<ExtUtils::MakeMaker>.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as an integrated part of the Standard Distribution
+of Perl or of its documentation (printed or otherwise), this works is
+covered under Perl's Artistic Licence. For separate distributions of
+all or part of this FAQ outside of that, see L<perlfaq>.
+
+Irrespective of its distribution, all code examples here are public
+domain. You are permitted and encouraged to use this code and any
+derivatives thereof in your own programs for fun or for profit as you
+see fit. A simple comment in the code giving credit to the FAQ would
+be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq4.pod b/contrib/perl5/pod/perlfaq4.pod
new file mode 100644
index 0000000..633f5f1
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq4.pod
@@ -0,0 +1,1358 @@
+=head1 NAME
+
+perlfaq4 - Data Manipulation ($Revision: 1.26 $, $Date: 1998/08/05 12:04:00 $)
+
+=head1 DESCRIPTION
+
+The section of the FAQ answers question related to the manipulation
+of data as numbers, dates, strings, arrays, hashes, and miscellaneous
+data issues.
+
+=head1 Data: Numbers
+
+=head2 Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?
+
+The infinite set that a mathematician thinks of as the real numbers can
+only be approximate on a computer, since the computer only has a finite
+number of bits to store an infinite number of, um, numbers.
+
+Internally, your computer represents floating-point numbers in binary.
+Floating-point numbers read in from a file or appearing as literals
+in your program are converted from their decimal floating-point
+representation (eg, 19.95) to the internal binary representation.
+
+However, 19.95 can't be precisely represented as a binary
+floating-point number, just like 1/3 can't be exactly represented as a
+decimal floating-point number. The computer's binary representation
+of 19.95, therefore, isn't exactly 19.95.
+
+When a floating-point number gets printed, the binary floating-point
+representation is converted back to decimal. These decimal numbers
+are displayed in either the format you specify with printf(), or the
+current output format for numbers (see L<perlvar/"$#"> if you use
+print. C<$#> has a different default value in Perl5 than it did in
+Perl4. Changing C<$#> yourself is deprecated.
+
+This affects B<all> computer languages that represent decimal
+floating-point numbers in binary, not just Perl. Perl provides
+arbitrary-precision decimal numbers with the Math::BigFloat module
+(part of the standard Perl distribution), but mathematical operations
+are consequently slower.
+
+To get rid of the superfluous digits, just use a format (eg,
+C<printf("%.2f", 19.95)>) to get the required precision.
+See L<perlop/"Floating-point Arithmetic">.
+
+=head2 Why isn't my octal data interpreted correctly?
+
+Perl only understands octal and hex numbers as such when they occur
+as literals in your program. If they are read in from somewhere and
+assigned, no automatic conversion takes place. You must explicitly
+use oct() or hex() if you want the values converted. oct() interprets
+both hex ("0x350") numbers and octal ones ("0350" or even without the
+leading "0", like "377"), while hex() only converts hexadecimal ones,
+with or without a leading "0x", like "0x255", "3A", "ff", or "deadbeef".
+
+This problem shows up most often when people try using chmod(), mkdir(),
+umask(), or sysopen(), which all want permissions in octal.
+
+ chmod(644, $file); # WRONG -- perl -w catches this
+ chmod(0644, $file); # right
+
+=head2 Does perl have a round function? What about ceil() and floor()? Trig functions?
+
+Remember that int() merely truncates toward 0. For rounding to a
+certain number of digits, sprintf() or printf() is usually the easiest
+route.
+
+ printf("%.3f", 3.1415926535); # prints 3.142
+
+The POSIX module (part of the standard perl distribution) implements
+ceil(), floor(), and a number of other mathematical and trigonometric
+functions.
+
+ use POSIX;
+ $ceil = ceil(3.5); # 4
+ $floor = floor(3.5); # 3
+
+In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex
+module. With 5.004, the Math::Trig module (part of the standard perl
+distribution) implements the trigonometric functions. Internally it
+uses the Math::Complex module and some functions can break out from
+the real axis into the complex plane, for example the inverse sine of
+2.
+
+Rounding in financial applications can have serious implications, and
+the rounding method used should be specified precisely. In these
+cases, it probably pays not to trust whichever system rounding is
+being used by Perl, but to instead implement the rounding function you
+need yourself.
+
+=head2 How do I convert bits into ints?
+
+To turn a string of 1s and 0s like C<10110110> into a scalar containing
+its binary value, use the pack() function (documented in
+L<perlfunc/"pack">):
+
+ $decimal = pack('B8', '10110110');
+
+Here's an example of going the other way:
+
+ $binary_string = join('', unpack('B*', "\x29"));
+
+=head2 How do I multiply matrices?
+
+Use the Math::Matrix or Math::MatrixReal modules (available from CPAN)
+or the PDL extension (also available from CPAN).
+
+=head2 How do I perform an operation on a series of integers?
+
+To call a function on each element in an array, and collect the
+results, use:
+
+ @results = map { my_func($_) } @array;
+
+For example:
+
+ @triple = map { 3 * $_ } @single;
+
+To call a function on each element of an array, but ignore the
+results:
+
+ foreach $iterator (@array) {
+ &my_func($iterator);
+ }
+
+To call a function on each integer in a (small) range, you B<can> use:
+
+ @results = map { &my_func($_) } (5 .. 25);
+
+but you should be aware that the C<..> operator creates an array of
+all integers in the range. This can take a lot of memory for large
+ranges. Instead use:
+
+ @results = ();
+ for ($i=5; $i < 500_005; $i++) {
+ push(@results, &my_func($i));
+ }
+
+=head2 How can I output Roman numerals?
+
+Get the http://www.perl.com/CPAN/modules/by-module/Roman module.
+
+=head2 Why aren't my random numbers random?
+
+The short explanation is that you're getting pseudorandom numbers, not
+random ones, because computers are good at being predictable and bad
+at being random (despite appearances caused by bugs in your programs
+:-). A longer explanation is available on
+http://www.perl.com/CPAN/doc/FMTEYEWTK/random, courtesy of Tom
+Phoenix. John von Neumann said, ``Anyone who attempts to generate
+random numbers by deterministic means is, of course, living in a state
+of sin.''
+
+You should also check out the Math::TrulyRandom module from CPAN. It
+uses the imperfections in your system's timer to generate random
+numbers, but this takes quite a while. If you want a better
+pseudorandom generator than comes with your operating system, look at
+``Numerical Recipes in C'' at http://nr.harvard.edu/nr/bookc.html .
+
+=head1 Data: Dates
+
+=head2 How do I find the week-of-the-year/day-of-the-year?
+
+The day of the year is in the array returned by localtime() (see
+L<perlfunc/"localtime">):
+
+ $day_of_year = (localtime(time()))[7];
+
+or more legibly (in 5.004 or higher):
+
+ use Time::localtime;
+ $day_of_year = localtime(time())->yday;
+
+You can find the week of the year by dividing this by 7:
+
+ $week_of_year = int($day_of_year / 7);
+
+Of course, this believes that weeks start at zero. The Date::Calc
+module from CPAN has a lot of date calculation functions, including
+day of the year, week of the year, and so on. Note that not
+all business consider ``week 1'' to be the same; for example,
+American business often consider the first week with a Monday
+in it to be Work Week #1, despite ISO 8601, which consider
+WW1 to be the frist week with a Thursday in it.
+
+=head2 How can I compare two dates and find the difference?
+
+If you're storing your dates as epoch seconds then simply subtract one
+from the other. If you've got a structured date (distinct year, day,
+month, hour, minute, seconds values) then use one of the Date::Manip
+and Date::Calc modules from CPAN.
+
+=head2 How can I take a string and turn it into epoch seconds?
+
+If it's a regular enough string that it always has the same format,
+you can split it up and pass the parts to C<timelocal> in the standard
+Time::Local module. Otherwise, you should look into the Date::Calc
+and Date::Manip modules from CPAN.
+
+=head2 How can I find the Julian Day?
+
+Neither Date::Manip nor Date::Calc deal with Julian days. Instead,
+there is an example of Julian date calculation that should help you in
+http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/JulianDay.pm.gz
+.
+
+=head2 Does Perl have a year 2000 problem? Is Perl Y2K compliant?
+
+Short answer: No, Perl does not have a Year 2000 problem. Yes,
+Perl is Y2K compliant. The programmers you're hired to use it,
+however, probably are not.
+
+Long answer: Perl is just as Y2K compliant as your pencil--no more,
+and no less. The date and time functions supplied with perl (gmtime
+and localtime) supply adequate information to determine the year well
+beyond 2000 (2038 is when trouble strikes for 32-bit machines). The
+year returned by these functions when used in an array context is the
+year minus 1900. For years between 1910 and 1999 this I<happens> to
+be a 2-digit decimal number. To avoid the year 2000 problem simply do
+not treat the year as a 2-digit number. It isn't.
+
+When gmtime() and localtime() are used in scalar context they return
+a timestamp string that contains a fully-expanded year. For example,
+C<$timestamp = gmtime(1005613200)> sets $timestamp to "Tue Nov 13 01:00:00
+2001". There's no year 2000 problem here.
+
+That doesn't mean that Perl can't be used to create non-Y2K compliant
+programs. It can. But so can your pencil. It's the fault of the user,
+not the language. At the risk of inflaming the NRA: ``Perl doesn't
+break Y2K, people do.'' See http://language.perl.com/news/y2k.html for
+a longer exposition.
+
+=head1 Data: Strings
+
+=head2 How do I validate input?
+
+The answer to this question is usually a regular expression, perhaps
+with auxiliary logic. See the more specific questions (numbers, mail
+addresses, etc.) for details.
+
+=head2 How do I unescape a string?
+
+It depends just what you mean by ``escape''. URL escapes are dealt
+with in L<perlfaq9>. Shell escapes with the backslash (C<\>)
+character are removed with:
+
+ s/\\(.)/$1/g;
+
+This won't expand C<"\n"> or C<"\t"> or any other special escapes.
+
+=head2 How do I remove consecutive pairs of characters?
+
+To turn C<"abbcccd"> into C<"abccd">:
+
+ s/(.)\1/$1/g;
+
+=head2 How do I expand function calls in a string?
+
+This is documented in L<perlref>. In general, this is fraught with
+quoting and readability problems, but it is possible. To interpolate
+a subroutine call (in list context) into a string:
+
+ print "My sub returned @{[mysub(1,2,3)]} that time.\n";
+
+If you prefer scalar context, similar chicanery is also useful for
+arbitrary expressions:
+
+ print "That yields ${\($n + 5)} widgets\n";
+
+Version 5.004 of Perl had a bug that gave list context to the
+expression in C<${...}>, but this is fixed in version 5.005.
+
+See also ``How can I expand variables in text strings?'' in this
+section of the FAQ.
+
+=head2 How do I find matching/nesting anything?
+
+This isn't something that can be done in one regular expression, no
+matter how complicated. To find something between two single
+characters, a pattern like C</x([^x]*)x/> will get the intervening
+bits in $1. For multiple ones, then something more like
+C</alpha(.*?)omega/> would be needed. But none of these deals with
+nested patterns, nor can they. For that you'll have to write a
+parser.
+
+If you are serious about writing a parser, there are a number of
+modules or oddities that will make your life a lot easier. There is
+the CPAN module Parse::RecDescent, the standard module Text::Balanced,
+the byacc program, and Mark-Jason Dominus's excellent I<py> tool at
+http://www.plover.com/~mjd/perl/py/ .
+
+One simple destructive, inside-out approach that you might try is to
+pull out the smallest nesting parts one at a time:
+
+ while (s//BEGIN((?:(?!BEGIN)(?!END).)*)END/gs) {
+ # do something with $1
+ }
+
+=head2 How do I reverse a string?
+
+Use reverse() in scalar context, as documented in
+L<perlfunc/reverse>.
+
+ $reversed = reverse $string;
+
+=head2 How do I expand tabs in a string?
+
+You can do it yourself:
+
+ 1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
+
+Or you can just use the Text::Tabs module (part of the standard perl
+distribution).
+
+ use Text::Tabs;
+ @expanded_lines = expand(@lines_with_tabs);
+
+=head2 How do I reformat a paragraph?
+
+Use Text::Wrap (part of the standard perl distribution):
+
+ use Text::Wrap;
+ print wrap("\t", ' ', @paragraphs);
+
+The paragraphs you give to Text::Wrap should not contain embedded
+newlines. Text::Wrap doesn't justify the lines (flush-right).
+
+=head2 How can I access/change the first N letters of a string?
+
+There are many ways. If you just want to grab a copy, use
+substr():
+
+ $first_byte = substr($a, 0, 1);
+
+If you want to modify part of a string, the simplest way is often to
+use substr() as an lvalue:
+
+ substr($a, 0, 3) = "Tom";
+
+Although those with a pattern matching kind of thought process will
+likely prefer:
+
+ $a =~ s/^.../Tom/;
+
+=head2 How do I change the Nth occurrence of something?
+
+You have to keep track of N yourself. For example, let's say you want
+to change the fifth occurrence of C<"whoever"> or C<"whomever"> into
+C<"whosoever"> or C<"whomsoever">, case insensitively.
+
+ $count = 0;
+ s{((whom?)ever)}{
+ ++$count == 5 # is it the 5th?
+ ? "${2}soever" # yes, swap
+ : $1 # renege and leave it there
+ }igex;
+
+In the more general case, you can use the C</g> modifier in a C<while>
+loop, keeping count of matches.
+
+ $WANT = 3;
+ $count = 0;
+ while (/(\w+)\s+fish\b/gi) {
+ if (++$count == $WANT) {
+ print "The third fish is a $1 one.\n";
+ # Warning: don't `last' out of this loop
+ }
+ }
+
+That prints out: C<"The third fish is a red one."> You can also use a
+repetition count and repeated pattern like this:
+
+ /(?:\w+\s+fish\s+){2}(\w+)\s+fish/i;
+
+=head2 How can I count the number of occurrences of a substring within a string?
+
+There are a number of ways, with varying efficiency: If you want a
+count of a certain single character (X) within a string, you can use the
+C<tr///> function like so:
+
+ $string = "ThisXlineXhasXsomeXx'sXinXit":
+ $count = ($string =~ tr/X//);
+ print "There are $count X charcters in the string";
+
+This is fine if you are just looking for a single character. However,
+if you are trying to count multiple character substrings within a
+larger string, C<tr///> won't work. What you can do is wrap a while()
+loop around a global pattern match. For example, let's count negative
+integers:
+
+ $string = "-9 55 48 -2 23 -76 4 14 -44";
+ while ($string =~ /-\d+/g) { $count++ }
+ print "There are $count negative numbers in the string";
+
+=head2 How do I capitalize all the words on one line?
+
+To make the first letter of each word upper case:
+
+ $line =~ s/\b(\w)/\U$1/g;
+
+This has the strange effect of turning "C<don't do it>" into "C<Don'T
+Do It>". Sometimes you might want this, instead (Suggested by Brian
+Foy):
+
+ $string =~ s/ (
+ (^\w) #at the beginning of the line
+ | # or
+ (\s\w) #preceded by whitespace
+ )
+ /\U$1/xg;
+ $string =~ /([\w']+)/\u\L$1/g;
+
+To make the whole line upper case:
+
+ $line = uc($line);
+
+To force each word to be lower case, with the first letter upper case:
+
+ $line =~ s/(\w+)/\u\L$1/g;
+
+You can (and probably should) enable locale awareness of those
+characters by placing a C<use locale> pragma in your program.
+See L<perllocale> for endless details on locales.
+
+=head2 How can I split a [character] delimited string except when inside
+[character]? (Comma-separated files)
+
+Take the example case of trying to split a string that is comma-separated
+into its different fields. (We'll pretend you said comma-separated, not
+comma-delimited, which is different and almost never what you mean.) You
+can't use C<split(/,/)> because you shouldn't split if the comma is inside
+quotes. For example, take a data line like this:
+
+ SAR001,"","Cimetrix, Inc","Bob Smith","CAM",N,8,1,0,7,"Error, Core Dumped"
+
+Due to the restriction of the quotes, this is a fairly complex
+problem. Thankfully, we have Jeffrey Friedl, author of a highly
+recommended book on regular expressions, to handle these for us. He
+suggests (assuming your string is contained in $text):
+
+ @new = ();
+ push(@new, $+) while $text =~ m{
+ "([^\"\\]*(?:\\.[^\"\\]*)*)",? # groups the phrase inside the quotes
+ | ([^,]+),?
+ | ,
+ }gx;
+ push(@new, undef) if substr($text,-1,1) eq ',';
+
+If you want to represent quotation marks inside a
+quotation-mark-delimited field, escape them with backslashes (eg,
+C<"like \"this\"">. Unescaping them is a task addressed earlier in
+this section.
+
+Alternatively, the Text::ParseWords module (part of the standard perl
+distribution) lets you say:
+
+ use Text::ParseWords;
+ @new = quotewords(",", 0, $text);
+
+=head2 How do I strip blank space from the beginning/end of a string?
+
+Although the simplest approach would seem to be:
+
+ $string =~ s/^\s*(.*?)\s*$/$1/;
+
+This is unneccesarily slow, destructive, and fails with embedded newlines.
+It is much better faster to do this in two steps:
+
+ $string =~ s/^\s+//;
+ $string =~ s/\s+$//;
+
+Or more nicely written as:
+
+ for ($string) {
+ s/^\s+//;
+ s/\s+$//;
+ }
+
+This idiom takes advantage of the C<foreach> loop's aliasing
+behavior to factor out common code. You can do this
+on several strings at once, or arrays, or even the
+values of a hash if you use a slide:
+
+ # trim whitespace in the scalar, the array,
+ # and all the values in the hash
+ foreach ($scalar, @array, @hash{keys %hash}) {
+ s/^\s+//;
+ s/\s+$//;
+ }
+
+=head2 How do I extract selected columns from a string?
+
+Use substr() or unpack(), both documented in L<perlfunc>.
+If you prefer thinking in terms of columns instead of widths,
+you can use this kind of thing:
+
+ # determine the unpack format needed to split Linux ps output
+ # arguments are cut columns
+ my $fmt = cut2fmt(8, 14, 20, 26, 30, 34, 41, 47, 59, 63, 67, 72);
+
+ sub cut2fmt {
+ my(@positions) = @_;
+ my $template = '';
+ my $lastpos = 1;
+ for my $place (@positions) {
+ $template .= "A" . ($place - $lastpos) . " ";
+ $lastpos = $place;
+ }
+ $template .= "A*";
+ return $template;
+ }
+
+=head2 How do I find the soundex value of a string?
+
+Use the standard Text::Soundex module distributed with perl.
+
+=head2 How can I expand variables in text strings?
+
+Let's assume that you have a string like:
+
+ $text = 'this has a $foo in it and a $bar';
+
+If those were both global variables, then this would
+suffice:
+
+ $text =~ s/\$(\w+)/${$1}/g;
+
+But since they are probably lexicals, or at least, they could
+be, you'd have to do this:
+
+ $text =~ s/(\$\w+)/$1/eeg;
+ die if $@; # needed on /ee, not /e
+
+It's probably better in the general case to treat those
+variables as entries in some special hash. For example:
+
+ %user_defs = (
+ foo => 23,
+ bar => 19,
+ );
+ $text =~ s/\$(\w+)/$user_defs{$1}/g;
+
+See also ``How do I expand function calls in a string?'' in this section
+of the FAQ.
+
+=head2 What's wrong with always quoting "$vars"?
+
+The problem is that those double-quotes force stringification,
+coercing numbers and references into strings, even when you
+don't want them to be.
+
+If you get used to writing odd things like these:
+
+ print "$var"; # BAD
+ $new = "$old"; # BAD
+ somefunc("$var"); # BAD
+
+You'll be in trouble. Those should (in 99.8% of the cases) be
+the simpler and more direct:
+
+ print $var;
+ $new = $old;
+ somefunc($var);
+
+Otherwise, besides slowing you down, you're going to break code when
+the thing in the scalar is actually neither a string nor a number, but
+a reference:
+
+ func(\@array);
+ sub func {
+ my $aref = shift;
+ my $oref = "$aref"; # WRONG
+ }
+
+You can also get into subtle problems on those few operations in Perl
+that actually do care about the difference between a string and a
+number, such as the magical C<++> autoincrement operator or the
+syscall() function.
+
+Stringification also destroys arrays.
+
+ @lines = `command`;
+ print "@lines"; # WRONG - extra blanks
+ print @lines; # right
+
+=head2 Why don't my <<HERE documents work?
+
+Check for these three things:
+
+=over 4
+
+=item 1. There must be no space after the << part.
+
+=item 2. There (probably) should be a semicolon at the end.
+
+=item 3. You can't (easily) have any space in front of the tag.
+
+=back
+
+If you want to indent the text in the here document, you
+can do this:
+
+ # all in one
+ ($VAR = <<HERE_TARGET) =~ s/^\s+//gm;
+ your text
+ goes here
+ HERE_TARGET
+
+But the HERE_TARGET must still be flush against the margin.
+If you want that indented also, you'll have to quote
+in the indentation.
+
+ ($quote = <<' FINIS') =~ s/^\s+//gm;
+ ...we will have peace, when you and all your works have
+ perished--and the works of your dark master to whom you
+ would deliver us. You are a liar, Saruman, and a corrupter
+ of men's hearts. --Theoden in /usr/src/perl/taint.c
+ FINIS
+ $quote =~ s/\s*--/\n--/;
+
+A nice general-purpose fixer-upper function for indented here documents
+follows. It expects to be called with a here document as its argument.
+It looks to see whether each line begins with a common substring, and
+if so, strips that off. Otherwise, it takes the amount of leading
+white space found on the first line and removes that much off each
+subsequent line.
+
+ sub fix {
+ local $_ = shift;
+ my ($white, $leader); # common white space and common leading string
+ if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\1\2?.*\n)+$/) {
+ ($white, $leader) = ($2, quotemeta($1));
+ } else {
+ ($white, $leader) = (/^(\s+)/, '');
+ }
+ s/^\s*?$leader(?:$white)?//gm;
+ return $_;
+ }
+
+This works with leading special strings, dynamically determined:
+
+ $remember_the_main = fix<<' MAIN_INTERPRETER_LOOP';
+ @@@ int
+ @@@ runops() {
+ @@@ SAVEI32(runlevel);
+ @@@ runlevel++;
+ @@@ while ( op = (*op->op_ppaddr)() ) ;
+ @@@ TAINT_NOT;
+ @@@ return 0;
+ @@@ }
+ MAIN_INTERPRETER_LOOP
+
+Or with a fixed amount of leading white space, with remaining
+indentation correctly preserved:
+
+ $poem = fix<<EVER_ON_AND_ON;
+ Now far ahead the Road has gone,
+ And I must follow, if I can,
+ Pursuing it with eager feet,
+ Until it joins some larger way
+ Where many paths and errands meet.
+ And whither then? I cannot say.
+ --Bilbo in /usr/src/perl/pp_ctl.c
+ EVER_ON_AND_ON
+
+=head1 Data: Arrays
+
+=head2 What is the difference between $array[1] and @array[1]?
+
+The former is a scalar value, the latter an array slice, which makes
+it a list with one (scalar) value. You should use $ when you want a
+scalar value (most of the time) and @ when you want a list with one
+scalar value in it (very, very rarely; nearly never, in fact).
+
+Sometimes it doesn't make a difference, but sometimes it does.
+For example, compare:
+
+ $good[0] = `some program that outputs several lines`;
+
+with
+
+ @bad[0] = `same program that outputs several lines`;
+
+The B<-w> flag will warn you about these matters.
+
+=head2 How can I extract just the unique elements of an array?
+
+There are several possible ways, depending on whether the array is
+ordered and whether you wish to preserve the ordering.
+
+=over 4
+
+=item a) If @in is sorted, and you want @out to be sorted:
+(this assumes all true values in the array)
+
+ $prev = 'nonesuch';
+ @out = grep($_ ne $prev && ($prev = $_), @in);
+
+This is nice in that it doesn't use much extra memory, simulating
+uniq(1)'s behavior of removing only adjacent duplicates. It's less
+nice in that it won't work with false values like undef, 0, or "";
+"0 but true" is ok, though.
+
+=item b) If you don't know whether @in is sorted:
+
+ undef %saw;
+ @out = grep(!$saw{$_}++, @in);
+
+=item c) Like (b), but @in contains only small integers:
+
+ @out = grep(!$saw[$_]++, @in);
+
+=item d) A way to do (b) without any loops or greps:
+
+ undef %saw;
+ @saw{@in} = ();
+ @out = sort keys %saw; # remove sort if undesired
+
+=item e) Like (d), but @in contains only small positive integers:
+
+ undef @ary;
+ @ary[@in] = @in;
+ @out = @ary;
+
+=back
+
+=head2 How can I tell whether a list or array contains a certain element?
+
+Hearing the word "in" is an I<in>dication that you probably should have
+used a hash, not a list or array, to store your data. Hashes are
+designed to answer this question quickly and efficiently. Arrays aren't.
+
+That being said, there are several ways to approach this. If you
+are going to make this query many times over arbitrary string values,
+the fastest way is probably to invert the original array and keep an
+associative array lying about whose keys are the first array's values.
+
+ @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
+ undef %is_blue;
+ for (@blues) { $is_blue{$_} = 1 }
+
+Now you can check whether $is_blue{$some_color}. It might have been a
+good idea to keep the blues all in a hash in the first place.
+
+If the values are all small integers, you could use a simple indexed
+array. This kind of an array will take up less space:
+
+ @primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31);
+ undef @is_tiny_prime;
+ for (@primes) { $is_tiny_prime[$_] = 1; }
+
+Now you check whether $is_tiny_prime[$some_number].
+
+If the values in question are integers instead of strings, you can save
+quite a lot of space by using bit strings instead:
+
+ @articles = ( 1..10, 150..2000, 2017 );
+ undef $read;
+ for (@articles) { vec($read,$_,1) = 1 }
+
+Now check whether C<vec($read,$n,1)> is true for some C<$n>.
+
+Please do not use
+
+ $is_there = grep $_ eq $whatever, @array;
+
+or worse yet
+
+ $is_there = grep /$whatever/, @array;
+
+These are slow (checks every element even if the first matches),
+inefficient (same reason), and potentially buggy (what if there are
+regexp characters in $whatever?).
+
+=head2 How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
+
+Use a hash. Here's code to do both and more. It assumes that
+each element is unique in a given array:
+
+ @union = @intersection = @difference = ();
+ %count = ();
+ foreach $element (@array1, @array2) { $count{$element}++ }
+ foreach $element (keys %count) {
+ push @union, $element;
+ push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;
+ }
+
+=head2 How do I find the first array element for which a condition is true?
+
+You can use this if you care about the index:
+
+ for ($i=0; $i < @array; $i++) {
+ if ($array[$i] eq "Waldo") {
+ $found_index = $i;
+ last;
+ }
+ }
+
+Now C<$found_index> has what you want.
+
+=head2 How do I handle linked lists?
+
+In general, you usually don't need a linked list in Perl, since with
+regular arrays, you can push and pop or shift and unshift at either end,
+or you can use splice to add and/or remove arbitrary number of elements at
+arbitrary points. Both pop and shift are both O(1) operations on perl's
+dynamic arrays. In the absence of shifts and pops, push in general
+needs to reallocate on the order every log(N) times, and unshift will
+need to copy pointers each time.
+
+If you really, really wanted, you could use structures as described in
+L<perldsc> or L<perltoot> and do just what the algorithm book tells you
+to do.
+
+=head2 How do I handle circular lists?
+
+Circular lists could be handled in the traditional fashion with linked
+lists, or you could just do something like this with an array:
+
+ unshift(@array, pop(@array)); # the last shall be first
+ push(@array, shift(@array)); # and vice versa
+
+=head2 How do I shuffle an array randomly?
+
+Use this:
+
+ # fisher_yates_shuffle( \@array ) :
+ # generate a random permutation of @array in place
+ sub fisher_yates_shuffle {
+ my $array = shift;
+ my $i;
+ for ($i = @$array; --$i; ) {
+ my $j = int rand ($i+1);
+ next if $i == $j;
+ @$array[$i,$j] = @$array[$j,$i];
+ }
+ }
+
+ fisher_yates_shuffle( \@array ); # permutes @array in place
+
+You've probably seen shuffling algorithms that works using splice,
+randomly picking another element to swap the current element with:
+
+ srand;
+ @new = ();
+ @old = 1 .. 10; # just a demo
+ while (@old) {
+ push(@new, splice(@old, rand @old, 1));
+ }
+
+This is bad because splice is already O(N), and since you do it N times,
+you just invented a quadratic algorithm; that is, O(N**2). This does
+not scale, although Perl is so efficient that you probably won't notice
+this until you have rather largish arrays.
+
+=head2 How do I process/modify each element of an array?
+
+Use C<for>/C<foreach>:
+
+ for (@lines) {
+ s/foo/bar/; # change that word
+ y/XZ/ZX/; # swap those letters
+ }
+
+Here's another; let's compute spherical volumes:
+
+ for (@volumes = @radii) { # @volumes has changed parts
+ $_ **= 3;
+ $_ *= (4/3) * 3.14159; # this will be constant folded
+ }
+
+If you want to do the same thing to modify the values of the hash,
+you may not use the C<values> function, oddly enough. You need a slice:
+
+ for $orbit ( @orbits{keys %orbits} ) {
+ ($orbit **= 3) *= (4/3) * 3.14159;
+ }
+
+=head2 How do I select a random element from an array?
+
+Use the rand() function (see L<perlfunc/rand>):
+
+ # at the top of the program:
+ srand; # not needed for 5.004 and later
+
+ # then later on
+ $index = rand @array;
+ $element = $array[$index];
+
+Make sure you I<only call srand once per program, if then>.
+If you are calling it more than once (such as before each
+call to rand), you're almost certainly doing something wrong.
+
+=head2 How do I permute N elements of a list?
+
+Here's a little program that generates all permutations
+of all the words on each line of input. The algorithm embodied
+in the permute() function should work on any list:
+
+ #!/usr/bin/perl -n
+ # tsc-permute: permute each word of input
+ permute([split], []);
+ sub permute {
+ my @items = @{ $_[0] };
+ my @perms = @{ $_[1] };
+ unless (@items) {
+ print "@perms\n";
+ } else {
+ my(@newitems,@newperms,$i);
+ foreach $i (0 .. $#items) {
+ @newitems = @items;
+ @newperms = @perms;
+ unshift(@newperms, splice(@newitems, $i, 1));
+ permute([@newitems], [@newperms]);
+ }
+ }
+ }
+
+=head2 How do I sort an array by (anything)?
+
+Supply a comparison function to sort() (described in L<perlfunc/sort>):
+
+ @list = sort { $a <=> $b } @list;
+
+The default sort function is cmp, string comparison, which would
+sort C<(1, 2, 10)> into C<(1, 10, 2)>. C<E<lt>=E<gt>>, used above, is
+the numerical comparison operator.
+
+If you have a complicated function needed to pull out the part you
+want to sort on, then don't do it inside the sort function. Pull it
+out first, because the sort BLOCK can be called many times for the
+same element. Here's an example of how to pull out the first word
+after the first number on each item, and then sort those words
+case-insensitively.
+
+ @idx = ();
+ for (@data) {
+ ($item) = /\d+\s*(\S+)/;
+ push @idx, uc($item);
+ }
+ @sorted = @data[ sort { $idx[$a] cmp $idx[$b] } 0 .. $#idx ];
+
+Which could also be written this way, using a trick
+that's come to be known as the Schwartzian Transform:
+
+ @sorted = map { $_->[0] }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_, uc((/\d+\s*(\S+)/ )[0] ] } @data;
+
+If you need to sort on several fields, the following paradigm is useful.
+
+ @sorted = sort { field1($a) <=> field1($b) ||
+ field2($a) cmp field2($b) ||
+ field3($a) cmp field3($b)
+ } @data;
+
+This can be conveniently combined with precalculation of keys as given
+above.
+
+See http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html for more about
+this approach.
+
+See also the question below on sorting hashes.
+
+=head2 How do I manipulate arrays of bits?
+
+Use pack() and unpack(), or else vec() and the bitwise operations.
+
+For example, this sets $vec to have bit N set if $ints[N] was set:
+
+ $vec = '';
+ foreach(@ints) { vec($vec,$_,1) = 1 }
+
+And here's how, given a vector in $vec, you can
+get those bits into your @ints array:
+
+ sub bitvec_to_list {
+ my $vec = shift;
+ my @ints;
+ # Find null-byte density then select best algorithm
+ if ($vec =~ tr/\0// / length $vec > 0.95) {
+ use integer;
+ my $i;
+ # This method is faster with mostly null-bytes
+ while($vec =~ /[^\0]/g ) {
+ $i = -9 + 8 * pos $vec;
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ push @ints, $i if vec($vec, ++$i, 1);
+ }
+ } else {
+ # This method is a fast general algorithm
+ use integer;
+ my $bits = unpack "b*", $vec;
+ push @ints, 0 if $bits =~ s/^(\d)// && $1;
+ push @ints, pos $bits while($bits =~ /1/g);
+ }
+ return \@ints;
+ }
+
+This method gets faster the more sparse the bit vector is.
+(Courtesy of Tim Bunce and Winfried Koenig.)
+
+=head2 Why does defined() return true on empty arrays and hashes?
+
+See L<perlfunc/defined> in the 5.004 release or later of Perl.
+
+=head1 Data: Hashes (Associative Arrays)
+
+=head2 How do I process an entire hash?
+
+Use the each() function (see L<perlfunc/each>) if you don't care
+whether it's sorted:
+
+ while ( ($key, $value) = each %hash) {
+ print "$key = $value\n";
+ }
+
+If you want it sorted, you'll have to use foreach() on the result of
+sorting the keys as shown in an earlier question.
+
+=head2 What happens if I add or remove keys from a hash while iterating over it?
+
+Don't do that.
+
+=head2 How do I look up a hash element by value?
+
+Create a reverse hash:
+
+ %by_value = reverse %by_key;
+ $key = $by_value{$value};
+
+That's not particularly efficient. It would be more space-efficient
+to use:
+
+ while (($key, $value) = each %by_key) {
+ $by_value{$value} = $key;
+ }
+
+If your hash could have repeated values, the methods above will only
+find one of the associated keys. This may or may not worry you.
+
+=head2 How can I know how many entries are in a hash?
+
+If you mean how many keys, then all you have to do is
+take the scalar sense of the keys() function:
+
+ $num_keys = scalar keys %hash;
+
+In void context it just resets the iterator, which is faster
+for tied hashes.
+
+=head2 How do I sort a hash (optionally by value instead of key)?
+
+Internally, hashes are stored in a way that prevents you from imposing
+an order on key-value pairs. Instead, you have to sort a list of the
+keys or values:
+
+ @keys = sort keys %hash; # sorted by key
+ @keys = sort {
+ $hash{$a} cmp $hash{$b}
+ } keys %hash; # and by value
+
+Here we'll do a reverse numeric sort by value, and if two keys are
+identical, sort by length of key, and if that fails, by straight ASCII
+comparison of the keys (well, possibly modified by your locale -- see
+L<perllocale>).
+
+ @keys = sort {
+ $hash{$b} <=> $hash{$a}
+ ||
+ length($b) <=> length($a)
+ ||
+ $a cmp $b
+ } keys %hash;
+
+=head2 How can I always keep my hash sorted?
+
+You can look into using the DB_File module and tie() using the
+$DB_BTREE hash bindings as documented in L<DB_File/"In Memory Databases">.
+The Tie::IxHash module from CPAN might also be instructive.
+
+=head2 What's the difference between "delete" and "undef" with hashes?
+
+Hashes are pairs of scalars: the first is the key, the second is the
+value. The key will be coerced to a string, although the value can be
+any kind of scalar: string, number, or reference. If a key C<$key> is
+present in the array, C<exists($key)> will return true. The value for
+a given key can be C<undef>, in which case C<$array{$key}> will be
+C<undef> while C<$exists{$key}> will return true. This corresponds to
+(C<$key>, C<undef>) being in the hash.
+
+Pictures help... here's the C<%ary> table:
+
+ keys values
+ +------+------+
+ | a | 3 |
+ | x | 7 |
+ | d | 0 |
+ | e | 2 |
+ +------+------+
+
+And these conditions hold
+
+ $ary{'a'} is true
+ $ary{'d'} is false
+ defined $ary{'d'} is true
+ defined $ary{'a'} is true
+ exists $ary{'a'} is true (perl5 only)
+ grep ($_ eq 'a', keys %ary) is true
+
+If you now say
+
+ undef $ary{'a'}
+
+your table now reads:
+
+
+ keys values
+ +------+------+
+ | a | undef|
+ | x | 7 |
+ | d | 0 |
+ | e | 2 |
+ +------+------+
+
+and these conditions now hold; changes in caps:
+
+ $ary{'a'} is FALSE
+ $ary{'d'} is false
+ defined $ary{'d'} is true
+ defined $ary{'a'} is FALSE
+ exists $ary{'a'} is true (perl5 only)
+ grep ($_ eq 'a', keys %ary) is true
+
+Notice the last two: you have an undef value, but a defined key!
+
+Now, consider this:
+
+ delete $ary{'a'}
+
+your table now reads:
+
+ keys values
+ +------+------+
+ | x | 7 |
+ | d | 0 |
+ | e | 2 |
+ +------+------+
+
+and these conditions now hold; changes in caps:
+
+ $ary{'a'} is false
+ $ary{'d'} is false
+ defined $ary{'d'} is true
+ defined $ary{'a'} is false
+ exists $ary{'a'} is FALSE (perl5 only)
+ grep ($_ eq 'a', keys %ary) is FALSE
+
+See, the whole entry is gone!
+
+=head2 Why don't my tied hashes make the defined/exists distinction?
+
+They may or may not implement the EXISTS() and DEFINED() methods
+differently. For example, there isn't the concept of undef with hashes
+that are tied to DBM* files. This means the true/false tables above
+will give different results when used on such a hash. It also means
+that exists and defined do the same thing with a DBM* file, and what
+they end up doing is not what they do with ordinary hashes.
+
+=head2 How do I reset an each() operation part-way through?
+
+Using C<keys %hash> in scalar context returns the number of keys in
+the hash I<and> resets the iterator associated with the hash. You may
+need to do this if you use C<last> to exit a loop early so that when you
+re-enter it, the hash iterator has been reset.
+
+=head2 How can I get the unique keys from two hashes?
+
+First you extract the keys from the hashes into arrays, and then solve
+the uniquifying the array problem described above. For example:
+
+ %seen = ();
+ for $element (keys(%foo), keys(%bar)) {
+ $seen{$element}++;
+ }
+ @uniq = keys %seen;
+
+Or more succinctly:
+
+ @uniq = keys %{{%foo,%bar}};
+
+Or if you really want to save space:
+
+ %seen = ();
+ while (defined ($key = each %foo)) {
+ $seen{$key}++;
+ }
+ while (defined ($key = each %bar)) {
+ $seen{$key}++;
+ }
+ @uniq = keys %seen;
+
+=head2 How can I store a multidimensional array in a DBM file?
+
+Either stringify the structure yourself (no fun), or else
+get the MLDBM (which uses Data::Dumper) module from CPAN and layer
+it on top of either DB_File or GDBM_File.
+
+=head2 How can I make my hash remember the order I put elements into it?
+
+Use the Tie::IxHash from CPAN.
+
+ use Tie::IxHash;
+ tie(%myhash, Tie::IxHash);
+ for ($i=0; $i<20; $i++) {
+ $myhash{$i} = 2*$i;
+ }
+ @keys = keys %myhash;
+ # @keys = (0,1,2,3,...)
+
+=head2 Why does passing a subroutine an undefined element in a hash create it?
+
+If you say something like:
+
+ somefunc($hash{"nonesuch key here"});
+
+Then that element "autovivifies"; that is, it springs into existence
+whether you store something there or not. That's because functions
+get scalars passed in by reference. If somefunc() modifies C<$_[0]>,
+it has to be ready to write it back into the caller's version.
+
+This has been fixed as of perl5.004.
+
+Normally, merely accessing a key's value for a nonexistent key does
+I<not> cause that key to be forever there. This is different than
+awk's behavior.
+
+=head2 How can I make the Perl equivalent of a C structure/C++ class/hash or array of hashes or arrays?
+
+Use references (documented in L<perlref>). Examples of complex data
+structures are given in L<perldsc> and L<perllol>. Examples of
+structures and object-oriented classes are in L<perltoot>.
+
+=head2 How can I use a reference as a hash key?
+
+You can't do this directly, but you could use the standard Tie::Refhash
+module distributed with perl.
+
+=head1 Data: Misc
+
+=head2 How do I handle binary data correctly?
+
+Perl is binary clean, so this shouldn't be a problem. For example,
+this works fine (assuming the files are found):
+
+ if (`cat /vmunix` =~ /gzip/) {
+ print "Your kernel is GNU-zip enabled!\n";
+ }
+
+On some systems, however, you have to play tedious games with "text"
+versus "binary" files. See L<perlfunc/"binmode">.
+
+If you're concerned about 8-bit ASCII data, then see L<perllocale>.
+
+If you want to deal with multibyte characters, however, there are
+some gotchas. See the section on Regular Expressions.
+
+=head2 How do I determine whether a scalar is a number/whole/integer/float?
+
+Assuming that you don't care about IEEE notations like "NaN" or
+"Infinity", you probably just want to use a regular expression.
+
+ warn "has nondigits" if /\D/;
+ warn "not a natural number" unless /^\d+$/; # rejects -3
+ warn "not an integer" unless /^-?\d+$/; # rejects +3
+ warn "not an integer" unless /^[+-]?\d+$/;
+ warn "not a decimal number" unless /^-?\d+\.?\d*$/; # rejects .2
+ warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
+ warn "not a C float"
+ unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
+
+If you're on a POSIX system, Perl's supports the C<POSIX::strtod>
+function. Its semantics are somewhat cumbersome, so here's a C<getnum>
+wrapper function for more convenient access. This function takes
+a string and returns the number it found, or C<undef> for input that
+isn't a C float. The C<is_numeric> function is a front end to C<getnum>
+if you just want to say, ``Is this a float?''
+
+ sub getnum {
+ use POSIX qw(strtod);
+ my $str = shift;
+ $str =~ s/^\s+//;
+ $str =~ s/\s+$//;
+ $! = 0;
+ my($num, $unparsed) = strtod($str);
+ if (($str eq '') || ($unparsed != 0) || $!) {
+ return undef;
+ } else {
+ return $num;
+ }
+ }
+
+ sub is_numeric { defined &getnum }
+
+Or you could check out
+http://www.perl.com/CPAN/modules/by-module/String/String-Scanf-1.1.tar.gz
+instead. The POSIX module (part of the standard Perl distribution)
+provides the C<strtol> and C<strtod> for converting strings to double
+and longs, respectively.
+
+=head2 How do I keep persistent data across program calls?
+
+For some specific applications, you can use one of the DBM modules.
+See L<AnyDBM_File>. More generically, you should consult the
+FreezeThaw, Storable, or Class::Eroot modules from CPAN.
+
+=head2 How do I print out or copy a recursive data structure?
+
+The Data::Dumper module on CPAN is nice for printing out
+data structures, and FreezeThaw for copying them. For example:
+
+ use FreezeThaw qw(freeze thaw);
+ $new = thaw freeze $old;
+
+Where $old can be (a reference to) any kind of data structure you'd like.
+It will be deeply copied.
+
+=head2 How do I define methods for every class/object?
+
+Use the UNIVERSAL class (see L<UNIVERSAL>).
+
+=head2 How do I verify a credit card checksum?
+
+Get the Business::CreditCard module from CPAN.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq5.pod b/contrib/perl5/pod/perlfaq5.pod
new file mode 100644
index 0000000..98e706a
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq5.pod
@@ -0,0 +1,1074 @@
+=head1 NAME
+
+perlfaq5 - Files and Formats ($Revision: 1.24 $, $Date: 1998/07/05 15:07:20 $)
+
+=head1 DESCRIPTION
+
+This section deals with I/O and the "f" issues: filehandles, flushing,
+formats, and footers.
+
+=head2 How do I flush/unbuffer an output filehandle? Why must I do this?
+
+The C standard I/O library (stdio) normally buffers characters sent to
+devices. This is done for efficiency reasons, so that there isn't a
+system call for each byte. Any time you use print() or write() in
+Perl, you go though this buffering. syswrite() circumvents stdio and
+buffering.
+
+In most stdio implementations, the type of output buffering and the size of
+the buffer varies according to the type of device. Disk files are block
+buffered, often with a buffer size of more than 2k. Pipes and sockets
+are often buffered with a buffer size between 1/2 and 2k. Serial devices
+(e.g. modems, terminals) are normally line-buffered, and stdio sends
+the entire line when it gets the newline.
+
+Perl does not support truly unbuffered output (except insofar as you can
+C<syswrite(OUT, $char, 1)>). What it does instead support is "command
+buffering", in which a physical write is performed after every output
+command. This isn't as hard on your system as unbuffering, but does
+get the output where you want it when you want it.
+
+If you expect characters to get to your device when you print them there,
+you'll want to autoflush its handle.
+Use select() and the C<$|> variable to control autoflushing
+(see L<perlvar/$|> and L<perlfunc/select>):
+
+ $old_fh = select(OUTPUT_HANDLE);
+ $| = 1;
+ select($old_fh);
+
+Or using the traditional idiom:
+
+ select((select(OUTPUT_HANDLE), $| = 1)[0]);
+
+Or if don't mind slowly loading several thousand lines of module code
+just because you're afraid of the C<$|> variable:
+
+ use FileHandle;
+ open(DEV, "+</dev/tty"); # ceci n'est pas une pipe
+ DEV->autoflush(1);
+
+or the newer IO::* modules:
+
+ use IO::Handle;
+ open(DEV, ">/dev/printer"); # but is this?
+ DEV->autoflush(1);
+
+or even this:
+
+ use IO::Socket; # this one is kinda a pipe?
+ $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.com',
+ PeerPort => 'http(80)',
+ Proto => 'tcp');
+ die "$!" unless $sock;
+
+ $sock->autoflush();
+ print $sock "GET / HTTP/1.0" . "\015\012" x 2;
+ $document = join('', <$sock>);
+ print "DOC IS: $document\n";
+
+Note the bizarrely hardcoded carriage return and newline in their octal
+equivalents. This is the ONLY way (currently) to assure a proper flush
+on all platforms, including Macintosh. That the way things work in
+network programming: you really should specify the exact bit pattern
+on the network line terminator. In practice, C<"\n\n"> often works,
+but this is not portable.
+
+See L<perlfaq9> for other examples of fetching URLs over the web.
+
+=head2 How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file?
+
+Although humans have an easy time thinking of a text file as being a
+sequence of lines that operates much like a stack of playing cards --
+or punch cards -- computers usually see the text file as a sequence of
+bytes. In general, there's no direct way for Perl to seek to a
+particular line of a file, insert text into a file, or remove text
+from a file.
+
+(There are exceptions in special circumstances. You can add or remove at
+the very end of the file. Another is replacing a sequence of bytes with
+another sequence of the same length. Another is using the C<$DB_RECNO>
+array bindings as documented in L<DB_File>. Yet another is manipulating
+files with all lines the same length.)
+
+The general solution is to create a temporary copy of the text file with
+the changes you want, then copy that over the original. This assumes
+no locking.
+
+ $old = $file;
+ $new = "$file.tmp.$$";
+ $bak = "$file.bak";
+
+ open(OLD, "< $old") or die "can't open $old: $!";
+ open(NEW, "> $new") or die "can't open $new: $!";
+
+ # Correct typos, preserving case
+ while (<OLD>) {
+ s/\b(p)earl\b/${1}erl/i;
+ (print NEW $_) or die "can't write to $new: $!";
+ }
+
+ close(OLD) or die "can't close $old: $!";
+ close(NEW) or die "can't close $new: $!";
+
+ rename($old, $bak) or die "can't rename $old to $bak: $!";
+ rename($new, $old) or die "can't rename $new to $old: $!";
+
+Perl can do this sort of thing for you automatically with the C<-i>
+command-line switch or the closely-related C<$^I> variable (see
+L<perlrun> for more details). Note that
+C<-i> may require a suffix on some non-Unix systems; see the
+platform-specific documentation that came with your port.
+
+ # Renumber a series of tests from the command line
+ perl -pi -e 's/(^\s+test\s+)\d+/ $1 . ++$count /e' t/op/taint.t
+
+ # form a script
+ local($^I, @ARGV) = ('.bak', glob("*.c"));
+ while (<>) {
+ if ($. == 1) {
+ print "This line should appear at the top of each file\n";
+ }
+ s/\b(p)earl\b/${1}erl/i; # Correct typos, preserving case
+ print;
+ close ARGV if eof; # Reset $.
+ }
+
+If you need to seek to an arbitrary line of a file that changes
+infrequently, you could build up an index of byte positions of where
+the line ends are in the file. If the file is large, an index of
+every tenth or hundredth line end would allow you to seek and read
+fairly efficiently. If the file is sorted, try the look.pl library
+(part of the standard perl distribution).
+
+In the unique case of deleting lines at the end of a file, you
+can use tell() and truncate(). The following code snippet deletes
+the last line of a file without making a copy or reading the
+whole file into memory:
+
+ open (FH, "+< $file");
+ while ( <FH> ) { $addr = tell(FH) unless eof(FH) }
+ truncate(FH, $addr);
+
+Error checking is left as an exercise for the reader.
+
+=head2 How do I count the number of lines in a file?
+
+One fairly efficient way is to count newlines in the file. The
+following program uses a feature of tr///, as documented in L<perlop>.
+If your text file doesn't end with a newline, then it's not really a
+proper text file, so this may report one fewer line than you expect.
+
+ $lines = 0;
+ open(FILE, $filename) or die "Can't open `$filename': $!";
+ while (sysread FILE, $buffer, 4096) {
+ $lines += ($buffer =~ tr/\n//);
+ }
+ close FILE;
+
+This assumes no funny games with newline translations.
+
+=head2 How do I make a temporary file name?
+
+Use the C<new_tmpfile> class method from the IO::File module to get a
+filehandle opened for reading and writing. Use this if you don't
+need to know the file's name.
+
+ use IO::File;
+ $fh = IO::File->new_tmpfile()
+ or die "Unable to make new temporary file: $!";
+
+Or you can use the C<tmpnam> function from the POSIX module to get a
+filename that you then open yourself. Use this if you do need to know
+the file's name.
+
+ use Fcntl;
+ use POSIX qw(tmpnam);
+
+ # try new temporary filenames until we get one that didn't already
+ # exist; the check should be unnecessary, but you can't be too careful
+ do { $name = tmpnam() }
+ until sysopen(FH, $name, O_RDWR|O_CREAT|O_EXCL);
+
+ # install atexit-style handler so that when we exit or die,
+ # we automatically delete this temporary file
+ END { unlink($name) or die "Couldn't unlink $name : $!" }
+
+ # now go on to use the file ...
+
+If you're committed to doing this by hand, use the process ID and/or
+the current time-value. If you need to have many temporary files in
+one process, use a counter:
+
+ BEGIN {
+ use Fcntl;
+ my $temp_dir = -d '/tmp' ? '/tmp' : $ENV{TMP} || $ENV{TEMP};
+ my $base_name = sprintf("%s/%d-%d-0000", $temp_dir, $$, time());
+ sub temp_file {
+ local *FH;
+ my $count = 0;
+ until (defined(fileno(FH)) || $count++ > 100) {
+ $base_name =~ s/-(\d+)$/"-" . (1 + $1)/e;
+ sysopen(FH, $base_name, O_WRONLY|O_EXCL|O_CREAT);
+ }
+ if (defined(fileno(FH))
+ return (*FH, $base_name);
+ } else {
+ return ();
+ }
+ }
+ }
+
+=head2 How can I manipulate fixed-record-length files?
+
+The most efficient way is using pack() and unpack(). This is faster than
+using substr() when take many, many strings. It is slower for just a few.
+
+Here is a sample chunk of code to break up and put back together again
+some fixed-format input lines, in this case from the output of a normal,
+Berkeley-style ps:
+
+ # sample input line:
+ # 15158 p5 T 0:00 perl /home/tchrist/scripts/now-what
+ $PS_T = 'A6 A4 A7 A5 A*';
+ open(PS, "ps|");
+ print scalar <PS>;
+ while (<PS>) {
+ ($pid, $tt, $stat, $time, $command) = unpack($PS_T, $_);
+ for $var (qw!pid tt stat time command!) {
+ print "$var: <$$var>\n";
+ }
+ print 'line=', pack($PS_T, $pid, $tt, $stat, $time, $command),
+ "\n";
+ }
+
+We've used C<$$var> in a way that forbidden by C<use strict 'refs'>.
+That is, we've promoted a string to a scalar variable reference using
+symbolic references. This is ok in small programs, but doesn't scale
+well. It also only works on global variables, not lexicals.
+
+=head2 How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles?
+
+The fastest, simplest, and most direct way is to localize the typeglob
+of the filehandle in question:
+
+ local *TmpHandle;
+
+Typeglobs are fast (especially compared with the alternatives) and
+reasonably easy to use, but they also have one subtle drawback. If you
+had, for example, a function named TmpHandle(), or a variable named
+%TmpHandle, you just hid it from yourself.
+
+ sub findme {
+ local *HostFile;
+ open(HostFile, "</etc/hosts") or die "no /etc/hosts: $!";
+ local $_; # <- VERY IMPORTANT
+ while (<HostFile>) {
+ print if /\b127\.(0\.0\.)?1\b/;
+ }
+ # *HostFile automatically closes/disappears here
+ }
+
+Here's how to use this in a loop to open and store a bunch of
+filehandles. We'll use as values of the hash an ordered
+pair to make it easy to sort the hash in insertion order.
+
+ @names = qw(motd termcap passwd hosts);
+ my $i = 0;
+ foreach $filename (@names) {
+ local *FH;
+ open(FH, "/etc/$filename") || die "$filename: $!";
+ $file{$filename} = [ $i++, *FH ];
+ }
+
+ # Using the filehandles in the array
+ foreach $name (sort { $file{$a}[0] <=> $file{$b}[0] } keys %file) {
+ my $fh = $file{$name}[1];
+ my $line = <$fh>;
+ print "$name $. $line";
+ }
+
+For passing filehandles to functions, the easiest way is to
+prefer them with a star, as in func(*STDIN). See L<perlfaq7/"Passing
+Filehandles"> for details.
+
+If you want to create many, anonymous handles, you should check out the
+Symbol, FileHandle, or IO::Handle (etc.) modules. Here's the equivalent
+code with Symbol::gensym, which is reasonably light-weight:
+
+ foreach $filename (@names) {
+ use Symbol;
+ my $fh = gensym();
+ open($fh, "/etc/$filename") || die "open /etc/$filename: $!";
+ $file{$filename} = [ $i++, $fh ];
+ }
+
+Or here using the semi-object-oriented FileHandle, which certainly isn't
+light-weight:
+
+ use FileHandle;
+
+ foreach $filename (@names) {
+ my $fh = FileHandle->new("/etc/$filename") or die "$filename: $!";
+ $file{$filename} = [ $i++, $fh ];
+ }
+
+Please understand that whether the filehandle happens to be a (probably
+localized) typeglob or an anonymous handle from one of the modules,
+in no way affects the bizarre rules for managing indirect handles.
+See the next question.
+
+=head2 How can I use a filehandle indirectly?
+
+An indirect filehandle is using something other than a symbol
+in a place that a filehandle is expected. Here are ways
+to get those:
+
+ $fh = SOME_FH; # bareword is strict-subs hostile
+ $fh = "SOME_FH"; # strict-refs hostile; same package only
+ $fh = *SOME_FH; # typeglob
+ $fh = \*SOME_FH; # ref to typeglob (bless-able)
+ $fh = *SOME_FH{IO}; # blessed IO::Handle from *SOME_FH typeglob
+
+Or to use the C<new> method from the FileHandle or IO modules to
+create an anonymous filehandle, store that in a scalar variable,
+and use it as though it were a normal filehandle.
+
+ use FileHandle;
+ $fh = FileHandle->new();
+
+ use IO::Handle; # 5.004 or higher
+ $fh = IO::Handle->new();
+
+Then use any of those as you would a normal filehandle. Anywhere that
+Perl is expecting a filehandle, an indirect filehandle may be used
+instead. An indirect filehandle is just a scalar variable that contains
+a filehandle. Functions like C<print>, C<open>, C<seek>, or the functions or
+the C<E<lt>FHE<gt>> diamond operator will accept either a read filehandle
+or a scalar variable containing one:
+
+ ($ifh, $ofh, $efh) = (*STDIN, *STDOUT, *STDERR);
+ print $ofh "Type it: ";
+ $got = <$ifh>
+ print $efh "What was that: $got";
+
+Of you're passing a filehandle to a function, you can write
+the function in two ways:
+
+ sub accept_fh {
+ my $fh = shift;
+ print $fh "Sending to indirect filehandle\n";
+ }
+
+Or it can localize a typeglob and use the filehandle directly:
+
+ sub accept_fh {
+ local *FH = shift;
+ print FH "Sending to localized filehandle\n";
+ }
+
+Both styles work with either objects or typeglobs of real filehandles.
+(They might also work with strings under some circumstances, but this
+is risky.)
+
+ accept_fh(*STDOUT);
+ accept_fh($handle);
+
+In the examples above, we assigned the filehandle to a scalar variable
+before using it. That is because only simple scalar variables,
+not expressions or subscripts into hashes or arrays, can be used with
+built-ins like C<print>, C<printf>, or the diamond operator. These are
+illegal and won't even compile:
+
+ @fd = (*STDIN, *STDOUT, *STDERR);
+ print $fd[1] "Type it: "; # WRONG
+ $got = <$fd[0]> # WRONG
+ print $fd[2] "What was that: $got"; # WRONG
+
+With C<print> and C<printf>, you get around this by using a block and
+an expression where you would place the filehandle:
+
+ print { $fd[1] } "funny stuff\n";
+ printf { $fd[1] } "Pity the poor %x.\n", 3_735_928_559;
+ # Pity the poor deadbeef.
+
+That block is a proper block like any other, so you can put more
+complicated code there. This sends the message out to one of two places:
+
+ $ok = -x "/bin/cat";
+ print { $ok ? $fd[1] : $fd[2] } "cat stat $ok\n";
+ print { $fd[ 1+ ($ok || 0) ] } "cat stat $ok\n";
+
+This approach of treating C<print> and C<printf> like object methods
+calls doesn't work for the diamond operator. That's because it's a
+real operator, not just a function with a comma-less argument. Assuming
+you've been storing typeglobs in your structure as we did above, you
+can use the built-in function named C<readline> to reads a record just
+as C<E<lt>E<gt>> does. Given the initialization shown above for @fd, this
+would work, but only because readline() require a typeglob. It doesn't
+work with objects or strings, which might be a bug we haven't fixed yet.
+
+ $got = readline($fd[0]);
+
+Let it be noted that the flakiness of indirect filehandles is not
+related to whether they're strings, typeglobs, objects, or anything else.
+It's the syntax of the fundamental operators. Playing the object
+game doesn't help you at all here.
+
+=head2 How can I set up a footer format to be used with write()?
+
+There's no builtin way to do this, but L<perlform> has a couple of
+techniques to make it possible for the intrepid hacker.
+
+=head2 How can I write() into a string?
+
+See L<perlform> for an swrite() function.
+
+=head2 How can I output my numbers with commas added?
+
+This one will do it for you:
+
+ sub commify {
+ local $_ = shift;
+ 1 while s/^(-?\d+)(\d{3})/$1,$2/;
+ return $_;
+ }
+
+ $n = 23659019423.2331;
+ print "GOT: ", commify($n), "\n";
+
+ GOT: 23,659,019,423.2331
+
+You can't just:
+
+ s/^(-?\d+)(\d{3})/$1,$2/g;
+
+because you have to put the comma in and then recalculate your
+position.
+
+Alternatively, this commifies all numbers in a line regardless of
+whether they have decimal portions, are preceded by + or -, or
+whatever:
+
+ # from Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
+ sub commify {
+ my $input = shift;
+ $input = reverse $input;
+ $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
+ return reverse $input;
+ }
+
+=head2 How can I translate tildes (~) in a filename?
+
+Use the E<lt>E<gt> (glob()) operator, documented in L<perlfunc>. This
+requires that you have a shell installed that groks tildes, meaning
+csh or tcsh or (some versions of) ksh, and thus may have portability
+problems. The Glob::KGlob module (available from CPAN) gives more
+portable glob functionality.
+
+Within Perl, you may use this directly:
+
+ $filename =~ s{
+ ^ ~ # find a leading tilde
+ ( # save this in $1
+ [^/] # a non-slash character
+ * # repeated 0 or more times (0 means me)
+ )
+ }{
+ $1
+ ? (getpwnam($1))[7]
+ : ( $ENV{HOME} || $ENV{LOGDIR} )
+ }ex;
+
+=head2 How come when I open a file read-write it wipes it out?
+
+Because you're using something like this, which truncates the file and
+I<then> gives you read-write access:
+
+ open(FH, "+> /path/name"); # WRONG (almost always)
+
+Whoops. You should instead use this, which will fail if the file
+doesn't exist. Using "E<gt>" always clobbers or creates.
+Using "E<lt>" never does either. The "+" doesn't change this.
+
+Here are examples of many kinds of file opens. Those using sysopen()
+all assume
+
+ use Fcntl;
+
+To open file for reading:
+
+ open(FH, "< $path") || die $!;
+ sysopen(FH, $path, O_RDONLY) || die $!;
+
+To open file for writing, create new file if needed or else truncate old file:
+
+ open(FH, "> $path") || die $!;
+ sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT) || die $!;
+ sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT, 0666) || die $!;
+
+To open file for writing, create new file, file must not exist:
+
+ sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT) || die $!;
+ sysopen(FH, $path, O_WRONLY|O_EXCL|O_CREAT, 0666) || die $!;
+
+To open file for appending, create if necessary:
+
+ open(FH, ">> $path") || die $!;
+ sysopen(FH, $path, O_WRONLY|O_APPEND|O_CREAT) || die $!;
+ sysopen(FH, $path, O_WRONLY|O_APPEND|O_CREAT, 0666) || die $!;
+
+To open file for appending, file must exist:
+
+ sysopen(FH, $path, O_WRONLY|O_APPEND) || die $!;
+
+To open file for update, file must exist:
+
+ open(FH, "+< $path") || die $!;
+ sysopen(FH, $path, O_RDWR) || die $!;
+
+To open file for update, create file if necessary:
+
+ sysopen(FH, $path, O_RDWR|O_CREAT) || die $!;
+ sysopen(FH, $path, O_RDWR|O_CREAT, 0666) || die $!;
+
+To open file for update, file must not exist:
+
+ sysopen(FH, $path, O_RDWR|O_EXCL|O_CREAT) || die $!;
+ sysopen(FH, $path, O_RDWR|O_EXCL|O_CREAT, 0666) || die $!;
+
+To open a file without blocking, creating if necessary:
+
+ sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT)
+ or die "can't open /tmp/somefile: $!":
+
+Be warned that neither creation nor deletion of files is guaranteed to
+be an atomic operation over NFS. That is, two processes might both
+successful create or unlink the same file! Therefore O_EXCL
+isn't so exclusive as you might wish.
+
+=head2 Why do I sometimes get an "Argument list too long" when I use <*>?
+
+The C<E<lt>E<gt>> operator performs a globbing operation (see above).
+By default glob() forks csh(1) to do the actual glob expansion, but
+csh can't handle more than 127 items and so gives the error message
+C<Argument list too long>. People who installed tcsh as csh won't
+have this problem, but their users may be surprised by it.
+
+To get around this, either do the glob yourself with C<Dirhandle>s and
+patterns, or use a module like Glob::KGlob, one that doesn't use the
+shell to do globbing.
+
+=head2 Is there a leak/bug in glob()?
+
+Due to the current implementation on some operating systems, when you
+use the glob() function or its angle-bracket alias in a scalar
+context, you may cause a leak and/or unpredictable behavior. It's
+best therefore to use glob() only in list context.
+
+=head2 How can I open a file with a leading "E<gt>" or trailing blanks?
+
+Normally perl ignores trailing blanks in filenames, and interprets
+certain leading characters (or a trailing "|") to mean something
+special. To avoid this, you might want to use a routine like this.
+It makes incomplete pathnames into explicit relative ones, and tacks a
+trailing null byte on the name to make perl leave it alone:
+
+ sub safe_filename {
+ local $_ = shift;
+ return m#^/#
+ ? "$_\0"
+ : "./$_\0";
+ }
+
+ $fn = safe_filename("<<<something really wicked ");
+ open(FH, "> $fn") or "couldn't open $fn: $!";
+
+You could also use the sysopen() function (see L<perlfunc/sysopen>).
+
+=head2 How can I reliably rename a file?
+
+Well, usually you just use Perl's rename() function. But that may
+not work everywhere, in particular, renaming files across file systems.
+If your operating system supports a mv(1) program or its moral equivalent,
+this works:
+
+ rename($old, $new) or system("mv", $old, $new);
+
+It may be more compelling to use the File::Copy module instead. You
+just copy to the new file to the new name (checking return values),
+then delete the old one. This isn't really the same semantics as a
+real rename(), though, which preserves metainformation like
+permissions, timestamps, inode info, etc.
+
+The newer version of File::Copy export a move() function.
+
+=head2 How can I lock a file?
+
+Perl's builtin flock() function (see L<perlfunc> for details) will call
+flock(2) if that exists, fcntl(2) if it doesn't (on perl version 5.004 and
+later), and lockf(3) if neither of the two previous system calls exists.
+On some systems, it may even use a different form of native locking.
+Here are some gotchas with Perl's flock():
+
+=over 4
+
+=item 1
+
+Produces a fatal error if none of the three system calls (or their
+close equivalent) exists.
+
+=item 2
+
+lockf(3) does not provide shared locking, and requires that the
+filehandle be open for writing (or appending, or read/writing).
+
+=item 3
+
+Some versions of flock() can't lock files over a network (e.g. on NFS
+file systems), so you'd need to force the use of fcntl(2) when you
+build Perl. See the flock entry of L<perlfunc>, and the F<INSTALL>
+file in the source distribution for information on building Perl to do
+this.
+
+=back
+
+=head2 What can't I just open(FH, ">file.lock")?
+
+A common bit of code B<NOT TO USE> is this:
+
+ sleep(3) while -e "file.lock"; # PLEASE DO NOT USE
+ open(LCK, "> file.lock"); # THIS BROKEN CODE
+
+This is a classic race condition: you take two steps to do something
+which must be done in one. That's why computer hardware provides an
+atomic test-and-set instruction. In theory, this "ought" to work:
+
+ sysopen(FH, "file.lock", O_WRONLY|O_EXCL|O_CREAT)
+ or die "can't open file.lock: $!":
+
+except that lamentably, file creation (and deletion) is not atomic
+over NFS, so this won't work (at least, not every time) over the net.
+Various schemes involving involving link() have been suggested, but
+these tend to involve busy-wait, which is also subdesirable.
+
+=head2 I still don't get locking. I just want to increment the number in the file. How can I do this?
+
+Didn't anyone ever tell you web-page hit counters were useless?
+They don't count number of hits, they're a waste of time, and they serve
+only to stroke the writer's vanity. Better to pick a random number.
+It's more realistic.
+
+Anyway, this is what you can do if you can't help yourself.
+
+ use Fcntl;
+ sysopen(FH, "numfile", O_RDWR|O_CREAT) or die "can't open numfile: $!";
+ flock(FH, 2) or die "can't flock numfile: $!";
+ $num = <FH> || 0;
+ seek(FH, 0, 0) or die "can't rewind numfile: $!";
+ truncate(FH, 0) or die "can't truncate numfile: $!";
+ (print FH $num+1, "\n") or die "can't write numfile: $!";
+ # DO NOT UNLOCK THIS UNTIL YOU CLOSE
+ close FH or die "can't close numfile: $!";
+
+Here's a much better web-page hit counter:
+
+ $hits = int( (time() - 850_000_000) / rand(1_000) );
+
+If the count doesn't impress your friends, then the code might. :-)
+
+=head2 How do I randomly update a binary file?
+
+If you're just trying to patch a binary, in many cases something as
+simple as this works:
+
+ perl -i -pe 's{window manager}{window mangler}g' /usr/bin/emacs
+
+However, if you have fixed sized records, then you might do something more
+like this:
+
+ $RECSIZE = 220; # size of record, in bytes
+ $recno = 37; # which record to update
+ open(FH, "+<somewhere") || die "can't update somewhere: $!";
+ seek(FH, $recno * $RECSIZE, 0);
+ read(FH, $record, $RECSIZE) == $RECSIZE || die "can't read record $recno: $!";
+ # munge the record
+ seek(FH, $recno * $RECSIZE, 0);
+ print FH $record;
+ close FH;
+
+Locking and error checking are left as an exercise for the reader.
+Don't forget them, or you'll be quite sorry.
+
+=head2 How do I get a file's timestamp in perl?
+
+If you want to retrieve the time at which the file was last read,
+written, or had its meta-data (owner, etc) changed, you use the B<-M>,
+B<-A>, or B<-C> filetest operations as documented in L<perlfunc>. These
+retrieve the age of the file (measured against the start-time of your
+program) in days as a floating point number. To retrieve the "raw"
+time in seconds since the epoch, you would call the stat function,
+then use localtime(), gmtime(), or POSIX::strftime() to convert this
+into human-readable form.
+
+Here's an example:
+
+ $write_secs = (stat($file))[9];
+ printf "file %s updated at %s\n", $file,
+ scalar localtime($write_secs);
+
+If you prefer something more legible, use the File::stat module
+(part of the standard distribution in version 5.004 and later):
+
+ use File::stat;
+ use Time::localtime;
+ $date_string = ctime(stat($file)->mtime);
+ print "file $file updated at $date_string\n";
+
+Error checking is left as an exercise for the reader.
+
+=head2 How do I set a file's timestamp in perl?
+
+You use the utime() function documented in L<perlfunc/utime>.
+By way of example, here's a little program that copies the
+read and write times from its first argument to all the rest
+of them.
+
+ if (@ARGV < 2) {
+ die "usage: cptimes timestamp_file other_files ...\n";
+ }
+ $timestamp = shift;
+ ($atime, $mtime) = (stat($timestamp))[8,9];
+ utime $atime, $mtime, @ARGV;
+
+Error checking is left as an exercise for the reader.
+
+Note that utime() currently doesn't work correctly with Win95/NT
+ports. A bug has been reported. Check it carefully before using
+it on those platforms.
+
+=head2 How do I print to more than one file at once?
+
+If you only have to do this once, you can do this:
+
+ for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }
+
+To connect up to one filehandle to several output filehandles, it's
+easiest to use the tee(1) program if you have it, and let it take care
+of the multiplexing:
+
+ open (FH, "| tee file1 file2 file3");
+
+Or even:
+
+ # make STDOUT go to three files, plus original STDOUT
+ open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
+ print "whatever\n" or die "Writing: $!\n";
+ close(STDOUT) or die "Closing: $!\n";
+
+Otherwise you'll have to write your own multiplexing print
+function -- or your own tee program -- or use Tom Christiansen's,
+at http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz, which is
+written in Perl and offers much greater functionality
+than the stock version.
+
+=head2 How can I read in a file by paragraphs?
+
+Use the C<$\> variable (see L<perlvar> for details). You can either
+set it to C<""> to eliminate empty paragraphs (C<"abc\n\n\n\ndef">,
+for instance, gets treated as two paragraphs and not three), or
+C<"\n\n"> to accept empty paragraphs.
+
+=head2 How can I read a single character from a file? From the keyboard?
+
+You can use the builtin C<getc()> function for most filehandles, but
+it won't (easily) work on a terminal device. For STDIN, either use
+the Term::ReadKey module from CPAN, or use the sample code in
+L<perlfunc/getc>.
+
+If your system supports POSIX, you can use the following code, which
+you'll note turns off echo processing as well.
+
+ #!/usr/bin/perl -w
+ use strict;
+ $| = 1;
+ for (1..4) {
+ my $got;
+ print "gimme: ";
+ $got = getone();
+ print "--> $got\n";
+ }
+ exit;
+
+ BEGIN {
+ use POSIX qw(:termios_h);
+
+ my ($term, $oterm, $echo, $noecho, $fd_stdin);
+
+ $fd_stdin = fileno(STDIN);
+
+ $term = POSIX::Termios->new();
+ $term->getattr($fd_stdin);
+ $oterm = $term->getlflag();
+
+ $echo = ECHO | ECHOK | ICANON;
+ $noecho = $oterm & ~$echo;
+
+ sub cbreak {
+ $term->setlflag($noecho);
+ $term->setcc(VTIME, 1);
+ $term->setattr($fd_stdin, TCSANOW);
+ }
+
+ sub cooked {
+ $term->setlflag($oterm);
+ $term->setcc(VTIME, 0);
+ $term->setattr($fd_stdin, TCSANOW);
+ }
+
+ sub getone {
+ my $key = '';
+ cbreak();
+ sysread(STDIN, $key, 1);
+ cooked();
+ return $key;
+ }
+
+ }
+
+ END { cooked() }
+
+The Term::ReadKey module from CPAN may be easier to use:
+
+ use Term::ReadKey;
+ open(TTY, "</dev/tty");
+ print "Gimme a char: ";
+ ReadMode "raw";
+ $key = ReadKey 0, *TTY;
+ ReadMode "normal";
+ printf "\nYou said %s, char number %03d\n",
+ $key, ord $key;
+
+For DOS systems, Dan Carson <dbc@tc.fluke.COM> reports the following:
+
+To put the PC in "raw" mode, use ioctl with some magic numbers gleaned
+from msdos.c (Perl source file) and Ralf Brown's interrupt list (comes
+across the net every so often):
+
+ $old_ioctl = ioctl(STDIN,0,0); # Gets device info
+ $old_ioctl &= 0xff;
+ ioctl(STDIN,1,$old_ioctl | 32); # Writes it back, setting bit 5
+
+Then to read a single character:
+
+ sysread(STDIN,$c,1); # Read a single character
+
+And to put the PC back to "cooked" mode:
+
+ ioctl(STDIN,1,$old_ioctl); # Sets it back to cooked mode.
+
+So now you have $c. If C<ord($c) == 0>, you have a two byte code, which
+means you hit a special key. Read another byte with C<sysread(STDIN,$c,1)>,
+and that value tells you what combination it was according to this
+table:
+
+ # PC 2-byte keycodes = ^@ + the following:
+
+ # HEX KEYS
+ # --- ----
+ # 0F SHF TAB
+ # 10-19 ALT QWERTYUIOP
+ # 1E-26 ALT ASDFGHJKL
+ # 2C-32 ALT ZXCVBNM
+ # 3B-44 F1-F10
+ # 47-49 HOME,UP,PgUp
+ # 4B LEFT
+ # 4D RIGHT
+ # 4F-53 END,DOWN,PgDn,Ins,Del
+ # 54-5D SHF F1-F10
+ # 5E-67 CTR F1-F10
+ # 68-71 ALT F1-F10
+ # 73-77 CTR LEFT,RIGHT,END,PgDn,HOME
+ # 78-83 ALT 1234567890-=
+ # 84 CTR PgUp
+
+This is all trial and error I did a long time ago, I hope I'm reading the
+file that worked.
+
+=head2 How can I tell if there's a character waiting on a filehandle?
+
+The very first thing you should do is look into getting the Term::ReadKey
+extension from CPAN. It now even has limited support for closed, proprietary
+(read: not open systems, not POSIX, not Unix, etc) systems.
+
+You should also check out the Frequently Asked Questions list in
+comp.unix.* for things like this: the answer is essentially the same.
+It's very system dependent. Here's one solution that works on BSD
+systems:
+
+ sub key_ready {
+ my($rin, $nfd);
+ vec($rin, fileno(STDIN), 1) = 1;
+ return $nfd = select($rin,undef,undef,0);
+ }
+
+If you want to find out how many characters are waiting,
+there's also the FIONREAD ioctl call to be looked at.
+
+The I<h2ph> tool that comes with Perl tries to convert C include
+files to Perl code, which can be C<require>d. FIONREAD ends
+up defined as a function in the I<sys/ioctl.ph> file:
+
+ require 'sys/ioctl.ph';
+
+ $size = pack("L", 0);
+ ioctl(FH, FIONREAD(), $size) or die "Couldn't call ioctl: $!\n";
+ $size = unpack("L", $size);
+
+If I<h2ph> wasn't installed or doesn't work for you, you can
+I<grep> the include files by hand:
+
+ % grep FIONREAD /usr/include/*/*
+ /usr/include/asm/ioctls.h:#define FIONREAD 0x541B
+
+Or write a small C program using the editor of champions:
+
+ % cat > fionread.c
+ #include <sys/ioctl.h>
+ main() {
+ printf("%#08x\n", FIONREAD);
+ }
+ ^D
+ % cc -o fionread fionread
+ % ./fionread
+ 0x4004667f
+
+And then hard-code it, leaving porting as an exercise to your successor.
+
+ $FIONREAD = 0x4004667f; # XXX: opsys dependent
+
+ $size = pack("L", 0);
+ ioctl(FH, $FIONREAD, $size) or die "Couldn't call ioctl: $!\n";
+ $size = unpack("L", $size);
+
+FIONREAD requires a filehandle connected to a stream, meaning sockets,
+pipes, and tty devices work, but I<not> files.
+
+=head2 How do I do a C<tail -f> in perl?
+
+First try
+
+ seek(GWFILE, 0, 1);
+
+The statement C<seek(GWFILE, 0, 1)> doesn't change the current position,
+but it does clear the end-of-file condition on the handle, so that the
+next <GWFILE> makes Perl try again to read something.
+
+If that doesn't work (it relies on features of your stdio implementation),
+then you need something more like this:
+
+ for (;;) {
+ for ($curpos = tell(GWFILE); <GWFILE>; $curpos = tell(GWFILE)) {
+ # search for some stuff and put it into files
+ }
+ # sleep for a while
+ seek(GWFILE, $curpos, 0); # seek to where we had been
+ }
+
+If this still doesn't work, look into the POSIX module. POSIX defines
+the clearerr() method, which can remove the end of file condition on a
+filehandle. The method: read until end of file, clearerr(), read some
+more. Lather, rinse, repeat.
+
+=head2 How do I dup() a filehandle in Perl?
+
+If you check L<perlfunc/open>, you'll see that several of the ways
+to call open() should do the trick. For example:
+
+ open(LOG, ">>/tmp/logfile");
+ open(STDERR, ">&LOG");
+
+Or even with a literal numeric descriptor:
+
+ $fd = $ENV{MHCONTEXTFD};
+ open(MHCONTEXT, "<&=$fd"); # like fdopen(3S)
+
+Note that "E<lt>&STDIN" makes a copy, but "E<lt>&=STDIN" make
+an alias. That means if you close an aliased handle, all
+aliases become inaccessible. This is not true with
+a copied one.
+
+Error checking, as always, has been left as an exercise for the reader.
+
+=head2 How do I close a file descriptor by number?
+
+This should rarely be necessary, as the Perl close() function is to be
+used for things that Perl opened itself, even if it was a dup of a
+numeric descriptor, as with MHCONTEXT above. But if you really have
+to, you may be able to do this:
+
+ require 'sys/syscall.ph';
+ $rc = syscall(&SYS_close, $fd + 0); # must force numeric
+ die "can't sysclose $fd: $!" unless $rc == -1;
+
+=head2 Why can't I use "C:\temp\foo" in DOS paths? What doesn't `C:\temp\foo.exe` work?
+
+Whoops! You just put a tab and a formfeed into that filename!
+Remember that within double quoted strings ("like\this"), the
+backslash is an escape character. The full list of these is in
+L<perlop/Quote and Quote-like Operators>. Unsurprisingly, you don't
+have a file called "c:(tab)emp(formfeed)oo" or
+"c:(tab)emp(formfeed)oo.exe" on your DOS filesystem.
+
+Either single-quote your strings, or (preferably) use forward slashes.
+Since all DOS and Windows versions since something like MS-DOS 2.0 or so
+have treated C</> and C<\> the same in a path, you might as well use the
+one that doesn't clash with Perl -- or the POSIX shell, ANSI C and C++,
+awk, Tcl, Java, or Python, just to mention a few.
+
+=head2 Why doesn't glob("*.*") get all the files?
+
+Because even on non-Unix ports, Perl's glob function follows standard
+Unix globbing semantics. You'll need C<glob("*")> to get all (non-hidden)
+files. This makes glob() portable.
+
+=head2 Why does Perl let me delete read-only files? Why does C<-i> clobber protected files? Isn't this a bug in Perl?
+
+This is elaborately and painstakingly described in the "Far More Than
+You Ever Wanted To Know" in
+http://www.perl.com/CPAN/doc/FMTEYEWTK/file-dir-perms .
+
+The executive summary: learn how your filesystem works. The
+permissions on a file say what can happen to the data in that file.
+The permissions on a directory say what can happen to the list of
+files in that directory. If you delete a file, you're removing its
+name from the directory (so the operation depends on the permissions
+of the directory, not of the file). If you try to write to the file,
+the permissions of the file govern whether you're allowed to.
+
+=head2 How do I select a random line from a file?
+
+Here's an algorithm from the Camel Book:
+
+ srand;
+ rand($.) < 1 && ($line = $_) while <>;
+
+This has a significant advantage in space over reading the whole
+file in. A simple proof by induction is available upon
+request if you doubt its correctness.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as an integrated part of the Standard Distribution
+of Perl or of its documentation (printed or otherwise), this works is
+covered under Perl's Artistic Licence. For separate distributions of
+all or part of this FAQ outside of that, see L<perlfaq>.
+
+Irrespective of its distribution, all code examples here are public
+domain. You are permitted and encouraged to use this code and any
+derivatives thereof in your own programs for fun or for profit as you
+see fit. A simple comment in the code giving credit to the FAQ would
+be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq6.pod b/contrib/perl5/pod/perlfaq6.pod
new file mode 100644
index 0000000..488a27c
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq6.pod
@@ -0,0 +1,626 @@
+=head1 NAME
+
+perlfaq6 - Regexps ($Revision: 1.22 $, $Date: 1998/07/16 14:01:07 $)
+
+=head1 DESCRIPTION
+
+This section is surprisingly small because the rest of the FAQ is
+littered with answers involving regular expressions. For example,
+decoding a URL and checking whether something is a number are handled
+with regular expressions, but those answers are found elsewhere in
+this document (in the section on Data and the Networking one on
+networking, to be precise).
+
+=head2 How can I hope to use regular expressions without creating illegible and unmaintainable code?
+
+Three techniques can make regular expressions maintainable and
+understandable.
+
+=over 4
+
+=item Comments Outside the Regexp
+
+Describe what you're doing and how you're doing it, using normal Perl
+comments.
+
+ # turn the line into the first word, a colon, and the
+ # number of characters on the rest of the line
+ s/^(\w+)(.*)/ lc($1) . ":" . length($2) /meg;
+
+=item Comments Inside the Regexp
+
+The C</x> modifier causes whitespace to be ignored in a regexp pattern
+(except in a character class), and also allows you to use normal
+comments there, too. As you can imagine, whitespace and comments help
+a lot.
+
+C</x> lets you turn this:
+
+ s{<(?:[^>'"]*|".*?"|'.*?')+>}{}gs;
+
+into this:
+
+ s{ < # opening angle bracket
+ (?: # Non-backreffing grouping paren
+ [^>'"] * # 0 or more things that are neither > nor ' nor "
+ | # or else
+ ".*?" # a section between double quotes (stingy match)
+ | # or else
+ '.*?' # a section between single quotes (stingy match)
+ ) + # all occurring one or more times
+ > # closing angle bracket
+ }{}gsx; # replace with nothing, i.e. delete
+
+It's still not quite so clear as prose, but it is very useful for
+describing the meaning of each part of the pattern.
+
+=item Different Delimiters
+
+While we normally think of patterns as being delimited with C</>
+characters, they can be delimited by almost any character. L<perlre>
+describes this. For example, the C<s///> above uses braces as
+delimiters. Selecting another delimiter can avoid quoting the
+delimiter within the pattern:
+
+ s/\/usr\/local/\/usr\/share/g; # bad delimiter choice
+ s#/usr/local#/usr/share#g; # better
+
+=back
+
+=head2 I'm having trouble matching over more than one line. What's wrong?
+
+Either you don't have more than one line in the string you're looking at
+(probably), or else you aren't using the correct modifier(s) on your
+pattern (possibly).
+
+There are many ways to get multiline data into a string. If you want
+it to happen automatically while reading input, you'll want to set $/
+(probably to '' for paragraphs or C<undef> for the whole file) to
+allow you to read more than one line at a time.
+
+Read L<perlre> to help you decide which of C</s> and C</m> (or both)
+you might want to use: C</s> allows dot to include newline, and C</m>
+allows caret and dollar to match next to a newline, not just at the
+end of the string. You do need to make sure that you've actually
+got a multiline string in there.
+
+For example, this program detects duplicate words, even when they span
+line breaks (but not paragraph ones). For this example, we don't need
+C</s> because we aren't using dot in a regular expression that we want
+to cross line boundaries. Neither do we need C</m> because we aren't
+wanting caret or dollar to match at any point inside the record next
+to newlines. But it's imperative that $/ be set to something other
+than the default, or else we won't actually ever have a multiline
+record read in.
+
+ $/ = ''; # read in more whole paragraph, not just one line
+ while ( <> ) {
+ while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha
+ print "Duplicate $1 at paragraph $.\n";
+ }
+ }
+
+Here's code that finds sentences that begin with "From " (which would
+be mangled by many mailers):
+
+ $/ = ''; # read in more whole paragraph, not just one line
+ while ( <> ) {
+ while ( /^From /gm ) { # /m makes ^ match next to \n
+ print "leading from in paragraph $.\n";
+ }
+ }
+
+Here's code that finds everything between START and END in a paragraph:
+
+ undef $/; # read in whole file, not just one line or paragraph
+ while ( <> ) {
+ while ( /START(.*?)END/sm ) { # /s makes . cross line boundaries
+ print "$1\n";
+ }
+ }
+
+=head2 How can I pull out lines between two patterns that are themselves on different lines?
+
+You can use Perl's somewhat exotic C<..> operator (documented in
+L<perlop>):
+
+ perl -ne 'print if /START/ .. /END/' file1 file2 ...
+
+If you wanted text and not lines, you would use
+
+ perl -0777 -pe 'print "$1\n" while /START(.*?)END/gs' file1 file2 ...
+
+But if you want nested occurrences of C<START> through C<END>, you'll
+run up against the problem described in the question in this section
+on matching balanced text.
+
+Here's another example of using C<..>:
+
+ while (<>) {
+ $in_header = 1 .. /^$/;
+ $in_body = /^$/ .. eof();
+ # now choose between them
+ } continue {
+ reset if eof(); # fix $.
+ }
+
+=head2 I put a regular expression into $/ but it didn't work. What's wrong?
+
+$/ must be a string, not a regular expression. Awk has to be better
+for something. :-)
+
+Actually, you could do this if you don't mind reading the whole file
+into memory:
+
+ undef $/;
+ @records = split /your_pattern/, <FH>;
+
+The Net::Telnet module (available from CPAN) has the capability to
+wait for a pattern in the input stream, or timeout if it doesn't
+appear within a certain time.
+
+ ## Create a file with three lines.
+ open FH, ">file";
+ print FH "The first line\nThe second line\nThe third line\n";
+ close FH;
+
+ ## Get a read/write filehandle to it.
+ $fh = new FileHandle "+<file";
+
+ ## Attach it to a "stream" object.
+ use Net::Telnet;
+ $file = new Net::Telnet (-fhopen => $fh);
+
+ ## Search for the second line and print out the third.
+ $file->waitfor('/second line\n/');
+ print $file->getline;
+
+=head2 How do I substitute case insensitively on the LHS, but preserving case on the RHS?
+
+It depends on what you mean by "preserving case". The following
+script makes the substitution have the same case, letter by letter, as
+the original. If the substitution has more characters than the string
+being substituted, the case of the last character is used for the rest
+of the substitution.
+
+ # Original by Nathan Torkington, massaged by Jeffrey Friedl
+ #
+ sub preserve_case($$)
+ {
+ my ($old, $new) = @_;
+ my ($state) = 0; # 0 = no change; 1 = lc; 2 = uc
+ my ($i, $oldlen, $newlen, $c) = (0, length($old), length($new));
+ my ($len) = $oldlen < $newlen ? $oldlen : $newlen;
+
+ for ($i = 0; $i < $len; $i++) {
+ if ($c = substr($old, $i, 1), $c =~ /[\W\d_]/) {
+ $state = 0;
+ } elsif (lc $c eq $c) {
+ substr($new, $i, 1) = lc(substr($new, $i, 1));
+ $state = 1;
+ } else {
+ substr($new, $i, 1) = uc(substr($new, $i, 1));
+ $state = 2;
+ }
+ }
+ # finish up with any remaining new (for when new is longer than old)
+ if ($newlen > $oldlen) {
+ if ($state == 1) {
+ substr($new, $oldlen) = lc(substr($new, $oldlen));
+ } elsif ($state == 2) {
+ substr($new, $oldlen) = uc(substr($new, $oldlen));
+ }
+ }
+ return $new;
+ }
+
+ $a = "this is a TEsT case";
+ $a =~ s/(test)/preserve_case($1, "success")/gie;
+ print "$a\n";
+
+This prints:
+
+ this is a SUcCESS case
+
+=head2 How can I make C<\w> match national character sets?
+
+See L<perllocale>.
+
+=head2 How can I match a locale-smart version of C</[a-zA-Z]/>?
+
+One alphabetic character would be C</[^\W\d_]/>, no matter what locale
+you're in. Non-alphabetics would be C</[\W\d_]/> (assuming you don't
+consider an underscore a letter).
+
+=head2 How can I quote a variable to use in a regexp?
+
+The Perl parser will expand $variable and @variable references in
+regular expressions unless the delimiter is a single quote. Remember,
+too, that the right-hand side of a C<s///> substitution is considered
+a double-quoted string (see L<perlop> for more details). Remember
+also that any regexp special characters will be acted on unless you
+precede the substitution with \Q. Here's an example:
+
+ $string = "to die?";
+ $lhs = "die?";
+ $rhs = "sleep no more";
+
+ $string =~ s/\Q$lhs/$rhs/;
+ # $string is now "to sleep no more"
+
+Without the \Q, the regexp would also spuriously match "di".
+
+=head2 What is C</o> really for?
+
+Using a variable in a regular expression match forces a re-evaluation
+(and perhaps recompilation) each time through. The C</o> modifier
+locks in the regexp the first time it's used. This always happens in a
+constant regular expression, and in fact, the pattern was compiled
+into the internal format at the same time your entire program was.
+
+Use of C</o> is irrelevant unless variable interpolation is used in
+the pattern, and if so, the regexp engine will neither know nor care
+whether the variables change after the pattern is evaluated the I<very
+first> time.
+
+C</o> is often used to gain an extra measure of efficiency by not
+performing subsequent evaluations when you know it won't matter
+(because you know the variables won't change), or more rarely, when
+you don't want the regexp to notice if they do.
+
+For example, here's a "paragrep" program:
+
+ $/ = ''; # paragraph mode
+ $pat = shift;
+ while (<>) {
+ print if /$pat/o;
+ }
+
+=head2 How do I use a regular expression to strip C style comments from a file?
+
+While this actually can be done, it's much harder than you'd think.
+For example, this one-liner
+
+ perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
+
+will work in many but not all cases. You see, it's too simple-minded for
+certain kinds of C programs, in particular, those with what appear to be
+comments in quoted strings. For that, you'd need something like this,
+created by Jeffrey Friedl:
+
+ $/ = undef;
+ $_ = <>;
+ s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|\n+|.[^/"'\\]*)#$2#g;
+ print;
+
+This could, of course, be more legibly written with the C</x> modifier, adding
+whitespace and comments.
+
+=head2 Can I use Perl regular expressions to match balanced text?
+
+Although Perl regular expressions are more powerful than "mathematical"
+regular expressions, because they feature conveniences like backreferences
+(C<\1> and its ilk), they still aren't powerful enough. You still need
+to use non-regexp techniques to parse balanced text, such as the text
+enclosed between matching parentheses or braces, for example.
+
+An elaborate subroutine (for 7-bit ASCII only) to pull out balanced
+and possibly nested single chars, like C<`> and C<'>, C<{> and C<}>,
+or C<(> and C<)> can be found in
+http://www.perl.com/CPAN/authors/id/TOMC/scripts/pull_quotes.gz .
+
+The C::Scan module from CPAN contains such subs for internal usage,
+but they are undocumented.
+
+=head2 What does it mean that regexps are greedy? How can I get around it?
+
+Most people mean that greedy regexps match as much as they can.
+Technically speaking, it's actually the quantifiers (C<?>, C<*>, C<+>,
+C<{}>) that are greedy rather than the whole pattern; Perl prefers local
+greed and immediate gratification to overall greed. To get non-greedy
+versions of the same quantifiers, use (C<??>, C<*?>, C<+?>, C<{}?>).
+
+An example:
+
+ $s1 = $s2 = "I am very very cold";
+ $s1 =~ s/ve.*y //; # I am cold
+ $s2 =~ s/ve.*?y //; # I am very cold
+
+Notice how the second substitution stopped matching as soon as it
+encountered "y ". The C<*?> quantifier effectively tells the regular
+expression engine to find a match as quickly as possible and pass
+control on to whatever is next in line, like you would if you were
+playing hot potato.
+
+=head2 How do I process each word on each line?
+
+Use the split function:
+
+ while (<>) {
+ foreach $word ( split ) {
+ # do something with $word here
+ }
+ }
+
+Note that this isn't really a word in the English sense; it's just
+chunks of consecutive non-whitespace characters.
+
+To work with only alphanumeric sequences, you might consider
+
+ while (<>) {
+ foreach $word (m/(\w+)/g) {
+ # do something with $word here
+ }
+ }
+
+=head2 How can I print out a word-frequency or line-frequency summary?
+
+To do this, you have to parse out each word in the input stream. We'll
+pretend that by word you mean chunk of alphabetics, hyphens, or
+apostrophes, rather than the non-whitespace chunk idea of a word given
+in the previous question:
+
+ while (<>) {
+ while ( /(\b[^\W_\d][\w'-]+\b)/g ) { # misses "`sheep'"
+ $seen{$1}++;
+ }
+ }
+ while ( ($word, $count) = each %seen ) {
+ print "$count $word\n";
+ }
+
+If you wanted to do the same thing for lines, you wouldn't need a
+regular expression:
+
+ while (<>) {
+ $seen{$_}++;
+ }
+ while ( ($line, $count) = each %seen ) {
+ print "$count $line";
+ }
+
+If you want these output in a sorted order, see the section on Hashes.
+
+=head2 How can I do approximate matching?
+
+See the module String::Approx available from CPAN.
+
+=head2 How do I efficiently match many regular expressions at once?
+
+The following is super-inefficient:
+
+ while (<FH>) {
+ foreach $pat (@patterns) {
+ if ( /$pat/ ) {
+ # do something
+ }
+ }
+ }
+
+Instead, you either need to use one of the experimental Regexp extension
+modules from CPAN (which might well be overkill for your purposes),
+or else put together something like this, inspired from a routine
+in Jeffrey Friedl's book:
+
+ sub _bm_build {
+ my $condition = shift;
+ my @regexp = @_; # this MUST not be local(); need my()
+ my $expr = join $condition => map { "m/\$regexp[$_]/o" } (0..$#regexp);
+ my $match_func = eval "sub { $expr }";
+ die if $@; # propagate $@; this shouldn't happen!
+ return $match_func;
+ }
+
+ sub bm_and { _bm_build('&&', @_) }
+ sub bm_or { _bm_build('||', @_) }
+
+ $f1 = bm_and qw{
+ xterm
+ (?i)window
+ };
+
+ $f2 = bm_or qw{
+ \b[Ff]ree\b
+ \bBSD\B
+ (?i)sys(tem)?\s*[V5]\b
+ };
+
+ # feed me /etc/termcap, prolly
+ while ( <> ) {
+ print "1: $_" if &$f1;
+ print "2: $_" if &$f2;
+ }
+
+=head2 Why don't word-boundary searches with C<\b> work for me?
+
+Two common misconceptions are that C<\b> is a synonym for C<\s+>, and
+that it's the edge between whitespace characters and non-whitespace
+characters. Neither is correct. C<\b> is the place between a C<\w>
+character and a C<\W> character (that is, C<\b> is the edge of a
+"word"). It's a zero-width assertion, just like C<^>, C<$>, and all
+the other anchors, so it doesn't consume any characters. L<perlre>
+describes the behaviour of all the regexp metacharacters.
+
+Here are examples of the incorrect application of C<\b>, with fixes:
+
+ "two words" =~ /(\w+)\b(\w+)/; # WRONG
+ "two words" =~ /(\w+)\s+(\w+)/; # right
+
+ " =matchless= text" =~ /\b=(\w+)=\b/; # WRONG
+ " =matchless= text" =~ /=(\w+)=/; # right
+
+Although they may not do what you thought they did, C<\b> and C<\B>
+can still be quite useful. For an example of the correct use of
+C<\b>, see the example of matching duplicate words over multiple
+lines.
+
+An example of using C<\B> is the pattern C<\Bis\B>. This will find
+occurrences of "is" on the insides of words only, as in "thistle", but
+not "this" or "island".
+
+=head2 Why does using $&, $`, or $' slow my program down?
+
+Because once Perl sees that you need one of these variables anywhere
+in the program, it has to provide them on each and every pattern
+match. The same mechanism that handles these provides for the use of
+$1, $2, etc., so you pay the same price for each regexp that contains
+capturing parentheses. But if you never use $&, etc., in your script,
+then regexps I<without> capturing parentheses won't be penalized. So
+avoid $&, $', and $` if you can, but if you can't (and some algorithms
+really appreciate them), once you've used them once, use them at will,
+because you've already paid the price.
+
+=head2 What good is C<\G> in a regular expression?
+
+The notation C<\G> is used in a match or substitution in conjunction the
+C</g> modifier (and ignored if there's no C</g>) to anchor the regular
+expression to the point just past where the last match occurred, i.e. the
+pos() point.
+
+For example, suppose you had a line of text quoted in standard mail
+and Usenet notation, (that is, with leading C<E<gt>> characters), and
+you want change each leading C<E<gt>> into a corresponding C<:>. You
+could do so in this way:
+
+ s/^(>+)/':' x length($1)/gem;
+
+Or, using C<\G>, the much simpler (and faster):
+
+ s/\G>/:/g;
+
+A more sophisticated use might involve a tokenizer. The following
+lex-like example is courtesy of Jeffrey Friedl. It did not work in
+5.003 due to bugs in that release, but does work in 5.004 or better.
+(Note the use of C</c>, which prevents a failed match with C</g> from
+resetting the search position back to the beginning of the string.)
+
+ while (<>) {
+ chomp;
+ PARSER: {
+ m/ \G( \d+\b )/gcx && do { print "number: $1\n"; redo; };
+ m/ \G( \w+ )/gcx && do { print "word: $1\n"; redo; };
+ m/ \G( \s+ )/gcx && do { print "space: $1\n"; redo; };
+ m/ \G( [^\w\d]+ )/gcx && do { print "other: $1\n"; redo; };
+ }
+ }
+
+Of course, that could have been written as
+
+ while (<>) {
+ chomp;
+ PARSER: {
+ if ( /\G( \d+\b )/gcx {
+ print "number: $1\n";
+ redo PARSER;
+ }
+ if ( /\G( \w+ )/gcx {
+ print "word: $1\n";
+ redo PARSER;
+ }
+ if ( /\G( \s+ )/gcx {
+ print "space: $1\n";
+ redo PARSER;
+ }
+ if ( /\G( [^\w\d]+ )/gcx {
+ print "other: $1\n";
+ redo PARSER;
+ }
+ }
+ }
+
+But then you lose the vertical alignment of the regular expressions.
+
+=head2 Are Perl regexps DFAs or NFAs? Are they POSIX compliant?
+
+While it's true that Perl's regular expressions resemble the DFAs
+(deterministic finite automata) of the egrep(1) program, they are in
+fact implemented as NFAs (non-deterministic finite automata) to allow
+backtracking and backreferencing. And they aren't POSIX-style either,
+because those guarantee worst-case behavior for all cases. (It seems
+that some people prefer guarantees of consistency, even when what's
+guaranteed is slowness.) See the book "Mastering Regular Expressions"
+(from O'Reilly) by Jeffrey Friedl for all the details you could ever
+hope to know on these matters (a full citation appears in
+L<perlfaq2>).
+
+=head2 What's wrong with using grep or map in a void context?
+
+Both grep and map build a return list, regardless of their context.
+This means you're making Perl go to the trouble of building up a
+return list that you then just ignore. That's no way to treat a
+programming language, you insensitive scoundrel!
+
+=head2 How can I match strings with multibyte characters?
+
+This is hard, and there's no good way. Perl does not directly support
+wide characters. It pretends that a byte and a character are
+synonymous. The following set of approaches was offered by Jeffrey
+Friedl, whose article in issue #5 of The Perl Journal talks about this
+very matter.
+
+Let's suppose you have some weird Martian encoding where pairs of
+ASCII uppercase letters encode single Martian letters (i.e. the two
+bytes "CV" make a single Martian letter, as do the two bytes "SG",
+"VS", "XX", etc.). Other bytes represent single characters, just like
+ASCII.
+
+So, the string of Martian "I am CVSGXX!" uses 12 bytes to encode the
+nine characters 'I', ' ', 'a', 'm', ' ', 'CV', 'SG', 'XX', '!'.
+
+Now, say you want to search for the single character C</GX/>. Perl
+doesn't know about Martian, so it'll find the two bytes "GX" in the "I
+am CVSGXX!" string, even though that character isn't there: it just
+looks like it is because "SG" is next to "XX", but there's no real
+"GX". This is a big problem.
+
+Here are a few ways, all painful, to deal with it:
+
+ $martian =~ s/([A-Z][A-Z])/ $1 /g; # Make sure adjacent ``martian'' bytes
+ # are no longer adjacent.
+ print "found GX!\n" if $martian =~ /GX/;
+
+Or like this:
+
+ @chars = $martian =~ m/([A-Z][A-Z]|[^A-Z])/g;
+ # above is conceptually similar to: @chars = $text =~ m/(.)/g;
+ #
+ foreach $char (@chars) {
+ print "found GX!\n", last if $char eq 'GX';
+ }
+
+Or like this:
+
+ while ($martian =~ m/\G([A-Z][A-Z]|.)/gs) { # \G probably unneeded
+ print "found GX!\n", last if $1 eq 'GX';
+ }
+
+Or like this:
+
+ die "sorry, Perl doesn't (yet) have Martian support )-:\n";
+
+In addition, a sample program which converts half-width to full-width
+katakana (in Shift-JIS or EUC encoding) is available from CPAN as
+
+=for Tom make it so
+
+There are many double- (and multi-) byte encodings commonly used these
+days. Some versions of these have 1-, 2-, 3-, and 4-byte characters,
+all mixed.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq7.pod b/contrib/perl5/pod/perlfaq7.pod
new file mode 100644
index 0000000..e1bccc8
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq7.pod
@@ -0,0 +1,816 @@
+=head1 NAME
+
+perlfaq7 - Perl Language Issues ($Revision: 1.21 $, $Date: 1998/06/22 15:20:07 $)
+
+=head1 DESCRIPTION
+
+This section deals with general Perl language issues that don't
+clearly fit into any of the other sections.
+
+=head2 Can I get a BNF/yacc/RE for the Perl language?
+
+There is no BNF, but you can paw your way through the yacc grammar in
+perly.y in the source distribution if you're particularly brave. The
+grammar relies on very smart tokenizing code, so be prepared to
+venture into toke.c as well.
+
+In the words of Chaim Frenkel: "Perl's grammar can not be reduced to BNF.
+The work of parsing perl is distributed between yacc, the lexer, smoke
+and mirrors."
+
+=head2 What are all these $@%* punctuation signs, and how do I know when to use them?
+
+They are type specifiers, as detailed in L<perldata>:
+
+ $ for scalar values (number, string or reference)
+ @ for arrays
+ % for hashes (associative arrays)
+ * for all types of that symbol name. In version 4 you used them like
+ pointers, but in modern perls you can just use references.
+
+While there are a few places where you don't actually need these type
+specifiers, you should always use them.
+
+A couple of others that you're likely to encounter that aren't
+really type specifiers are:
+
+ <> are used for inputting a record from a filehandle.
+ \ takes a reference to something.
+
+Note that E<lt>FILEE<gt> is I<neither> the type specifier for files
+nor the name of the handle. It is the C<E<lt>E<gt>> operator applied
+to the handle FILE. It reads one line (well, record - see
+L<perlvar/$/>) from the handle FILE in scalar context, or I<all> lines
+in list context. When performing open, close, or any other operation
+besides C<E<lt>E<gt>> on files, or even talking about the handle, do
+I<not> use the brackets. These are correct: C<eof(FH)>, C<seek(FH, 0,
+2)> and "copying from STDIN to FILE".
+
+=head2 Do I always/never have to quote my strings or use semicolons and commas?
+
+Normally, a bareword doesn't need to be quoted, but in most cases
+probably should be (and must be under C<use strict>). But a hash key
+consisting of a simple word (that isn't the name of a defined
+subroutine) and the left-hand operand to the C<=E<gt>> operator both
+count as though they were quoted:
+
+ This is like this
+ ------------ ---------------
+ $foo{line} $foo{"line"}
+ bar => stuff "bar" => stuff
+
+The final semicolon in a block is optional, as is the final comma in a
+list. Good style (see L<perlstyle>) says to put them in except for
+one-liners:
+
+ if ($whoops) { exit 1 }
+ @nums = (1, 2, 3);
+
+ if ($whoops) {
+ exit 1;
+ }
+ @lines = (
+ "There Beren came from mountains cold",
+ "And lost he wandered under leaves",
+ );
+
+=head2 How do I skip some return values?
+
+One way is to treat the return values as a list and index into it:
+
+ $dir = (getpwnam($user))[7];
+
+Another way is to use undef as an element on the left-hand-side:
+
+ ($dev, $ino, undef, undef, $uid, $gid) = stat($file);
+
+=head2 How do I temporarily block warnings?
+
+The C<$^W> variable (documented in L<perlvar>) controls
+runtime warnings for a block:
+
+ {
+ local $^W = 0; # temporarily turn off warnings
+ $a = $b + $c; # I know these might be undef
+ }
+
+Note that like all the punctuation variables, you cannot currently
+use my() on C<$^W>, only local().
+
+A new C<use warnings> pragma is in the works to provide finer control
+over all this. The curious should check the perl5-porters mailing list
+archives for details.
+
+=head2 What's an extension?
+
+A way of calling compiled C code from Perl. Reading L<perlxstut>
+is a good place to learn more about extensions.
+
+=head2 Why do Perl operators have different precedence than C operators?
+
+Actually, they don't. All C operators that Perl copies have the same
+precedence in Perl as they do in C. The problem is with operators that C
+doesn't have, especially functions that give a list context to everything
+on their right, eg print, chmod, exec, and so on. Such functions are
+called "list operators" and appear as such in the precedence table in
+L<perlop>.
+
+A common mistake is to write:
+
+ unlink $file || die "snafu";
+
+This gets interpreted as:
+
+ unlink ($file || die "snafu");
+
+To avoid this problem, either put in extra parentheses or use the
+super low precedence C<or> operator:
+
+ (unlink $file) || die "snafu";
+ unlink $file or die "snafu";
+
+The "English" operators (C<and>, C<or>, C<xor>, and C<not>)
+deliberately have precedence lower than that of list operators for
+just such situations as the one above.
+
+Another operator with surprising precedence is exponentiation. It
+binds more tightly even than unary minus, making C<-2**2> product a
+negative not a positive four. It is also right-associating, meaning
+that C<2**3**2> is two raised to the ninth power, not eight squared.
+
+Although it has the same precedence as in C, Perl's C<?:> operator
+produces an lvalue. This assigns $x to either $a or $b, depending
+on the trueness of $maybe:
+
+ ($maybe ? $a : $b) = $x;
+
+=head2 How do I declare/create a structure?
+
+In general, you don't "declare" a structure. Just use a (probably
+anonymous) hash reference. See L<perlref> and L<perldsc> for details.
+Here's an example:
+
+ $person = {}; # new anonymous hash
+ $person->{AGE} = 24; # set field AGE to 24
+ $person->{NAME} = "Nat"; # set field NAME to "Nat"
+
+If you're looking for something a bit more rigorous, try L<perltoot>.
+
+=head2 How do I create a module?
+
+A module is a package that lives in a file of the same name. For
+example, the Hello::There module would live in Hello/There.pm. For
+details, read L<perlmod>. You'll also find L<Exporter> helpful. If
+you're writing a C or mixed-language module with both C and Perl, then
+you should study L<perlxstut>.
+
+Here's a convenient template you might wish you use when starting your
+own module. Make sure to change the names appropriately.
+
+ package Some::Module; # assumes Some/Module.pm
+
+ use strict;
+
+ BEGIN {
+ use Exporter ();
+ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+ ## set the version for version checking; uncomment to use
+ ## $VERSION = 1.00;
+
+ # if using RCS/CVS, this next line may be preferred,
+ # but beware two-digit versions.
+ $VERSION = do{my@r=q$Revision: 1.21 $=~/\d+/g;sprintf '%d.'.'%02d'x$#r,@r};
+
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&func1 &func2 &func3);
+ %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+
+ # your exported package globals go here,
+ # as well as any optionally exported functions
+ @EXPORT_OK = qw($Var1 %Hashit);
+ }
+ use vars @EXPORT_OK;
+
+ # non-exported package globals go here
+ use vars qw( @more $stuff );
+
+ # initialize package globals, first exported ones
+ $Var1 = '';
+ %Hashit = ();
+
+ # then the others (which are still accessible as $Some::Module::stuff)
+ $stuff = '';
+ @more = ();
+
+ # all file-scoped lexicals must be created before
+ # the functions below that use them.
+
+ # file-private lexicals go here
+ my $priv_var = '';
+ my %secret_hash = ();
+
+ # here's a file-private function as a closure,
+ # callable as &$priv_func; it cannot be prototyped.
+ my $priv_func = sub {
+ # stuff goes here.
+ };
+
+ # make all your functions, whether exported or not;
+ # remember to put something interesting in the {} stubs
+ sub func1 {} # no prototype
+ sub func2() {} # proto'd void
+ sub func3($$) {} # proto'd to 2 scalars
+
+ # this one isn't exported, but could be called!
+ sub func4(\%) {} # proto'd to 1 hash ref
+
+ END { } # module clean-up code here (global destructor)
+
+ 1; # modules must return true
+
+=head2 How do I create a class?
+
+See L<perltoot> for an introduction to classes and objects, as well as
+L<perlobj> and L<perlbot>.
+
+=head2 How can I tell if a variable is tainted?
+
+See L<perlsec/"Laundering and Detecting Tainted Data">. Here's an
+example (which doesn't use any system calls, because the kill()
+is given no processes to signal):
+
+ sub is_tainted {
+ return ! eval { join('',@_), kill 0; 1; };
+ }
+
+This is not C<-w> clean, however. There is no C<-w> clean way to
+detect taintedness - take this as a hint that you should untaint
+all possibly-tainted data.
+
+=head2 What's a closure?
+
+Closures are documented in L<perlref>.
+
+I<Closure> is a computer science term with a precise but
+hard-to-explain meaning. Closures are implemented in Perl as anonymous
+subroutines with lasting references to lexical variables outside their
+own scopes. These lexicals magically refer to the variables that were
+around when the subroutine was defined (deep binding).
+
+Closures make sense in any programming language where you can have the
+return value of a function be itself a function, as you can in Perl.
+Note that some languages provide anonymous functions but are not
+capable of providing proper closures; the Python language, for
+example. For more information on closures, check out any textbook on
+functional programming. Scheme is a language that not only supports
+but encourages closures.
+
+Here's a classic function-generating function:
+
+ sub add_function_generator {
+ return sub { shift + shift };
+ }
+
+ $add_sub = add_function_generator();
+ $sum = $add_sub->(4,5); # $sum is 9 now.
+
+The closure works as a I<function template> with some customization
+slots left out to be filled later. The anonymous subroutine returned
+by add_function_generator() isn't technically a closure because it
+refers to no lexicals outside its own scope.
+
+Contrast this with the following make_adder() function, in which the
+returned anonymous function contains a reference to a lexical variable
+outside the scope of that function itself. Such a reference requires
+that Perl return a proper closure, thus locking in for all time the
+value that the lexical had when the function was created.
+
+ sub make_adder {
+ my $addpiece = shift;
+ return sub { shift + $addpiece };
+ }
+
+ $f1 = make_adder(20);
+ $f2 = make_adder(555);
+
+Now C<&$f1($n)> is always 20 plus whatever $n you pass in, whereas
+C<&$f2($n)> is always 555 plus whatever $n you pass in. The $addpiece
+in the closure sticks around.
+
+Closures are often used for less esoteric purposes. For example, when
+you want to pass in a bit of code into a function:
+
+ my $line;
+ timeout( 30, sub { $line = <STDIN> } );
+
+If the code to execute had been passed in as a string, C<'$line =
+E<lt>STDINE<gt>'>, there would have been no way for the hypothetical
+timeout() function to access the lexical variable $line back in its
+caller's scope.
+
+=head2 What is variable suicide and how can I prevent it?
+
+Variable suicide is when you (temporarily or permanently) lose the
+value of a variable. It is caused by scoping through my() and local()
+interacting with either closures or aliased foreach() interator
+variables and subroutine arguments. It used to be easy to
+inadvertently lose a variable's value this way, but now it's much
+harder. Take this code:
+
+ my $f = "foo";
+ sub T {
+ while ($i++ < 3) { my $f = $f; $f .= "bar"; print $f, "\n" }
+ }
+ T;
+ print "Finally $f\n";
+
+The $f that has "bar" added to it three times should be a new C<$f>
+(C<my $f> should create a new local variable each time through the
+loop). It isn't, however. This is a bug, and will be fixed.
+
+=head2 How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regexp}?
+
+With the exception of regexps, you need to pass references to these
+objects. See L<perlsub/"Pass by Reference"> for this particular
+question, and L<perlref> for information on references.
+
+=over 4
+
+=item Passing Variables and Functions
+
+Regular variables and functions are quite easy: just pass in a
+reference to an existing or anonymous variable or function:
+
+ func( \$some_scalar );
+
+ func( \$some_array );
+ func( [ 1 .. 10 ] );
+
+ func( \%some_hash );
+ func( { this => 10, that => 20 } );
+
+ func( \&some_func );
+ func( sub { $_[0] ** $_[1] } );
+
+=item Passing Filehandles
+
+To pass filehandles to subroutines, use the C<*FH> or C<\*FH> notations.
+These are "typeglobs" - see L<perldata/"Typeglobs and Filehandles">
+and especially L<perlsub/"Pass by Reference"> for more information.
+
+Here's an excerpt:
+
+If you're passing around filehandles, you could usually just use the bare
+typeglob, like *STDOUT, but typeglobs references would be better because
+they'll still work properly under C<use strict 'refs'>. For example:
+
+ splutter(\*STDOUT);
+ sub splutter {
+ my $fh = shift;
+ print $fh "her um well a hmmm\n";
+ }
+
+ $rec = get_rec(\*STDIN);
+ sub get_rec {
+ my $fh = shift;
+ return scalar <$fh>;
+ }
+
+If you're planning on generating new filehandles, you could do this:
+
+ sub openit {
+ my $name = shift;
+ local *FH;
+ return open (FH, $path) ? *FH : undef;
+ }
+ $fh = openit('< /etc/motd');
+ print <$fh>;
+
+=item Passing Regexps
+
+To pass regexps around, you'll need to either use one of the highly
+experimental regular expression modules from CPAN (Nick Ing-Simmons's
+Regexp or Ilya Zakharevich's Devel::Regexp), pass around strings
+and use an exception-trapping eval, or else be be very, very clever.
+Here's an example of how to pass in a string to be regexp compared:
+
+ sub compare($$) {
+ my ($val1, $regexp) = @_;
+ my $retval = eval { $val =~ /$regexp/ };
+ die if $@;
+ return $retval;
+ }
+
+ $match = compare("old McDonald", q/d.*D/);
+
+Make sure you never say something like this:
+
+ return eval "\$val =~ /$regexp/"; # WRONG
+
+or someone can sneak shell escapes into the regexp due to the double
+interpolation of the eval and the double-quoted string. For example:
+
+ $pattern_of_evil = 'danger ${ system("rm -rf * &") } danger';
+
+ eval "\$string =~ /$pattern_of_evil/";
+
+Those preferring to be very, very clever might see the O'Reilly book,
+I<Mastering Regular Expressions>, by Jeffrey Friedl. Page 273's
+Build_MatchMany_Function() is particularly interesting. A complete
+citation of this book is given in L<perlfaq2>.
+
+=item Passing Methods
+
+To pass an object method into a subroutine, you can do this:
+
+ call_a_lot(10, $some_obj, "methname")
+ sub call_a_lot {
+ my ($count, $widget, $trick) = @_;
+ for (my $i = 0; $i < $count; $i++) {
+ $widget->$trick();
+ }
+ }
+
+Or you can use a closure to bundle up the object and its method call
+and arguments:
+
+ my $whatnot = sub { $some_obj->obfuscate(@args) };
+ func($whatnot);
+ sub func {
+ my $code = shift;
+ &$code();
+ }
+
+You could also investigate the can() method in the UNIVERSAL class
+(part of the standard perl distribution).
+
+=back
+
+=head2 How do I create a static variable?
+
+As with most things in Perl, TMTOWTDI. What is a "static variable" in
+other languages could be either a function-private variable (visible
+only within a single function, retaining its value between calls to
+that function), or a file-private variable (visible only to functions
+within the file it was declared in) in Perl.
+
+Here's code to implement a function-private variable:
+
+ BEGIN {
+ my $counter = 42;
+ sub prev_counter { return --$counter }
+ sub next_counter { return $counter++ }
+ }
+
+Now prev_counter() and next_counter() share a private variable $counter
+that was initialized at compile time.
+
+To declare a file-private variable, you'll still use a my(), putting
+it at the outer scope level at the top of the file. Assume this is in
+file Pax.pm:
+
+ package Pax;
+ my $started = scalar(localtime(time()));
+
+ sub begun { return $started }
+
+When C<use Pax> or C<require Pax> loads this module, the variable will
+be initialized. It won't get garbage-collected the way most variables
+going out of scope do, because the begun() function cares about it,
+but no one else can get it. It is not called $Pax::started because
+its scope is unrelated to the package. It's scoped to the file. You
+could conceivably have several packages in that same file all
+accessing the same private variable, but another file with the same
+package couldn't get to it.
+
+See L<perlsub/"Peristent Private Variables"> for details.
+
+=head2 What's the difference between dynamic and lexical (static) scoping? Between local() and my()?
+
+C<local($x)> saves away the old value of the global variable C<$x>,
+and assigns a new value for the duration of the subroutine, I<which is
+visible in other functions called from that subroutine>. This is done
+at run-time, so is called dynamic scoping. local() always affects global
+variables, also called package variables or dynamic variables.
+
+C<my($x)> creates a new variable that is only visible in the current
+subroutine. This is done at compile-time, so is called lexical or
+static scoping. my() always affects private variables, also called
+lexical variables or (improperly) static(ly scoped) variables.
+
+For instance:
+
+ sub visible {
+ print "var has value $var\n";
+ }
+
+ sub dynamic {
+ local $var = 'local'; # new temporary value for the still-global
+ visible(); # variable called $var
+ }
+
+ sub lexical {
+ my $var = 'private'; # new private variable, $var
+ visible(); # (invisible outside of sub scope)
+ }
+
+ $var = 'global';
+
+ visible(); # prints global
+ dynamic(); # prints local
+ lexical(); # prints global
+
+Notice how at no point does the value "private" get printed. That's
+because $var only has that value within the block of the lexical()
+function, and it is hidden from called subroutine.
+
+In summary, local() doesn't make what you think of as private, local
+variables. It gives a global variable a temporary value. my() is
+what you're looking for if you want private variables.
+
+See L<perlsub/"Private Variables via my()"> and L<perlsub/"Temporary
+Values via local()"> for excruciating details.
+
+=head2 How can I access a dynamic variable while a similarly named lexical is in scope?
+
+You can do this via symbolic references, provided you haven't set
+C<use strict "refs">. So instead of $var, use C<${'var'}>.
+
+ local $var = "global";
+ my $var = "lexical";
+
+ print "lexical is $var\n";
+
+ no strict 'refs';
+ print "global is ${'var'}\n";
+
+If you know your package, you can just mention it explicitly, as in
+$Some_Pack::var. Note that the notation $::var is I<not> the dynamic
+$var in the current package, but rather the one in the C<main>
+package, as though you had written $main::var. Specifying the package
+directly makes you hard-code its name, but it executes faster and
+avoids running afoul of C<use strict "refs">.
+
+=head2 What's the difference between deep and shallow binding?
+
+In deep binding, lexical variables mentioned in anonymous subroutines
+are the same ones that were in scope when the subroutine was created.
+In shallow binding, they are whichever variables with the same names
+happen to be in scope when the subroutine is called. Perl always uses
+deep binding of lexical variables (i.e., those created with my()).
+However, dynamic variables (aka global, local, or package variables)
+are effectively shallowly bound. Consider this just one more reason
+not to use them. See the answer to L<"What's a closure?">.
+
+=head2 Why doesn't "my($foo) = <FILE>;" work right?
+
+C<my()> and C<local()> give list context to the right hand side
+of C<=>. The E<lt>FHE<gt> read operation, like so many of Perl's
+functions and operators, can tell which context it was called in and
+behaves appropriately. In general, the scalar() function can help.
+This function does nothing to the data itself (contrary to popular myth)
+but rather tells its argument to behave in whatever its scalar fashion is.
+If that function doesn't have a defined scalar behavior, this of course
+doesn't help you (such as with sort()).
+
+To enforce scalar context in this particular case, however, you need
+merely omit the parentheses:
+
+ local($foo) = <FILE>; # WRONG
+ local($foo) = scalar(<FILE>); # ok
+ local $foo = <FILE>; # right
+
+You should probably be using lexical variables anyway, although the
+issue is the same here:
+
+ my($foo) = <FILE>; # WRONG
+ my $foo = <FILE>; # right
+
+=head2 How do I redefine a builtin function, operator, or method?
+
+Why do you want to do that? :-)
+
+If you want to override a predefined function, such as open(),
+then you'll have to import the new definition from a different
+module. See L<perlsub/"Overriding Builtin Functions">. There's
+also an example in L<perltoot/"Class::Template">.
+
+If you want to overload a Perl operator, such as C<+> or C<**>,
+then you'll want to use the C<use overload> pragma, documented
+in L<overload>.
+
+If you're talking about obscuring method calls in parent classes,
+see L<perltoot/"Overridden Methods">.
+
+=head2 What's the difference between calling a function as &foo and foo()?
+
+When you call a function as C<&foo>, you allow that function access to
+your current @_ values, and you by-pass prototypes. That means that
+the function doesn't get an empty @_, it gets yours! While not
+strictly speaking a bug (it's documented that way in L<perlsub>), it
+would be hard to consider this a feature in most cases.
+
+When you call your function as C<&foo()>, then you I<do> get a new @_,
+but prototyping is still circumvented.
+
+Normally, you want to call a function using C<foo()>. You may only
+omit the parentheses if the function is already known to the compiler
+because it already saw the definition (C<use> but not C<require>),
+or via a forward reference or C<use subs> declaration. Even in this
+case, you get a clean @_ without any of the old values leaking through
+where they don't belong.
+
+=head2 How do I create a switch or case statement?
+
+This is explained in more depth in the L<perlsyn>. Briefly, there's
+no official case statement, because of the variety of tests possible
+in Perl (numeric comparison, string comparison, glob comparison,
+regexp matching, overloaded comparisons, ...). Larry couldn't decide
+how best to do this, so he left it out, even though it's been on the
+wish list since perl1.
+
+The general answer is to write a construct like this:
+
+ for ($variable_to_test) {
+ if (/pat1/) { } # do something
+ elsif (/pat2/) { } # do something else
+ elsif (/pat3/) { } # do something else
+ else { } # default
+ }
+
+Here's a simple example of a switch based on pattern matching, this
+time lined up in a way to make it look more like a switch statement.
+We'll do a multi-way conditional based on the type of reference stored
+in $whatchamacallit:
+
+ SWITCH: for (ref $whatchamacallit) {
+
+ /^$/ && die "not a reference";
+
+ /SCALAR/ && do {
+ print_scalar($$ref);
+ last SWITCH;
+ };
+
+ /ARRAY/ && do {
+ print_array(@$ref);
+ last SWITCH;
+ };
+
+ /HASH/ && do {
+ print_hash(%$ref);
+ last SWITCH;
+ };
+
+ /CODE/ && do {
+ warn "can't print function ref";
+ last SWITCH;
+ };
+
+ # DEFAULT
+
+ warn "User defined type skipped";
+
+ }
+
+See C<perlsyn/"Basic BLOCKs and Switch Statements"> for many other
+examples in this style.
+
+Sometimes you should change the positions of the constant and the variable.
+For example, let's say you wanted to test which of many answers you were
+given, but in a case-insensitive way that also allows abbreviations.
+You can use the following technique if the strings all start with
+different characters, or if you want to arrange the matches so that
+one takes precedence over another, as C<"SEND"> has precedence over
+C<"STOP"> here:
+
+ chomp($answer = <>);
+ if ("SEND" =~ /^\Q$answer/i) { print "Action is send\n" }
+ elsif ("STOP" =~ /^\Q$answer/i) { print "Action is stop\n" }
+ elsif ("ABORT" =~ /^\Q$answer/i) { print "Action is abort\n" }
+ elsif ("LIST" =~ /^\Q$answer/i) { print "Action is list\n" }
+ elsif ("EDIT" =~ /^\Q$answer/i) { print "Action is edit\n" }
+
+A totally different approach is to create a hash of function references.
+
+ my %commands = (
+ "happy" => \&joy,
+ "sad", => \&sullen,
+ "done" => sub { die "See ya!" },
+ "mad" => \&angry,
+ );
+
+ print "How are you? ";
+ chomp($string = <STDIN>);
+ if ($commands{$string}) {
+ $commands{$string}->();
+ } else {
+ print "No such command: $string\n";
+ }
+
+=head2 How can I catch accesses to undefined variables/functions/methods?
+
+The AUTOLOAD method, discussed in L<perlsub/"Autoloading"> and
+L<perltoot/"AUTOLOAD: Proxy Methods">, lets you capture calls to
+undefined functions and methods.
+
+When it comes to undefined variables that would trigger a warning
+under C<-w>, you can use a handler to trap the pseudo-signal
+C<__WARN__> like this:
+
+ $SIG{__WARN__} = sub {
+
+ for ( $_[0] ) { # voici un switch statement
+
+ /Use of uninitialized value/ && do {
+ # promote warning to a fatal
+ die $_;
+ };
+
+ # other warning cases to catch could go here;
+
+ warn $_;
+ }
+
+ };
+
+=head2 Why can't a method included in this same file be found?
+
+Some possible reasons: your inheritance is getting confused, you've
+misspelled the method name, or the object is of the wrong type. Check
+out L<perltoot> for details on these. You may also use C<print
+ref($object)> to find out the class C<$object> was blessed into.
+
+Another possible reason for problems is because you've used the
+indirect object syntax (eg, C<find Guru "Samy">) on a class name
+before Perl has seen that such a package exists. It's wisest to make
+sure your packages are all defined before you start using them, which
+will be taken care of if you use the C<use> statement instead of
+C<require>. If not, make sure to use arrow notation (eg,
+C<Guru-E<gt>find("Samy")>) instead. Object notation is explained in
+L<perlobj>.
+
+Make sure to read about creating modules in L<perlmod> and
+the perils of indirect objects in L<perlobj/"WARNING">.
+
+=head2 How can I find out my current package?
+
+If you're just a random program, you can do this to find
+out what the currently compiled package is:
+
+ my $packname = __PACKAGE__;
+
+But if you're a method and you want to print an error message
+that includes the kind of object you were called on (which is
+not necessarily the same as the one in which you were compiled):
+
+ sub amethod {
+ my $self = shift;
+ my $class = ref($self) || $self;
+ warn "called me from a $class object";
+ }
+
+=head2 How can I comment out a large block of perl code?
+
+Use embedded POD to discard it:
+
+ # program is here
+
+ =for nobody
+ This paragraph is commented out
+
+ # program continues
+
+ =begin comment text
+
+ all of this stuff
+
+ here will be ignored
+ by everyone
+
+ =end comment text
+
+ =cut
+
+This can't go just anywhere. You have to put a pod directive where
+the parser is expecting a new statement, not just in the middle
+of an expression or some other arbitrary yacc grammar production.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq8.pod b/contrib/perl5/pod/perlfaq8.pod
new file mode 100644
index 0000000..c4036ff
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq8.pod
@@ -0,0 +1,1075 @@
+=head1 NAME
+
+perlfaq8 - System Interaction ($Revision: 1.26 $, $Date: 1998/08/05 12:20:28 $)
+
+=head1 DESCRIPTION
+
+This section of the Perl FAQ covers questions involving operating
+system interaction. This involves interprocess communication (IPC),
+control over the user-interface (keyboard, screen and pointing
+devices), and most anything else not related to data manipulation.
+
+Read the FAQs and documentation specific to the port of perl to your
+operating system (eg, L<perlvms>, L<perlplan9>, ...). These should
+contain more detailed information on the vagaries of your perl.
+
+=head2 How do I find out which operating system I'm running under?
+
+The $^O variable ($OSNAME if you use English) contains the operating
+system that your perl binary was built for.
+
+=head2 How come exec() doesn't return?
+
+Because that's what it does: it replaces your currently running
+program with a different one. If you want to keep going (as is
+probably the case if you're asking this question) use system()
+instead.
+
+=head2 How do I do fancy stuff with the keyboard/screen/mouse?
+
+How you access/control keyboards, screens, and pointing devices
+("mice") is system-dependent. Try the following modules:
+
+=over 4
+
+=item Keyboard
+
+ Term::Cap Standard perl distribution
+ Term::ReadKey CPAN
+ Term::ReadLine::Gnu CPAN
+ Term::ReadLine::Perl CPAN
+ Term::Screen CPAN
+
+=item Screen
+
+ Term::Cap Standard perl distribution
+ Curses CPAN
+ Term::ANSIColor CPAN
+
+=item Mouse
+
+ Tk CPAN
+
+=back
+
+Some of these specific cases are shown below.
+
+=head2 How do I print something out in color?
+
+In general, you don't, because you don't know whether
+the recipient has a color-aware display device. If you
+know that they have an ANSI terminal that understands
+color, you can use the Term::ANSIColor module from CPAN:
+
+ use Term::ANSIColor;
+ print color("red"), "Stop!\n", color("reset");
+ print color("green"), "Go!\n", color("reset");
+
+Or like this:
+
+ use Term::ANSIColor qw(:constants);
+ print RED, "Stop!\n", RESET;
+ print GREEN, "Go!\n", RESET;
+
+=head2 How do I read just one key without waiting for a return key?
+
+Controlling input buffering is a remarkably system-dependent matter.
+If most systems, you can just use the B<stty> command as shown in
+L<perlfunc/getc>, but as you see, that's already getting you into
+portability snags.
+
+ open(TTY, "+</dev/tty") or die "no tty: $!";
+ system "stty cbreak </dev/tty >/dev/tty 2>&1";
+ $key = getc(TTY); # perhaps this works
+ # OR ELSE
+ sysread(TTY, $key, 1); # probably this does
+ system "stty -cbreak </dev/tty >/dev/tty 2>&1";
+
+The Term::ReadKey module from CPAN offers an easy-to-use interface that
+should be more efficient than shelling out to B<stty> for each key.
+It even includes limited support for Windows.
+
+ use Term::ReadKey;
+ ReadMode('cbreak');
+ $key = ReadKey(0);
+ ReadMode('normal');
+
+However, that requires that you have a working C compiler and can use it
+to build and install a CPAN module. Here's a solution using
+the standard POSIX module, which is already on your systems (assuming
+your system supports POSIX).
+
+ use HotKey;
+ $key = readkey();
+
+And here's the HotKey module, which hides the somewhat mystifying calls
+to manipulate the POSIX termios structures.
+
+ # HotKey.pm
+ package HotKey;
+
+ @ISA = qw(Exporter);
+ @EXPORT = qw(cbreak cooked readkey);
+
+ use strict;
+ use POSIX qw(:termios_h);
+ my ($term, $oterm, $echo, $noecho, $fd_stdin);
+
+ $fd_stdin = fileno(STDIN);
+ $term = POSIX::Termios->new();
+ $term->getattr($fd_stdin);
+ $oterm = $term->getlflag();
+
+ $echo = ECHO | ECHOK | ICANON;
+ $noecho = $oterm & ~$echo;
+
+ sub cbreak {
+ $term->setlflag($noecho); # ok, so i don't want echo either
+ $term->setcc(VTIME, 1);
+ $term->setattr($fd_stdin, TCSANOW);
+ }
+
+ sub cooked {
+ $term->setlflag($oterm);
+ $term->setcc(VTIME, 0);
+ $term->setattr($fd_stdin, TCSANOW);
+ }
+
+ sub readkey {
+ my $key = '';
+ cbreak();
+ sysread(STDIN, $key, 1);
+ cooked();
+ return $key;
+ }
+
+ END { cooked() }
+
+ 1;
+
+=head2 How do I check whether input is ready on the keyboard?
+
+The easiest way to do this is to read a key in nonblocking mode with the
+Term::ReadKey module from CPAN, passing it an argument of -1 to indicate
+not to block:
+
+ use Term::ReadKey;
+
+ ReadMode('cbreak');
+
+ if (defined ($char = ReadKey(-1)) ) {
+ # input was waiting and it was $char
+ } else {
+ # no input was waiting
+ }
+
+ ReadMode('normal'); # restore normal tty settings
+
+=head2 How do I clear the screen?
+
+If you only have to so infrequently, use C<system>:
+
+ system("clear");
+
+If you have to do this a lot, save the clear string
+so you can print it 100 times without calling a program
+100 times:
+
+ $clear_string = `clear`;
+ print $clear_string;
+
+If you're planning on doing other screen manipulations, like cursor
+positions, etc, you might wish to use Term::Cap module:
+
+ use Term::Cap;
+ $terminal = Term::Cap->Tgetent( {OSPEED => 9600} );
+ $clear_string = $terminal->Tputs('cl');
+
+=head2 How do I get the screen size?
+
+If you have Term::ReadKey module installed from CPAN,
+you can use it to fetch the width and height in characters
+and in pixels:
+
+ use Term::ReadKey;
+ ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
+
+This is more portable than the raw C<ioctl>, but not as
+illustrative:
+
+ require 'sys/ioctl.ph';
+ die "no TIOCGWINSZ " unless defined &TIOCGWINSZ;
+ open(TTY, "+</dev/tty") or die "No tty: $!";
+ unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) {
+ die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ;
+ }
+ ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize);
+ print "(row,col) = ($row,$col)";
+ print " (xpixel,ypixel) = ($xpixel,$ypixel)" if $xpixel || $ypixel;
+ print "\n";
+
+=head2 How do I ask the user for a password?
+
+(This question has nothing to do with the web. See a different
+FAQ for that.)
+
+There's an example of this in L<perlfunc/crypt>). First, you put
+the terminal into "no echo" mode, then just read the password
+normally. You may do this with an old-style ioctl() function, POSIX
+terminal control (see L<POSIX>, and Chapter 7 of the Camel), or a call
+to the B<stty> program, with varying degrees of portability.
+
+You can also do this for most systems using the Term::ReadKey module
+from CPAN, which is easier to use and in theory more portable.
+
+ use Term::ReadKey;
+
+ ReadMode('noecho');
+ $password = ReadLine(0);
+
+=head2 How do I read and write the serial port?
+
+This depends on which operating system your program is running on. In
+the case of Unix, the serial ports will be accessible through files in
+/dev; on other systems, the devices names will doubtless differ.
+Several problem areas common to all device interaction are the
+following
+
+=over 4
+
+=item lockfiles
+
+Your system may use lockfiles to control multiple access. Make sure
+you follow the correct protocol. Unpredictable behaviour can result
+from multiple processes reading from one device.
+
+=item open mode
+
+If you expect to use both read and write operations on the device,
+you'll have to open it for update (see L<perlfunc/"open"> for
+details). You may wish to open it without running the risk of
+blocking by using sysopen() and C<O_RDWR|O_NDELAY|O_NOCTTY> from the
+Fcntl module (part of the standard perl distribution). See
+L<perlfunc/"sysopen"> for more on this approach.
+
+=item end of line
+
+Some devices will be expecting a "\r" at the end of each line rather
+than a "\n". In some ports of perl, "\r" and "\n" are different from
+their usual (Unix) ASCII values of "\012" and "\015". You may have to
+give the numeric values you want directly, using octal ("\015"), hex
+("0x0D"), or as a control-character specification ("\cM").
+
+ print DEV "atv1\012"; # wrong, for some devices
+ print DEV "atv1\015"; # right, for some devices
+
+Even though with normal text files, a "\n" will do the trick, there is
+still no unified scheme for terminating a line that is portable
+between Unix, DOS/Win, and Macintosh, except to terminate I<ALL> line
+ends with "\015\012", and strip what you don't need from the output.
+This applies especially to socket I/O and autoflushing, discussed
+next.
+
+=item flushing output
+
+If you expect characters to get to your device when you print() them,
+you'll want to autoflush that filehandle. You can use select()
+and the C<$|> variable to control autoflushing (see L<perlvar/$|>
+and L<perlfunc/select>):
+
+ $oldh = select(DEV);
+ $| = 1;
+ select($oldh);
+
+You'll also see code that does this without a temporary variable, as in
+
+ select((select(DEV), $| = 1)[0]);
+
+Or if you don't mind pulling in a few thousand lines
+of code just because you're afraid of a little $| variable:
+
+ use IO::Handle;
+ DEV->autoflush(1);
+
+As mentioned in the previous item, this still doesn't work when using
+socket I/O between Unix and Macintosh. You'll need to hardcode your
+line terminators, in that case.
+
+=item non-blocking input
+
+If you are doing a blocking read() or sysread(), you'll have to
+arrange for an alarm handler to provide a timeout (see
+L<perlfunc/alarm>). If you have a non-blocking open, you'll likely
+have a non-blocking read, which means you may have to use a 4-arg
+select() to determine whether I/O is ready on that device (see
+L<perlfunc/"select">.
+
+=back
+
+While trying to read from his caller-id box, the notorious Jamie Zawinski
+<jwz@netscape.com>, after much gnashing of teeth and fighting with sysread,
+sysopen, POSIX's tcgetattr business, and various other functions that
+go bump in the night, finally came up with this:
+
+ sub open_modem {
+ use IPC::Open2;
+ my $stty = `/bin/stty -g`;
+ open2( \*MODEM_IN, \*MODEM_OUT, "cu -l$modem_device -s2400 2>&1");
+ # starting cu hoses /dev/tty's stty settings, even when it has
+ # been opened on a pipe...
+ system("/bin/stty $stty");
+ $_ = <MODEM_IN>;
+ chop;
+ if ( !m/^Connected/ ) {
+ print STDERR "$0: cu printed `$_' instead of `Connected'\n";
+ }
+ }
+
+
+=head2 How do I decode encrypted password files?
+
+You spend lots and lots of money on dedicated hardware, but this is
+bound to get you talked about.
+
+Seriously, you can't if they are Unix password files - the Unix
+password system employs one-way encryption. It's more like hashing than
+encryption. The best you can check is whether something else hashes to
+the same string. You can't turn a hash back into the original string.
+Programs like Crack
+can forcibly (and intelligently) try to guess passwords, but don't
+(can't) guarantee quick success.
+
+If you're worried about users selecting bad passwords, you should
+proactively check when they try to change their password (by modifying
+passwd(1), for example).
+
+=head2 How do I start a process in the background?
+
+You could use
+
+ system("cmd &")
+
+or you could use fork as documented in L<perlfunc/"fork">, with
+further examples in L<perlipc>. Some things to be aware of, if you're
+on a Unix-like system:
+
+=over 4
+
+=item STDIN, STDOUT, and STDERR are shared
+
+Both the main process and the backgrounded one (the "child" process)
+share the same STDIN, STDOUT and STDERR filehandles. If both try to
+access them at once, strange things can happen. You may want to close
+or reopen these for the child. You can get around this with
+C<open>ing a pipe (see L<perlfunc/"open">) but on some systems this
+means that the child process cannot outlive the parent.
+
+=item Signals
+
+You'll have to catch the SIGCHLD signal, and possibly SIGPIPE too.
+SIGCHLD is sent when the backgrounded process finishes. SIGPIPE is
+sent when you write to a filehandle whose child process has closed (an
+untrapped SIGPIPE can cause your program to silently die). This is
+not an issue with C<system("cmd&")>.
+
+=item Zombies
+
+You have to be prepared to "reap" the child process when it finishes
+
+ $SIG{CHLD} = sub { wait };
+
+See L<perlipc/"Signals"> for other examples of code to do this.
+Zombies are not an issue with C<system("prog &")>.
+
+=back
+
+=head2 How do I trap control characters/signals?
+
+You don't actually "trap" a control character. Instead, that character
+generates a signal which is sent to your terminal's currently
+foregrounded process group, which you then trap in your process.
+Signals are documented in L<perlipc/"Signals"> and chapter 6 of the Camel.
+
+Be warned that very few C libraries are re-entrant. Therefore, if you
+attempt to print() in a handler that got invoked during another stdio
+operation your internal structures will likely be in an
+inconsistent state, and your program will dump core. You can
+sometimes avoid this by using syswrite() instead of print().
+
+Unless you're exceedingly careful, the only safe things to do inside a
+signal handler are: set a variable and exit. And in the first case,
+you should only set a variable in such a way that malloc() is not
+called (eg, by setting a variable that already has a value).
+
+For example:
+
+ $Interrupted = 0; # to ensure it has a value
+ $SIG{INT} = sub {
+ $Interrupted++;
+ syswrite(STDERR, "ouch\n", 5);
+ }
+
+However, because syscalls restart by default, you'll find that if
+you're in a "slow" call, such as E<lt>FHE<gt>, read(), connect(), or
+wait(), that the only way to terminate them is by "longjumping" out;
+that is, by raising an exception. See the time-out handler for a
+blocking flock() in L<perlipc/"Signals"> or chapter 6 of the Camel.
+
+=head2 How do I modify the shadow password file on a Unix system?
+
+If perl was installed correctly, and your shadow library was written
+properly, the getpw*() functions described in L<perlfunc> should in
+theory provide (read-only) access to entries in the shadow password
+file. To change the file, make a new shadow password file (the format
+varies from system to system - see L<passwd(5)> for specifics) and use
+pwd_mkdb(8) to install it (see L<pwd_mkdb(5)> for more details).
+
+=head2 How do I set the time and date?
+
+Assuming you're running under sufficient permissions, you should be
+able to set the system-wide date and time by running the date(1)
+program. (There is no way to set the time and date on a per-process
+basis.) This mechanism will work for Unix, MS-DOS, Windows, and NT;
+the VMS equivalent is C<set time>.
+
+However, if all you want to do is change your timezone, you can
+probably get away with setting an environment variable:
+
+ $ENV{TZ} = "MST7MDT"; # unixish
+ $ENV{'SYS$TIMEZONE_DIFFERENTIAL'}="-5" # vms
+ system "trn comp.lang.perl.misc";
+
+=head2 How can I sleep() or alarm() for under a second?
+
+If you want finer granularity than the 1 second that the sleep()
+function provides, the easiest way is to use the select() function as
+documented in L<perlfunc/"select">. If your system has itimers and
+syscall() support, you can check out the old example in
+http://www.perl.com/CPAN/doc/misc/ancient/tutorial/eg/itimers.pl .
+
+=head2 How can I measure time under a second?
+
+In general, you may not be able to. The Time::HiRes module (available
+from CPAN) provides this functionality for some systems.
+
+In general, you may not be able to. But if your system supports both the
+syscall() function in Perl as well as a system call like gettimeofday(2),
+then you may be able to do something like this:
+
+ require 'sys/syscall.ph';
+
+ $TIMEVAL_T = "LL";
+
+ $done = $start = pack($TIMEVAL_T, ());
+
+ syscall( &SYS_gettimeofday, $start, 0)) != -1
+ or die "gettimeofday: $!";
+
+ ##########################
+ # DO YOUR OPERATION HERE #
+ ##########################
+
+ syscall( &SYS_gettimeofday, $done, 0) != -1
+ or die "gettimeofday: $!";
+
+ @start = unpack($TIMEVAL_T, $start);
+ @done = unpack($TIMEVAL_T, $done);
+
+ # fix microseconds
+ for ($done[1], $start[1]) { $_ /= 1_000_000 }
+
+ $delta_time = sprintf "%.4f", ($done[0] + $done[1] )
+ -
+ ($start[0] + $start[1] );
+
+=head2 How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
+
+Release 5 of Perl added the END block, which can be used to simulate
+atexit(). Each package's END block is called when the program or
+thread ends (see L<perlmod> manpage for more details).
+
+For example, you can use this to make sure your filter program
+managed to finish its output without filling up the disk:
+
+ END {
+ close(STDOUT) || die "stdout close failed: $!";
+ }
+
+The END block isn't called when untrapped signals kill the program, though, so if
+you use END blocks you should also use
+
+ use sigtrap qw(die normal-signals);
+
+Perl's exception-handling mechanism is its eval() operator. You can
+use eval() as setjmp and die() as longjmp. For details of this, see
+the section on signals, especially the time-out handler for a blocking
+flock() in L<perlipc/"Signals"> and chapter 6 of the Camel.
+
+If exception handling is all you're interested in, try the
+exceptions.pl library (part of the standard perl distribution).
+
+If you want the atexit() syntax (and an rmexit() as well), try the
+AtExit module available from CPAN.
+
+=head2 Why doesn't my sockets program work under System V (Solaris)? What does the error message "Protocol not supported" mean?
+
+Some Sys-V based systems, notably Solaris 2.X, redefined some of the
+standard socket constants. Since these were constant across all
+architectures, they were often hardwired into perl code. The proper
+way to deal with this is to "use Socket" to get the correct values.
+
+Note that even though SunOS and Solaris are binary compatible, these
+values are different. Go figure.
+
+=head2 How can I call my system's unique C functions from Perl?
+
+In most cases, you write an external module to do it - see the answer
+to "Where can I learn about linking C with Perl? [h2xs, xsubpp]".
+However, if the function is a system call, and your system supports
+syscall(), you can use the syscall function (documented in
+L<perlfunc>).
+
+Remember to check the modules that came with your distribution, and
+CPAN as well - someone may already have written a module to do it.
+
+=head2 Where do I get the include files to do ioctl() or syscall()?
+
+Historically, these would be generated by the h2ph tool, part of the
+standard perl distribution. This program converts cpp(1) directives
+in C header files to files containing subroutine definitions, like
+&SYS_getitimer, which you can use as arguments to your functions.
+It doesn't work perfectly, but it usually gets most of the job done.
+Simple files like F<errno.h>, F<syscall.h>, and F<socket.h> were fine,
+but the hard ones like F<ioctl.h> nearly always need to hand-edited.
+Here's how to install the *.ph files:
+
+ 1. become super-user
+ 2. cd /usr/include
+ 3. h2ph *.h */*.h
+
+If your system supports dynamic loading, for reasons of portability and
+sanity you probably ought to use h2xs (also part of the standard perl
+distribution). This tool converts C header files to Perl extensions.
+See L<perlxstut> for how to get started with h2xs.
+
+If your system doesn't support dynamic loading, you still probably
+ought to use h2xs. See L<perlxstut> and L<ExtUtils::MakeMaker> for
+more information (in brief, just use B<make perl> instead of a plain
+B<make> to rebuild perl with a new static extension).
+
+=head2 Why do setuid perl scripts complain about kernel problems?
+
+Some operating systems have bugs in the kernel that make setuid
+scripts inherently insecure. Perl gives you a number of options
+(described in L<perlsec>) to work around such systems.
+
+=head2 How can I open a pipe both to and from a command?
+
+The IPC::Open2 module (part of the standard perl distribution) is an
+easy-to-use approach that internally uses pipe(), fork(), and exec() to do
+the job. Make sure you read the deadlock warnings in its documentation,
+though (see L<IPC::Open2>). See L<perlipc/"Bidirectional Communication
+with Another Process"> and L<perlipc/"Bidirectional Communication with
+Yourself">
+
+You may also use the IPC::Open3 module (part of the standard perl
+distribution), but be warned that it has a different order of
+arguments from IPC::Open2 (see L<IPC::Open3>).
+
+=head2 Why can't I get the output of a command with system()?
+
+You're confusing the purpose of system() and backticks (``). system()
+runs a command and returns exit status information (as a 16 bit value:
+the low 7 bits are the signal the process died from, if any, and
+the high 8 bits are the actual exit value). Backticks (``) run a
+command and return what it sent to STDOUT.
+
+ $exit_status = system("mail-users");
+ $output_string = `ls`;
+
+=head2 How can I capture STDERR from an external command?
+
+There are three basic ways of running external commands:
+
+ system $cmd; # using system()
+ $output = `$cmd`; # using backticks (``)
+ open (PIPE, "cmd |"); # using open()
+
+With system(), both STDOUT and STDERR will go the same place as the
+script's versions of these, unless the command redirects them.
+Backticks and open() read B<only> the STDOUT of your command.
+
+With any of these, you can change file descriptors before the call:
+
+ open(STDOUT, ">logfile");
+ system("ls");
+
+or you can use Bourne shell file-descriptor redirection:
+
+ $output = `$cmd 2>some_file`;
+ open (PIPE, "cmd 2>some_file |");
+
+You can also use file-descriptor redirection to make STDERR a
+duplicate of STDOUT:
+
+ $output = `$cmd 2>&1`;
+ open (PIPE, "cmd 2>&1 |");
+
+Note that you I<cannot> simply open STDERR to be a dup of STDOUT
+in your Perl program and avoid calling the shell to do the redirection.
+This doesn't work:
+
+ open(STDERR, ">&STDOUT");
+ $alloutput = `cmd args`; # stderr still escapes
+
+This fails because the open() makes STDERR go to where STDOUT was
+going at the time of the open(). The backticks then make STDOUT go to
+a string, but don't change STDERR (which still goes to the old
+STDOUT).
+
+Note that you I<must> use Bourne shell (sh(1)) redirection syntax in
+backticks, not csh(1)! Details on why Perl's system() and backtick
+and pipe opens all use the Bourne shell are in
+http://www.perl.com/CPAN/doc/FMTEYEWTK/versus/csh.whynot .
+To capture a command's STDERR and STDOUT together:
+
+ $output = `cmd 2>&1`; # either with backticks
+ $pid = open(PH, "cmd 2>&1 |"); # or with an open pipe
+ while (<PH>) { } # plus a read
+
+To capture a command's STDOUT but discard its STDERR:
+
+ $output = `cmd 2>/dev/null`; # either with backticks
+ $pid = open(PH, "cmd 2>/dev/null |"); # or with an open pipe
+ while (<PH>) { } # plus a read
+
+To capture a command's STDERR but discard its STDOUT:
+
+ $output = `cmd 2>&1 1>/dev/null`; # either with backticks
+ $pid = open(PH, "cmd 2>&1 1>/dev/null |"); # or with an open pipe
+ while (<PH>) { } # plus a read
+
+To exchange a command's STDOUT and STDERR in order to capture the STDERR
+but leave its STDOUT to come out our old STDERR:
+
+ $output = `cmd 3>&1 1>&2 2>&3 3>&-`; # either with backticks
+ $pid = open(PH, "cmd 3>&1 1>&2 2>&3 3>&-|");# or with an open pipe
+ while (<PH>) { } # plus a read
+
+To read both a command's STDOUT and its STDERR separately, it's easiest
+and safest to redirect them separately to files, and then read from those
+files when the program is done:
+
+ system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
+
+Ordering is important in all these examples. That's because the shell
+processes file descriptor redirections in strictly left to right order.
+
+ system("prog args 1>tmpfile 2>&1");
+ system("prog args 2>&1 1>tmpfile");
+
+The first command sends both standard out and standard error to the
+temporary file. The second command sends only the old standard output
+there, and the old standard error shows up on the old standard out.
+
+=head2 Why doesn't open() return an error when a pipe open fails?
+
+It does, but probably not how you expect it to. On systems that
+follow the standard fork()/exec() paradigm (such as Unix), it works like
+this: open() causes a fork(). In the parent, open() returns with the
+process ID of the child. The child exec()s the command to be piped
+to/from. The parent can't know whether the exec() was successful or
+not - all it can return is whether the fork() succeeded or not. To
+find out if the command succeeded, you have to catch SIGCHLD and
+wait() to get the exit status. You should also catch SIGPIPE if
+you're writing to the child -- you may not have found out the exec()
+failed by the time you write. This is documented in L<perlipc>.
+
+On systems that follow the spawn() paradigm, open() I<might> do what
+you expect - unless perl uses a shell to start your command. In this
+case the fork()/exec() description still applies.
+
+=head2 What's wrong with using backticks in a void context?
+
+Strictly speaking, nothing. Stylistically speaking, it's not a good
+way to write maintainable code because backticks have a (potentially
+humungous) return value, and you're ignoring it. It's may also not be very
+efficient, because you have to read in all the lines of output, allocate
+memory for them, and then throw it away. Too often people are lulled
+to writing:
+
+ `cp file file.bak`;
+
+And now they think "Hey, I'll just always use backticks to run programs."
+Bad idea: backticks are for capturing a program's output; the system()
+function is for running programs.
+
+Consider this line:
+
+ `cat /etc/termcap`;
+
+You haven't assigned the output anywhere, so it just wastes memory
+(for a little while). Plus you forgot to check C<$?> to see whether
+the program even ran correctly. Even if you wrote
+
+ print `cat /etc/termcap`;
+
+In most cases, this could and probably should be written as
+
+ system("cat /etc/termcap") == 0
+ or die "cat program failed!";
+
+Which will get the output quickly (as its generated, instead of only
+at the end) and also check the return value.
+
+system() also provides direct control over whether shell wildcard
+processing may take place, whereas backticks do not.
+
+=head2 How can I call backticks without shell processing?
+
+This is a bit tricky. Instead of writing
+
+ @ok = `grep @opts '$search_string' @filenames`;
+
+You have to do this:
+
+ my @ok = ();
+ if (open(GREP, "-|")) {
+ while (<GREP>) {
+ chomp;
+ push(@ok, $_);
+ }
+ close GREP;
+ } else {
+ exec 'grep', @opts, $search_string, @filenames;
+ }
+
+Just as with system(), no shell escapes happen when you exec() a list.
+
+There are more examples of this L<perlipc/"Safe Pipe Opens">.
+
+=head2 Why can't my script read from STDIN after I gave it EOF (^D on Unix, ^Z on MS-DOS)?
+
+Because some stdio's set error and eof flags that need clearing. The
+POSIX module defines clearerr() that you can use. That is the
+technically correct way to do it. Here are some less reliable
+workarounds:
+
+=over 4
+
+=item 1
+
+Try keeping around the seekpointer and go there, like this:
+
+ $where = tell(LOG);
+ seek(LOG, $where, 0);
+
+=item 2
+
+If that doesn't work, try seeking to a different part of the file and
+then back.
+
+=item 3
+
+If that doesn't work, try seeking to a different part of
+the file, reading something, and then seeking back.
+
+=item 4
+
+If that doesn't work, give up on your stdio package and use sysread.
+
+=back
+
+=head2 How can I convert my shell script to perl?
+
+Learn Perl and rewrite it. Seriously, there's no simple converter.
+Things that are awkward to do in the shell are easy to do in Perl, and
+this very awkwardness is what would make a shell->perl converter
+nigh-on impossible to write. By rewriting it, you'll think about what
+you're really trying to do, and hopefully will escape the shell's
+pipeline datastream paradigm, which while convenient for some matters,
+causes many inefficiencies.
+
+=head2 Can I use perl to run a telnet or ftp session?
+
+Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from
+CPAN). http://www.perl.com/CPAN/scripts/netstuff/telnet.emul.shar
+will also help for emulating the telnet protocol, but Net::Telnet is
+quite probably easier to use..
+
+If all you want to do is pretend to be telnet but don't need
+the initial telnet handshaking, then the standard dual-process
+approach will suffice:
+
+ use IO::Socket; # new in 5.004
+ $handle = IO::Socket::INET->new('www.perl.com:80')
+ || die "can't connect to port 80 on www.perl.com: $!";
+ $handle->autoflush(1);
+ if (fork()) { # XXX: undef means failure
+ select($handle);
+ print while <STDIN>; # everything from stdin to socket
+ } else {
+ print while <$handle>; # everything from socket to stdout
+ }
+ close $handle;
+ exit;
+
+=head2 How can I write expect in Perl?
+
+Once upon a time, there was a library called chat2.pl (part of the
+standard perl distribution), which never really got finished. If you
+find it somewhere, I<don't use it>. These days, your best bet is to
+look at the Expect module available from CPAN, which also requires two
+other modules from CPAN, IO::Pty and IO::Stty.
+
+=head2 Is there a way to hide perl's command line from programs such as "ps"?
+
+First of all note that if you're doing this for security reasons (to
+avoid people seeing passwords, for example) then you should rewrite
+your program so that critical information is never given as an
+argument. Hiding the arguments won't make your program completely
+secure.
+
+To actually alter the visible command line, you can assign to the
+variable $0 as documented in L<perlvar>. This won't work on all
+operating systems, though. Daemon programs like sendmail place their
+state there, as in:
+
+ $0 = "orcus [accepting connections]";
+
+=head2 I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible?
+
+=over 4
+
+=item Unix
+
+In the strictest sense, it can't be done -- the script executes as a
+different process from the shell it was started from. Changes to a
+process are not reflected in its parent, only in its own children
+created after the change. There is shell magic that may allow you to
+fake it by eval()ing the script's output in your shell; check out the
+comp.unix.questions FAQ for details.
+
+=back
+
+=head2 How do I close a process's filehandle without waiting for it to complete?
+
+Assuming your system supports such things, just send an appropriate signal
+to the process (see L<perlfunc/"kill">. It's common to first send a TERM
+signal, wait a little bit, and then send a KILL signal to finish it off.
+
+=head2 How do I fork a daemon process?
+
+If by daemon process you mean one that's detached (disassociated from
+its tty), then the following process is reported to work on most
+Unixish systems. Non-Unix users should check their Your_OS::Process
+module for other solutions.
+
+=over 4
+
+=item *
+
+Open /dev/tty and use the the TIOCNOTTY ioctl on it. See L<tty(4)>
+for details. Or better yet, you can just use the POSIX::setsid()
+function, so you don't have to worry about process groups.
+
+=item *
+
+Change directory to /
+
+=item *
+
+Reopen STDIN, STDOUT, and STDERR so they're not connected to the old
+tty.
+
+=item *
+
+Background yourself like this:
+
+ fork && exit;
+
+=back
+
+=head2 How do I make my program run with sh and csh?
+
+See the F<eg/nih> script (part of the perl source distribution).
+
+=head2 How do I find out if I'm running interactively or not?
+
+Good question. Sometimes C<-t STDIN> and C<-t STDOUT> can give clues,
+sometimes not.
+
+ if (-t STDIN && -t STDOUT) {
+ print "Now what? ";
+ }
+
+On POSIX systems, you can test whether your own process group matches
+the current process group of your controlling terminal as follows:
+
+ use POSIX qw/getpgrp tcgetpgrp/;
+ open(TTY, "/dev/tty") or die $!;
+ $tpgrp = tcgetpgrp(TTY);
+ $pgrp = getpgrp();
+ if ($tpgrp == $pgrp) {
+ print "foreground\n";
+ } else {
+ print "background\n";
+ }
+
+=head2 How do I timeout a slow event?
+
+Use the alarm() function, probably in conjunction with a signal
+handler, as documented L<perlipc/"Signals"> and chapter 6 of the
+Camel. You may instead use the more flexible Sys::AlarmCall module
+available from CPAN.
+
+=head2 How do I set CPU limits?
+
+Use the BSD::Resource module from CPAN.
+
+=head2 How do I avoid zombies on a Unix system?
+
+Use the reaper code from L<perlipc/"Signals"> to call wait() when a
+SIGCHLD is received, or else use the double-fork technique described
+in L<perlfunc/fork>.
+
+=head2 How do I use an SQL database?
+
+There are a number of excellent interfaces to SQL databases. See the
+DBD::* modules available from
+http://www.perl.com/CPAN/modules/dbperl/DBD .
+A lot of information on this can be found at
+http://www.hermetica.com/technologia/perl/DBI/index.html .
+
+=head2 How do I make a system() exit on control-C?
+
+You can't. You need to imitate the system() call (see L<perlipc> for
+sample code) and then have a signal handler for the INT signal that
+passes the signal on to the subprocess. Or you can check for it:
+
+ $rc = system($cmd);
+ if ($rc & 127) { die "signal death" }
+
+=head2 How do I open a file without blocking?
+
+If you're lucky enough to be using a system that supports
+non-blocking reads (most Unixish systems do), you need only to use the
+O_NDELAY or O_NONBLOCK flag from the Fcntl module in conjunction with
+sysopen():
+
+ use Fcntl;
+ sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT, 0644)
+ or die "can't open /tmp/somefile: $!":
+
+=head2 How do I install a CPAN module?
+
+The easiest way is to have the CPAN module do it for you. This module
+comes with perl version 5.004 and later. To manually install the CPAN
+module, or any well-behaved CPAN module for that matter, follow these
+steps:
+
+=over 4
+
+=item 1
+
+Unpack the source into a temporary area.
+
+=item 2
+
+ perl Makefile.PL
+
+=item 3
+
+ make
+
+=item 4
+
+ make test
+
+=item 5
+
+ make install
+
+=back
+
+If your version of perl is compiled without dynamic loading, then you
+just need to replace step 3 (B<make>) with B<make perl> and you will
+get a new F<perl> binary with your extension linked in.
+
+See L<ExtUtils::MakeMaker> for more details on building extensions.
+See also the next question.
+
+=head2 What's the difference between require and use?
+
+Perl offers several different ways to include code from one file into
+another. Here are the deltas between the various inclusion constructs:
+
+ 1) do $file is like eval `cat $file`, except the former:
+ 1.1: searches @INC and updates %INC.
+ 1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
+
+ 2) require $file is like do $file, except the former:
+ 2.1: checks for redundant loading, skipping already loaded files.
+ 2.2: raises an exception on failure to find, compile, or execute $file.
+
+ 3) require Module is like require "Module.pm", except the former:
+ 3.1: translates each "::" into your system's directory separator.
+ 3.2: primes the parser to disambiguate class Module as an indirect object.
+
+ 4) use Module is like require Module, except the former:
+ 4.1: loads the module at compile time, not run-time.
+ 4.2: imports symbols and semantics from that package to the current one.
+
+In general, you usually want C<use> and a proper Perl module.
+
+=head2 How do I keep my own module/library directory?
+
+When you build modules, use the PREFIX option when generating
+Makefiles:
+
+ perl Makefile.PL PREFIX=/u/mydir/perl
+
+then either set the PERL5LIB environment variable before you run
+scripts that use the modules/libraries (see L<perlrun>) or say
+
+ use lib '/u/mydir/perl';
+
+See Perl's L<lib> for more information.
+
+=head2 How do I add the directory my program lives in to the module/library search path?
+
+ use FindBin;
+ use lib "$FindBin::Bin";
+ use your_own_modules;
+
+=head2 How do I add a directory to my include path at runtime?
+
+Here are the suggested ways of modifying your include path:
+
+ the PERLLIB environment variable
+ the PERL5LIB environment variable
+ the perl -Idir commpand line flag
+ the use lib pragma, as in
+ use lib "$ENV{HOME}/myown_perllib";
+
+The latter is particularly useful because it knows about machine
+dependent architectures. The lib.pm pragmatic module was first
+included with the 5.002 release of Perl.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
diff --git a/contrib/perl5/pod/perlfaq9.pod b/contrib/perl5/pod/perlfaq9.pod
new file mode 100644
index 0000000..330158b
--- /dev/null
+++ b/contrib/perl5/pod/perlfaq9.pod
@@ -0,0 +1,552 @@
+=head1 NAME
+
+perlfaq9 - Networking ($Revision: 1.20 $, $Date: 1998/06/22 18:31:09 $)
+
+=head1 DESCRIPTION
+
+This section deals with questions related to networking, the internet,
+and a few on the web.
+
+=head2 My CGI script runs from the command line but not the browser. (500 Server Error)
+
+If you can demonstrate that you've read the following FAQs and that
+your problem isn't something simple that can be easily answered, you'll
+probably receive a courteous and useful reply to your question if you
+post it on comp.infosystems.www.authoring.cgi (if it's something to do
+with HTTP, HTML, or the CGI protocols). Questions that appear to be Perl
+questions but are really CGI ones that are posted to comp.lang.perl.misc
+may not be so well received.
+
+The useful FAQs and related documents are:
+
+ CGI FAQ
+ http://www.webthing.com/page.cgi/cgifaq
+
+ Web FAQ
+ http://www.boutell.com/faq/
+
+ WWW Security FAQ
+ http://www.w3.org/Security/Faq/
+
+ HTTP Spec
+ http://www.w3.org/pub/WWW/Protocols/HTTP/
+
+ HTML Spec
+ http://www.w3.org/TR/REC-html40/
+ http://www.w3.org/pub/WWW/MarkUp/
+
+ CGI Spec
+ http://www.w3.org/CGI/
+
+ CGI Security FAQ
+ http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
+
+=head2 How can I get better error messages from a CGI program?
+
+Use the CGI::Carp module. It replaces C<warn> and C<die>, plus the
+normal Carp modules C<carp>, C<croak>, and C<confess> functions with
+more verbose and safer versions. It still sends them to the normal
+server error log.
+
+ use CGI::Carp;
+ warn "This is a complaint";
+ die "But this one is serious";
+
+The following use of CGI::Carp also redirects errors to a file of your choice,
+placed in a BEGIN block to catch compile-time warnings as well:
+
+ BEGIN {
+ use CGI::Carp qw(carpout);
+ open(LOG, ">>/var/local/cgi-logs/mycgi-log")
+ or die "Unable to append to mycgi-log: $!\n";
+ carpout(*LOG);
+ }
+
+You can even arrange for fatal errors to go back to the client browser,
+which is nice for your own debugging, but might confuse the end user.
+
+ use CGI::Carp qw(fatalsToBrowser);
+ die "Bad error here";
+
+Even if the error happens before you get the HTTP header out, the module
+will try to take care of this to avoid the dreaded server 500 errors.
+Normal warnings still go out to the server error log (or wherever
+you've sent them with C<carpout>) with the application name and date
+stamp prepended.
+
+=head2 How do I remove HTML from a string?
+
+The most correct way (albeit not the fastest) is to use HTML::Parse
+from CPAN (part of the libwww-perl distribution, which is a must-have
+module for all web hackers).
+
+Many folks attempt a simple-minded regular expression approach, like
+C<s/E<lt>.*?E<gt>//g>, but that fails in many cases because the tags
+may continue over line breaks, they may contain quoted angle-brackets,
+or HTML comment may be present. Plus folks forget to convert
+entities, like C<&lt;> for example.
+
+Here's one "simple-minded" approach, that works for most files:
+
+ #!/usr/bin/perl -p0777
+ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
+
+If you want a more complete solution, see the 3-stage striphtml
+program in
+http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz
+.
+
+Here are some tricky cases that you should think about when picking
+a solution:
+
+ <IMG SRC = "foo.gif" ALT = "A > B">
+
+ <IMG SRC = "foo.gif"
+ ALT = "A > B">
+
+ <!-- <A comment> -->
+
+ <script>if (a<b && a>c)</script>
+
+ <# Just data #>
+
+ <![INCLUDE CDATA [ >>>>>>>>>>>> ]]>
+
+If HTML comments include other tags, those solutions would also break
+on text like this:
+
+ <!-- This section commented out.
+ <B>You can't see me!</B>
+ -->
+
+=head2 How do I extract URLs?
+
+A quick but imperfect approach is
+
+ #!/usr/bin/perl -n00
+ # qxurl - tchrist@perl.com
+ print "$2\n" while m{
+ < \s*
+ A \s+ HREF \s* = \s* (["']) (.*?) \1
+ \s* >
+ }gsix;
+
+This version does not adjust relative URLs, understand alternate
+bases, deal with HTML comments, deal with HREF and NAME attributes in
+the same tag, or accept URLs themselves as arguments. It also runs
+about 100x faster than a more "complete" solution using the LWP suite
+of modules, such as the
+http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/xurl.gz
+program.
+
+=head2 How do I download a file from the user's machine? How do I open a file on another machine?
+
+In the context of an HTML form, you can use what's known as
+B<multipart/form-data> encoding. The CGI.pm module (available from
+CPAN) supports this in the start_multipart_form() method, which isn't
+the same as the startform() method.
+
+=head2 How do I make a pop-up menu in HTML?
+
+Use the B<E<lt>SELECTE<gt>> and B<E<lt>OPTIONE<gt>> tags. The CGI.pm
+module (available from CPAN) supports this widget, as well as many
+others, including some that it cleverly synthesizes on its own.
+
+=head2 How do I fetch an HTML file?
+
+One approach, if you have the lynx text-based HTML browser installed
+on your system, is this:
+
+ $html_code = `lynx -source $url`;
+ $text_data = `lynx -dump $url`;
+
+The libwww-perl (LWP) modules from CPAN provide a more powerful way to
+do this. They work through proxies, and don't require lynx:
+
+ # simplest version
+ use LWP::Simple;
+ $content = get($URL);
+
+ # or print HTML from a URL
+ use LWP::Simple;
+ getprint "http://www.sn.no/libwww-perl/";
+
+ # or print ASCII from HTML from a URL
+ use LWP::Simple;
+ use HTML::Parse;
+ use HTML::FormatText;
+ my ($html, $ascii);
+ $html = get("http://www.perl.com/");
+ defined $html
+ or die "Can't fetch HTML from http://www.perl.com/";
+ $ascii = HTML::FormatText->new->format(parse_html($html));
+ print $ascii;
+
+=head2 How do I automate an HTML form submission?
+
+If you're submitting values using the GET method, create a URL and encode
+the form using the C<query_form> method:
+
+ use LWP::Simple;
+ use URI::URL;
+
+ my $url = url('http://www.perl.com/cgi-bin/cpan_mod');
+ $url->query_form(module => 'DB_File', readme => 1);
+ $content = get($url);
+
+If you're using the POST method, create your own user agent and encode
+the content appropriately.
+
+ use HTTP::Request::Common qw(POST);
+ use LWP::UserAgent;
+
+ $ua = LWP::UserAgent->new();
+ my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod',
+ [ module => 'DB_File', readme => 1 ];
+ $content = $ua->request($req)->as_string;
+
+=head2 How do I decode or create those %-encodings on the web?
+
+Here's an example of decoding:
+
+ $string = "http://altavista.digital.com/cgi-bin/query?pg=q&what=news&fmt=.&q=%2Bcgi-bin+%2Bperl.exe";
+ $string =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;
+
+Encoding is a bit harder, because you can't just blindly change
+all the non-alphanumunder character (C<\W>) into their hex escapes.
+It's important that characters with special meaning like C</> and C<?>
+I<not> be translated. Probably the easiest way to get this right is
+to avoid reinventing the wheel and just use the URI::Escape module,
+which is part of the libwww-perl package (LWP) available from CPAN.
+
+=head2 How do I redirect to another page?
+
+Instead of sending back a C<Content-Type> as the headers of your
+reply, send back a C<Location:> header. Officially this should be a
+C<URI:> header, so the CGI.pm module (available from CPAN) sends back
+both:
+
+ Location: http://www.domain.com/newpage
+ URI: http://www.domain.com/newpage
+
+Note that relative URLs in these headers can cause strange effects
+because of "optimizations" that servers do.
+
+ $url = "http://www.perl.com/CPAN/";
+ print "Location: $url\n\n";
+ exit;
+
+To be correct to the spec, each of those C<"\n">
+should really each be C<"\015\012">, but unless you're
+stuck on MacOS, you probably won't notice.
+
+=head2 How do I put a password on my web pages?
+
+That depends. You'll need to read the documentation for your web
+server, or perhaps check some of the other FAQs referenced above.
+
+=head2 How do I edit my .htpasswd and .htgroup files with Perl?
+
+The HTTPD::UserAdmin and HTTPD::GroupAdmin modules provide a
+consistent OO interface to these files, regardless of how they're
+stored. Databases may be text, dbm, Berkley DB or any database with a
+DBI compatible driver. HTTPD::UserAdmin supports files used by the
+`Basic' and `Digest' authentication schemes. Here's an example:
+
+ use HTTPD::UserAdmin ();
+ HTTPD::UserAdmin
+ ->new(DB => "/foo/.htpasswd")
+ ->add($username => $password);
+
+=head2 How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
+
+Read the CGI security FAQ, at
+http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html, and the
+Perl/CGI FAQ at
+http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html.
+
+In brief: use tainting (see L<perlsec>), which makes sure that data
+from outside your script (eg, CGI parameters) are never used in
+C<eval> or C<system> calls. In addition to tainting, never use the
+single-argument form of system() or exec(). Instead, supply the
+command and arguments as a list, which prevents shell globbing.
+
+=head2 How do I parse a mail header?
+
+For a quick-and-dirty solution, try this solution derived
+from page 222 of the 2nd edition of "Programming Perl":
+
+ $/ = '';
+ $header = <MSG>;
+ $header =~ s/\n\s+/ /g; # merge continuation lines
+ %head = ( UNIX_FROM_LINE, split /^([-\w]+):\s*/m, $header );
+
+That solution doesn't do well if, for example, you're trying to
+maintain all the Received lines. A more complete approach is to use
+the Mail::Header module from CPAN (part of the MailTools package).
+
+=head2 How do I decode a CGI form?
+
+You use a standard module, probably CGI.pm. Under no circumstances
+should you attempt to do so by hand!
+
+You'll see a lot of CGI programs that blindly read from STDIN the number
+of bytes equal to CONTENT_LENGTH for POSTs, or grab QUERY_STRING for
+decoding GETs. These programs are very poorly written. They only work
+sometimes. They typically forget to check the return value of the read()
+system call, which is a cardinal sin. They don't handle HEAD requests.
+They don't handle multipart forms used for file uploads. They don't deal
+with GET/POST combinations where query fields are in more than one place.
+They don't deal with keywords in the query string.
+
+In short, they're bad hacks. Resist them at all costs. Please do not be
+tempted to reinvent the wheel. Instead, use the CGI.pm or CGI_Lite.pm
+(available from CPAN), or if you're trapped in the module-free land
+of perl1 .. perl4, you might look into cgi-lib.pl (available from
+http://www.bio.cam.ac.uk/web/form.html).
+
+Make sure you know whether to use a GET or a POST in your form.
+GETs should only be used for something that doesn't update the server.
+Otherwise you can get mangled databases and repeated feedback mail
+messages. The fancy word for this is ``idempotency''. This simply
+means that there should be no difference between making a GET request
+for a particular URL once or multiple times. This is because the
+HTTP protocol definition says that a GET request may be cached by the
+browser, or server, or an intervening proxy. POST requests cannot be
+cached, because each request is independent and matters. Typically,
+POST requests change or depend on state on the server (query or update
+a database, send mail, or purchase a computer).
+
+=head2 How do I check a valid mail address?
+
+You can't, at least, not in real time. Bummer, eh?
+
+Without sending mail to the address and seeing whether there's a human
+on the other hand to answer you, you cannot determine whether a mail
+address is valid. Even if you apply the mail header standard, you
+can have problems, because there are deliverable addresses that aren't
+RFC-822 (the mail header standard) compliant, and addresses that aren't
+deliverable which are compliant.
+
+Many are tempted to try to eliminate many frequently-invalid
+mail addresses with a simple regexp, such as
+C</^[\w.-]+\@([\w.-]\.)+\w+$/>. It's a very bad idea. However,
+this also throws out many valid ones, and says nothing about
+potential deliverability, so is not suggested. Instead, see
+http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz ,
+which actually checks against the full RFC spec (except for nested
+comments), looks for addresses you may not wish to accept mail to
+(say, Bill Clinton or your postmaster), and then makes sure that the
+hostname given can be looked up in the DNS MX records. It's not fast,
+but it works for what it tries to do.
+
+Our best advice for verifying a person's mail address is to have them
+enter their address twice, just as you normally do to change a password.
+This usually weeds out typos. If both versions match, send
+mail to that address with a personal message that looks somewhat like:
+
+ Dear someuser@host.com,
+
+ Please confirm the mail address you gave us Wed May 6 09:38:41
+ MDT 1998 by replying to this message. Include the string
+ "Rumpelstiltskin" in that reply, but spelled in reverse; that is,
+ start with "Nik...". Once this is done, your confirmed address will
+ be entered into our records.
+
+If you get the message back and they've followed your directions,
+you can be reasonably assured that it's real.
+
+A related strategy that's less open to forgery is to give them a PIN
+(personal ID number). Record the address and PIN (best that it be a
+random one) for later processing. In the mail you send, ask them to
+include the PIN in their reply. But if it bounces, or the message is
+included via a ``vacation'' script, it'll be there anyway. So it's
+best to ask them to mail back a slight alteration of the PIN, such as
+with the characters reversed, one added or subtracted to each digit, etc.
+
+=head2 How do I decode a MIME/BASE64 string?
+
+The MIME-tools package (available from CPAN) handles this and a lot
+more. Decoding BASE64 becomes as simple as:
+
+ use MIME::base64;
+ $decoded = decode_base64($encoded);
+
+A more direct approach is to use the unpack() function's "u"
+format after minor transliterations:
+
+ tr#A-Za-z0-9+/##cd; # remove non-base64 chars
+ tr#A-Za-z0-9+/# -_#; # convert to uuencoded format
+ $len = pack("c", 32 + 0.75*length); # compute length byte
+ print unpack("u", $len . $_); # uudecode and print
+
+=head2 How do I return the user's mail address?
+
+On systems that support getpwuid, the $E<lt> variable and the
+Sys::Hostname module (which is part of the standard perl distribution),
+you can probably try using something like this:
+
+ use Sys::Hostname;
+ $address = sprintf('%s@%s', getpwuid($<), hostname);
+
+Company policies on mail address can mean that this generates addresses
+that the company's mail system will not accept, so you should ask for
+users' mail addresses when this matters. Furthermore, not all systems
+on which Perl runs are so forthcoming with this information as is Unix.
+
+The Mail::Util module from CPAN (part of the MailTools package) provides a
+mailaddress() function that tries to guess the mail address of the user.
+It makes a more intelligent guess than the code above, using information
+given when the module was installed, but it could still be incorrect.
+Again, the best way is often just to ask the user.
+
+=head2 How do I send mail?
+
+Use the C<sendmail> program directly:
+
+ open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq")
+ or die "Can't fork for sendmail: $!\n";
+ print SENDMAIL <<"EOF";
+ From: User Originating Mail <me\@host>
+ To: Final Destination <you\@otherhost>
+ Subject: A relevant subject line
+
+ Body of the message goes here, in as many lines as you like.
+ EOF
+ close(SENDMAIL) or warn "sendmail didn't close nicely";
+
+The B<-oi> option prevents sendmail from interpreting a line consisting
+of a single dot as "end of message". The B<-t> option says to use the
+headers to decide who to send the message to, and B<-odq> says to put
+the message into the queue. This last option means your message won't
+be immediately delivered, so leave it out if you want immediate
+delivery.
+
+Or use the CPAN module Mail::Mailer:
+
+ use Mail::Mailer;
+
+ $mailer = Mail::Mailer->new();
+ $mailer->open({ From => $from_address,
+ To => $to_address,
+ Subject => $subject,
+ })
+ or die "Can't open: $!\n";
+ print $mailer $body;
+ $mailer->close();
+
+The Mail::Internet module uses Net::SMTP which is less Unix-centric than
+Mail::Mailer, but less reliable. Avoid raw SMTP commands. There
+are many reasons to use a mail transport agent like sendmail. These
+include queueing, MX records, and security.
+
+=head2 How do I read mail?
+
+Use the Mail::Folder module from CPAN
+(part of the MailFolder package) or the Mail::Internet module from
+CPAN (also part of the MailTools package).
+
+ # sending mail
+ use Mail::Internet;
+ use Mail::Header;
+ # say which mail host to use
+ $ENV{SMTPHOSTS} = 'mail.frii.com';
+ # create headers
+ $header = new Mail::Header;
+ $header->add('From', 'gnat@frii.com');
+ $header->add('Subject', 'Testing');
+ $header->add('To', 'gnat@frii.com');
+ # create body
+ $body = 'This is a test, ignore';
+ # create mail object
+ $mail = new Mail::Internet(undef, Header => $header, Body => \[$body]);
+ # send it
+ $mail->smtpsend or die;
+
+Often a module is overkill, though. Here's a mail sorter.
+
+ #!/usr/bin/perl
+ # bysub1 - simple sort by subject
+ my(@msgs, @sub);
+ my $msgno = -1;
+ $/ = ''; # paragraph reads
+ while (<>) {
+ if (/^From/m) {
+ /^Subject:\s*(?:Re:\s*)*(.*)/mi;
+ $sub[++$msgno] = lc($1) || '';
+ }
+ $msgs[$msgno] .= $_;
+ }
+ for my $i (sort { $sub[$a] cmp $sub[$b] || $a <=> $b } (0 .. $#msgs)) {
+ print $msgs[$i];
+ }
+
+Or more succinctly,
+
+ #!/usr/bin/perl -n00
+ # bysub2 - awkish sort-by-subject
+ BEGIN { $msgno = -1 }
+ $sub[++$msgno] = (/^Subject:\s*(?:Re:\s*)*(.*)/mi)[0] if /^From/m;
+ $msg[$msgno] .= $_;
+ END { print @msg[ sort { $sub[$a] cmp $sub[$b] || $a <=> $b } (0 .. $#msg) ] }
+
+=head2 How do I find out my hostname/domainname/IP address?
+
+The normal way to find your own hostname is to call the C<`hostname`>
+program. While sometimes expedient, this has some problems, such as
+not knowing whether you've got the canonical name or not. It's one of
+those tradeoffs of convenience versus portability.
+
+The Sys::Hostname module (part of the standard perl distribution) will
+give you the hostname after which you can find out the IP address
+(assuming you have working DNS) with a gethostbyname() call.
+
+ use Socket;
+ use Sys::Hostname;
+ my $host = hostname();
+ my $addr = inet_ntoa(scalar(gethostbyname($name)) || 'localhost');
+
+Probably the simplest way to learn your DNS domain name is to grok
+it out of /etc/resolv.conf, at least under Unix. Of course, this
+assumes several things about your resolv.conf configuration, including
+that it exists.
+
+(We still need a good DNS domain name-learning method for non-Unix
+systems.)
+
+=head2 How do I fetch a news article or the active newsgroups?
+
+Use the Net::NNTP or News::NNTPClient modules, both available from CPAN.
+This can make tasks like fetching the newsgroup list as simple as:
+
+ perl -MNews::NNTPClient
+ -e 'print News::NNTPClient->new->list("newsgroups")'
+
+=head2 How do I fetch/put an FTP file?
+
+LWP::Simple (available from CPAN) can fetch but not put. Net::FTP (also
+available from CPAN) is more complex but can put as well as fetch.
+
+=head2 How can I do RPC in Perl?
+
+A DCE::RPC module is being developed (but is not yet available), and
+will be released as part of the DCE-Perl package (available from
+CPAN). No ONC::RPC module is known.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
diff --git a/contrib/perl5/pod/perlform.pod b/contrib/perl5/pod/perlform.pod
new file mode 100644
index 0000000..6b65e04
--- /dev/null
+++ b/contrib/perl5/pod/perlform.pod
@@ -0,0 +1,337 @@
+=head1 NAME
+
+perlform - Perl formats
+
+=head1 DESCRIPTION
+
+Perl has a mechanism to help you generate simple reports and charts. To
+facilitate this, Perl helps you code up your output page close to how it
+will look when it's printed. It can keep track of things like how many
+lines are on a page, what page you're on, when to print page headers,
+etc. Keywords are borrowed from FORTRAN: format() to declare and write()
+to execute; see their entries in L<perlfunc>. Fortunately, the layout is
+much more legible, more like BASIC's PRINT USING statement. Think of it
+as a poor man's nroff(1).
+
+Formats, like packages and subroutines, are declared rather than
+executed, so they may occur at any point in your program. (Usually it's
+best to keep them all together though.) They have their own namespace
+apart from all the other "types" in Perl. This means that if you have a
+function named "Foo", it is not the same thing as having a format named
+"Foo". However, the default name for the format associated with a given
+filehandle is the same as the name of the filehandle. Thus, the default
+format for STDOUT is named "STDOUT", and the default format for filehandle
+TEMP is named "TEMP". They just look the same. They aren't.
+
+Output record formats are declared as follows:
+
+ format NAME =
+ FORMLIST
+ .
+
+If name is omitted, format "STDOUT" is defined. FORMLIST consists of
+a sequence of lines, each of which may be one of three types:
+
+=over 4
+
+=item 1.
+
+A comment, indicated by putting a '#' in the first column.
+
+=item 2.
+
+A "picture" line giving the format for one output line.
+
+=item 3.
+
+An argument line supplying values to plug into the previous picture line.
+
+=back
+
+Picture lines are printed exactly as they look, except for certain fields
+that substitute values into the line. Each field in a picture line starts
+with either "@" (at) or "^" (caret). These lines do not undergo any kind
+of variable interpolation. The at field (not to be confused with the array
+marker @) is the normal kind of field; the other kind, caret fields, are used
+to do rudimentary multi-line text block filling. The length of the field
+is supplied by padding out the field with multiple "E<lt>", "E<gt>", or "|"
+characters to specify, respectively, left justification, right
+justification, or centering. If the variable would exceed the width
+specified, it is truncated.
+
+As an alternate form of right justification, you may also use "#"
+characters (with an optional ".") to specify a numeric field. This way
+you can line up the decimal points. If any value supplied for these
+fields contains a newline, only the text up to the newline is printed.
+Finally, the special field "@*" can be used for printing multi-line,
+nontruncated values; it should appear by itself on a line.
+
+The values are specified on the following line in the same order as
+the picture fields. The expressions providing the values should be
+separated by commas. The expressions are all evaluated in a list context
+before the line is processed, so a single list expression could produce
+multiple list elements. The expressions may be spread out to more than
+one line if enclosed in braces. If so, the opening brace must be the first
+token on the first line. If an expression evaluates to a number with a
+decimal part, and if the corresponding picture specifies that the decimal
+part should appear in the output (that is, any picture except multiple "#"
+characters B<without> an embedded "."), the character used for the decimal
+point is B<always> determined by the current LC_NUMERIC locale. This
+means that, if, for example, the run-time environment happens to specify a
+German locale, "," will be used instead of the default ".". See
+L<perllocale> and L<"WARNINGS"> for more information.
+
+Picture fields that begin with ^ rather than @ are treated specially.
+With a # field, the field is blanked out if the value is undefined. For
+other field types, the caret enables a kind of fill mode. Instead of an
+arbitrary expression, the value supplied must be a scalar variable name
+that contains a text string. Perl puts as much text as it can into the
+field, and then chops off the front of the string so that the next time
+the variable is referenced, more of the text can be printed. (Yes, this
+means that the variable itself is altered during execution of the write()
+call, and is not returned.) Normally you would use a sequence of fields
+in a vertical stack to print out a block of text. You might wish to end
+the final field with the text "...", which will appear in the output if
+the text was too long to appear in its entirety. You can change which
+characters are legal to break on by changing the variable C<$:> (that's
+$FORMAT_LINE_BREAK_CHARACTERS if you're using the English module) to a
+list of the desired characters.
+
+Using caret fields can produce variable length records. If the text
+to be formatted is short, you can suppress blank lines by putting a
+"~" (tilde) character anywhere in the line. The tilde will be translated
+to a space upon output. If you put a second tilde contiguous to the
+first, the line will be repeated until all the fields on the line are
+exhausted. (If you use a field of the at variety, the expression you
+supply had better not give the same value every time forever!)
+
+Top-of-form processing is by default handled by a format with the
+same name as the current filehandle with "_TOP" concatenated to it.
+It's triggered at the top of each page. See L<perlfunc/write>.
+
+Examples:
+
+ # a report on the /etc/passwd file
+ format STDOUT_TOP =
+ Passwd File
+ Name Login Office Uid Gid Home
+ ------------------------------------------------------------------
+ .
+ format STDOUT =
+ @<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<<
+ $name, $login, $office,$uid,$gid, $home
+ .
+
+
+ # a report from a bug report form
+ format STDOUT_TOP =
+ Bug Reports
+ @<<<<<<<<<<<<<<<<<<<<<<< @||| @>>>>>>>>>>>>>>>>>>>>>>>
+ $system, $%, $date
+ ------------------------------------------------------------------
+ .
+ format STDOUT =
+ Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $subject
+ Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $index, $description
+ Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $priority, $date, $description
+ From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $from, $description
+ Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $programmer, $description
+ ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $description
+ ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $description
+ ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $description
+ ~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $description
+ ~ ^<<<<<<<<<<<<<<<<<<<<<<<...
+ $description
+ .
+
+It is possible to intermix print()s with write()s on the same output
+channel, but you'll have to handle C<$-> (C<$FORMAT_LINES_LEFT>)
+yourself.
+
+=head2 Format Variables
+
+The current format name is stored in the variable C<$~> (C<$FORMAT_NAME>),
+and the current top of form format name is in C<$^> (C<$FORMAT_TOP_NAME>).
+The current output page number is stored in C<$%> (C<$FORMAT_PAGE_NUMBER>),
+and the number of lines on the page is in C<$=> (C<$FORMAT_LINES_PER_PAGE>).
+Whether to autoflush output on this handle is stored in C<$|>
+(C<$OUTPUT_AUTOFLUSH>). The string output before each top of page (except
+the first) is stored in C<$^L> (C<$FORMAT_FORMFEED>). These variables are
+set on a per-filehandle basis, so you'll need to select() into a different
+one to affect them:
+
+ select((select(OUTF),
+ $~ = "My_Other_Format",
+ $^ = "My_Top_Format"
+ )[0]);
+
+Pretty ugly, eh? It's a common idiom though, so don't be too surprised
+when you see it. You can at least use a temporary variable to hold
+the previous filehandle: (this is a much better approach in general,
+because not only does legibility improve, you now have intermediary
+stage in the expression to single-step the debugger through):
+
+ $ofh = select(OUTF);
+ $~ = "My_Other_Format";
+ $^ = "My_Top_Format";
+ select($ofh);
+
+If you use the English module, you can even read the variable names:
+
+ use English;
+ $ofh = select(OUTF);
+ $FORMAT_NAME = "My_Other_Format";
+ $FORMAT_TOP_NAME = "My_Top_Format";
+ select($ofh);
+
+But you still have those funny select()s. So just use the FileHandle
+module. Now, you can access these special variables using lowercase
+method names instead:
+
+ use FileHandle;
+ format_name OUTF "My_Other_Format";
+ format_top_name OUTF "My_Top_Format";
+
+Much better!
+
+=head1 NOTES
+
+Because the values line may contain arbitrary expressions (for at fields,
+not caret fields), you can farm out more sophisticated processing
+to other functions, like sprintf() or one of your own. For example:
+
+ format Ident =
+ @<<<<<<<<<<<<<<<
+ &commify($n)
+ .
+
+To get a real at or caret into the field, do this:
+
+ format Ident =
+ I have an @ here.
+ "@"
+ .
+
+To center a whole line of text, do something like this:
+
+ format Ident =
+ @|||||||||||||||||||||||||||||||||||||||||||||||
+ "Some text line"
+ .
+
+There is no builtin way to say "float this to the right hand side
+of the page, however wide it is." You have to specify where it goes.
+The truly desperate can generate their own format on the fly, based
+on the current number of columns, and then eval() it:
+
+ $format = "format STDOUT = \n"
+ . '^' . '<' x $cols . "\n"
+ . '$entry' . "\n"
+ . "\t^" . "<" x ($cols-8) . "~~\n"
+ . '$entry' . "\n"
+ . ".\n";
+ print $format if $Debugging;
+ eval $format;
+ die $@ if $@;
+
+Which would generate a format looking something like this:
+
+ format STDOUT =
+ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $entry
+ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
+ $entry
+ .
+
+Here's a little program that's somewhat like fmt(1):
+
+ format =
+ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
+ $_
+
+ .
+
+ $/ = '';
+ while (<>) {
+ s/\s*\n\s*/ /g;
+ write;
+ }
+
+=head2 Footers
+
+While $FORMAT_TOP_NAME contains the name of the current header format,
+there is no corresponding mechanism to automatically do the same thing
+for a footer. Not knowing how big a format is going to be until you
+evaluate it is one of the major problems. It's on the TODO list.
+
+Here's one strategy: If you have a fixed-size footer, you can get footers
+by checking $FORMAT_LINES_LEFT before each write() and print the footer
+yourself if necessary.
+
+Here's another strategy: Open a pipe to yourself, using C<open(MYSELF, "|-")>
+(see L<perlfunc/open()>) and always write() to MYSELF instead of STDOUT.
+Have your child process massage its STDIN to rearrange headers and footers
+however you like. Not very convenient, but doable.
+
+=head2 Accessing Formatting Internals
+
+For low-level access to the formatting mechanism. you may use formline()
+and access C<$^A> (the $ACCUMULATOR variable) directly.
+
+For example:
+
+ $str = formline <<'END', 1,2,3;
+ @<<< @||| @>>>
+ END
+
+ print "Wow, I just stored `$^A' in the accumulator!\n";
+
+Or to make an swrite() subroutine, which is to write() what sprintf()
+is to printf(), do this:
+
+ use Carp;
+ sub swrite {
+ croak "usage: swrite PICTURE ARGS" unless @_;
+ my $format = shift;
+ $^A = "";
+ formline($format,@_);
+ return $^A;
+ }
+
+ $string = swrite(<<'END', 1, 2, 3);
+ Check me out
+ @<<< @||| @>>>
+ END
+ print $string;
+
+=head1 WARNINGS
+
+The lone dot that ends a format can also prematurely end a mail
+message passing through a misconfigured Internet mailer (and based on
+experience, such misconfiguration is the rule, not the exception). So
+when sending format code through mail, you should indent it so that
+the format-ending dot is not on the left margin; this will prevent
+SMTP cutoff.
+
+Lexical variables (declared with "my") are not visible within a
+format unless the format is declared within the scope of the lexical
+variable. (They weren't visible at all before version 5.001.)
+
+Formats are the only part of Perl that unconditionally use information
+from a program's locale; if a program's environment specifies an
+LC_NUMERIC locale, it is always used to specify the decimal point
+character in formatted output. Perl ignores all other aspects of locale
+handling unless the C<use locale> pragma is in effect. Formatted output
+cannot be controlled by C<use locale> because the pragma is tied to the
+block structure of the program, and, for historical reasons, formats
+exist outside that block structure. See L<perllocale> for further
+discussion of locale handling.
diff --git a/contrib/perl5/pod/perlfunc.pod b/contrib/perl5/pod/perlfunc.pod
new file mode 100644
index 0000000..4eac093
--- /dev/null
+++ b/contrib/perl5/pod/perlfunc.pod
@@ -0,0 +1,4440 @@
+=head1 NAME
+
+perlfunc - Perl builtin functions
+
+=head1 DESCRIPTION
+
+The functions in this section can serve as terms in an expression.
+They fall into two major categories: list operators and named unary
+operators. These differ in their precedence relationship with a
+following comma. (See the precedence table in L<perlop>.) List
+operators take more than one argument, while unary operators can never
+take more than one argument. Thus, a comma terminates the argument of
+a unary operator, but merely separates the arguments of a list
+operator. A unary operator generally provides a scalar context to its
+argument, while a list operator may provide either scalar and list
+contexts for its arguments. If it does both, the scalar arguments will
+be first, and the list argument will follow. (Note that there can ever
+be only one list argument.) For instance, splice() has three scalar
+arguments followed by a list.
+
+In the syntax descriptions that follow, list operators that expect a
+list (and provide list context for the elements of the list) are shown
+with LIST as an argument. Such a list may consist of any combination
+of scalar arguments or list values; the list values will be included
+in the list as if each individual element were interpolated at that
+point in the list, forming a longer single-dimensional list value.
+Elements of the LIST should be separated by commas.
+
+Any function in the list below may be used either with or without
+parentheses around its arguments. (The syntax descriptions omit the
+parentheses.) If you use the parentheses, the simple (but occasionally
+surprising) rule is this: It I<LOOKS> like a function, therefore it I<IS> a
+function, and precedence doesn't matter. Otherwise it's a list
+operator or unary operator, and precedence does matter. And whitespace
+between the function and left parenthesis doesn't count--so you need to
+be careful sometimes:
+
+ print 1+2+4; # Prints 7.
+ print(1+2) + 4; # Prints 3.
+ print (1+2)+4; # Also prints 3!
+ print +(1+2)+4; # Prints 7.
+ print ((1+2)+4); # Prints 7.
+
+If you run Perl with the B<-w> switch it can warn you about this. For
+example, the third line above produces:
+
+ print (...) interpreted as function at - line 1.
+ Useless use of integer addition in void context at - line 1.
+
+For functions that can be used in either a scalar or list context,
+nonabortive failure is generally indicated in a scalar context by
+returning the undefined value, and in a list context by returning the
+null list.
+
+Remember the following important rule: There is B<no rule> that relates
+the behavior of an expression in list context to its behavior in scalar
+context, or vice versa. It might do two totally different things.
+Each operator and function decides which sort of value it would be most
+appropriate to return in a scalar context. Some operators return the
+length of the list that would have been returned in list context. Some
+operators return the first value in the list. Some operators return the
+last value in the list. Some operators return a count of successful
+operations. In general, they do what you want, unless you want
+consistency.
+
+An named array in scalar context is quite different from what would at
+first glance appear to be a list in scalar context. You can't get a list
+like C<(1,2,3)> into being in scalar context, because the compiler knows
+the context at compile time. It would generate the scalar comma operator
+there, not the list construction version of the comma. That means it
+was never a list to start with.
+
+In general, functions in Perl that serve as wrappers for system calls
+of the same name (like chown(2), fork(2), closedir(2), etc.) all return
+true when they succeed and C<undef> otherwise, as is usually mentioned
+in the descriptions below. This is different from the C interfaces,
+which return C<-1> on failure. Exceptions to this rule are C<wait()>,
+C<waitpid()>, and C<syscall()>. System calls also set the special C<$!>
+variable on failure. Other functions do not, except accidentally.
+
+=head2 Perl Functions by Category
+
+Here are Perl's functions (including things that look like
+functions, like some keywords and named operators)
+arranged by category. Some functions appear in more
+than one place.
+
+=over
+
+=item Functions for SCALARs or strings
+
+C<chomp>, C<chop>, C<chr>, C<crypt>, C<hex>, C<index>, C<lc>, C<lcfirst>,
+C<length>, C<oct>, C<ord>, C<pack>, C<q/STRING/>, C<qq/STRING/>, C<reverse>,
+C<rindex>, C<sprintf>, C<substr>, C<tr///>, C<uc>, C<ucfirst>, C<y///>
+
+=item Regular expressions and pattern matching
+
+C<m//>, C<pos>, C<quotemeta>, C<s///>, C<split>, C<study>, C<qr//>
+
+=item Numeric functions
+
+C<abs>, C<atan2>, C<cos>, C<exp>, C<hex>, C<int>, C<log>, C<oct>, C<rand>,
+C<sin>, C<sqrt>, C<srand>
+
+=item Functions for real @ARRAYs
+
+C<pop>, C<push>, C<shift>, C<splice>, C<unshift>
+
+=item Functions for list data
+
+C<grep>, C<join>, C<map>, C<qw/STRING/>, C<reverse>, C<sort>, C<unpack>
+
+=item Functions for real %HASHes
+
+C<delete>, C<each>, C<exists>, C<keys>, C<values>
+
+=item Input and output functions
+
+C<binmode>, C<close>, C<closedir>, C<dbmclose>, C<dbmopen>, C<die>, C<eof>,
+C<fileno>, C<flock>, C<format>, C<getc>, C<print>, C<printf>, C<read>,
+C<readdir>, C<rewinddir>, C<seek>, C<seekdir>, C<select>, C<syscall>,
+C<sysread>, C<sysseek>, C<syswrite>, C<tell>, C<telldir>, C<truncate>,
+C<warn>, C<write>
+
+=item Functions for fixed length data or records
+
+C<pack>, C<read>, C<syscall>, C<sysread>, C<syswrite>, C<unpack>, C<vec>
+
+=item Functions for filehandles, files, or directories
+
+C<-I<X>>, C<chdir>, C<chmod>, C<chown>, C<chroot>, C<fcntl>, C<glob>,
+C<ioctl>, C<link>, C<lstat>, C<mkdir>, C<open>, C<opendir>, C<readlink>,
+C<rename>, C<rmdir>, C<stat>, C<symlink>, C<umask>, C<unlink>, C<utime>
+
+=item Keywords related to the control flow of your perl program
+
+C<caller>, C<continue>, C<die>, C<do>, C<dump>, C<eval>, C<exit>,
+C<goto>, C<last>, C<next>, C<redo>, C<return>, C<sub>, C<wantarray>
+
+=item Keywords related to scoping
+
+C<caller>, C<import>, C<local>, C<my>, C<package>, C<use>
+
+=item Miscellaneous functions
+
+C<defined>, C<dump>, C<eval>, C<formline>, C<local>, C<my>, C<reset>,
+C<scalar>, C<undef>, C<wantarray>
+
+=item Functions for processes and process groups
+
+C<alarm>, C<exec>, C<fork>, C<getpgrp>, C<getppid>, C<getpriority>, C<kill>,
+C<pipe>, C<qx/STRING/>, C<setpgrp>, C<setpriority>, C<sleep>, C<system>,
+C<times>, C<wait>, C<waitpid>
+
+=item Keywords related to perl modules
+
+C<do>, C<import>, C<no>, C<package>, C<require>, C<use>
+
+=item Keywords related to classes and object-orientedness
+
+C<bless>, C<dbmclose>, C<dbmopen>, C<package>, C<ref>, C<tie>, C<tied>,
+C<untie>, C<use>
+
+=item Low-level socket functions
+
+C<accept>, C<bind>, C<connect>, C<getpeername>, C<getsockname>,
+C<getsockopt>, C<listen>, C<recv>, C<send>, C<setsockopt>, C<shutdown>,
+C<socket>, C<socketpair>
+
+=item System V interprocess communication functions
+
+C<msgctl>, C<msgget>, C<msgrcv>, C<msgsnd>, C<semctl>, C<semget>, C<semop>,
+C<shmctl>, C<shmget>, C<shmread>, C<shmwrite>
+
+=item Fetching user and group info
+
+C<endgrent>, C<endhostent>, C<endnetent>, C<endpwent>, C<getgrent>,
+C<getgrgid>, C<getgrnam>, C<getlogin>, C<getpwent>, C<getpwnam>,
+C<getpwuid>, C<setgrent>, C<setpwent>
+
+=item Fetching network info
+
+C<endprotoent>, C<endservent>, C<gethostbyaddr>, C<gethostbyname>,
+C<gethostent>, C<getnetbyaddr>, C<getnetbyname>, C<getnetent>,
+C<getprotobyname>, C<getprotobynumber>, C<getprotoent>,
+C<getservbyname>, C<getservbyport>, C<getservent>, C<sethostent>,
+C<setnetent>, C<setprotoent>, C<setservent>
+
+=item Time-related functions
+
+C<gmtime>, C<localtime>, C<time>, C<times>
+
+=item Functions new in perl5
+
+C<abs>, C<bless>, C<chomp>, C<chr>, C<exists>, C<formline>, C<glob>,
+C<import>, C<lc>, C<lcfirst>, C<map>, C<my>, C<no>, C<prototype>, C<qx>,
+C<qw>, C<readline>, C<readpipe>, C<ref>, C<sub*>, C<sysopen>, C<tie>,
+C<tied>, C<uc>, C<ucfirst>, C<untie>, C<use>
+
+* - C<sub> was a keyword in perl4, but in perl5 it is an
+operator, which can be used in expressions.
+
+=item Functions obsoleted in perl5
+
+C<dbmclose>, C<dbmopen>
+
+=back
+
+=head2 Alphabetical Listing of Perl Functions
+
+=over 8
+
+=item I<-X> FILEHANDLE
+
+=item I<-X> EXPR
+
+=item I<-X>
+
+A file test, where X is one of the letters listed below. This unary
+operator takes one argument, either a filename or a filehandle, and
+tests the associated file to see if something is true about it. If the
+argument is omitted, tests C<$_>, except for C<-t>, which tests STDIN.
+Unless otherwise documented, it returns C<1> for TRUE and C<''> for FALSE, or
+the undefined value if the file doesn't exist. Despite the funny
+names, precedence is the same as any other named unary operator, and
+the argument may be parenthesized like any other unary operator. The
+operator may be any of:
+X<-r>X<-w>X<-x>X<-o>X<-R>X<-W>X<-X>X<-O>X<-e>X<-z>X<-s>X<-f>X<-d>X<-l>X<-p>
+X<-S>X<-b>X<-c>X<-t>X<-u>X<-g>X<-k>X<-T>X<-B>X<-M>X<-A>X<-C>
+
+ -r File is readable by effective uid/gid.
+ -w File is writable by effective uid/gid.
+ -x File is executable by effective uid/gid.
+ -o File is owned by effective uid.
+
+ -R File is readable by real uid/gid.
+ -W File is writable by real uid/gid.
+ -X File is executable by real uid/gid.
+ -O File is owned by real uid.
+
+ -e File exists.
+ -z File has zero size.
+ -s File has nonzero size (returns size).
+
+ -f File is a plain file.
+ -d File is a directory.
+ -l File is a symbolic link.
+ -p File is a named pipe (FIFO), or Filehandle is a pipe.
+ -S File is a socket.
+ -b File is a block special file.
+ -c File is a character special file.
+ -t Filehandle is opened to a tty.
+
+ -u File has setuid bit set.
+ -g File has setgid bit set.
+ -k File has sticky bit set.
+
+ -T File is a text file.
+ -B File is a binary file (opposite of -T).
+
+ -M Age of file in days when script started.
+ -A Same for access time.
+ -C Same for inode change time.
+
+The interpretation of the file permission operators C<-r>, C<-R>, C<-w>,
+C<-W>, C<-x>, and C<-X> is based solely on the mode of the file and the
+uids and gids of the user. There may be other reasons you can't actually
+read, write, or execute the file, such as AFS access control lists. Also note that, for the superuser,
+C<-r>, C<-R>, C<-w>, and C<-W> always return C<1>, and C<-x> and C<-X> return
+C<1> if any execute bit is set in the mode. Scripts run by the superuser may
+thus need to do a C<stat()> to determine the actual mode of the
+file, or temporarily set the uid to something else.
+
+Example:
+
+ while (<>) {
+ chop;
+ next unless -f $_; # ignore specials
+ #...
+ }
+
+Note that C<-s/a/b/> does not do a negated substitution. Saying
+C<-exp($foo)> still works as expected, however--only single letters
+following a minus are interpreted as file tests.
+
+The C<-T> and C<-B> switches work as follows. The first block or so of the
+file is examined for odd characters such as strange control codes or
+characters with the high bit set. If too many strange characters (E<gt>30%)
+are found, it's a C<-B> file, otherwise it's a C<-T> file. Also, any file
+containing null in the first block is considered a binary file. If C<-T>
+or C<-B> is used on a filehandle, the current stdio buffer is examined
+rather than the first block. Both C<-T> and C<-B> return TRUE on a null
+file, or a file at EOF when testing a filehandle. Because you have to
+read a file to do the C<-T> test, on most occasions you want to use a C<-f>
+against the file first, as in C<next unless -f $file && -T $file>.
+
+If any of the file tests (or either the C<stat()> or C<lstat()> operators) are given
+the special filehandle consisting of a solitary underline, then the stat
+structure of the previous file test (or stat operator) is used, saving
+a system call. (This doesn't work with C<-t>, and you need to remember
+that lstat() and C<-l> will leave values in the stat structure for the
+symbolic link, not the real file.) Example:
+
+ print "Can do.\n" if -r $a || -w _ || -x _;
+
+ stat($filename);
+ print "Readable\n" if -r _;
+ print "Writable\n" if -w _;
+ print "Executable\n" if -x _;
+ print "Setuid\n" if -u _;
+ print "Setgid\n" if -g _;
+ print "Sticky\n" if -k _;
+ print "Text\n" if -T _;
+ print "Binary\n" if -B _;
+
+=item abs VALUE
+
+=item abs
+
+Returns the absolute value of its argument.
+If VALUE is omitted, uses C<$_>.
+
+=item accept NEWSOCKET,GENERICSOCKET
+
+Accepts an incoming socket connect, just as the accept(2) system call
+does. Returns the packed address if it succeeded, FALSE otherwise.
+See example in L<perlipc/"Sockets: Client/Server Communication">.
+
+=item alarm SECONDS
+
+=item alarm
+
+Arranges to have a SIGALRM delivered to this process after the
+specified number of seconds have elapsed. If SECONDS is not specified,
+the value stored in C<$_> is used. (On some machines,
+unfortunately, the elapsed time may be up to one second less than you
+specified because of how seconds are counted.) Only one timer may be
+counting at once. Each call disables the previous timer, and an
+argument of C<0> may be supplied to cancel the previous timer without
+starting a new one. The returned value is the amount of time remaining
+on the previous timer.
+
+For delays of finer granularity than one second, you may use Perl's
+C<syscall()> interface to access setitimer(2) if your system supports it,
+or else see L</select()>. It is usually a mistake to intermix C<alarm()>
+and C<sleep()> calls.
+
+If you want to use C<alarm()> to time out a system call you need to use an
+C<eval()>/C<die()> pair. You can't rely on the alarm causing the system call to
+fail with C<$!> set to C<EINTR> because Perl sets up signal handlers to
+restart system calls on some systems. Using C<eval()>/C<die()> always works,
+modulo the caveats given in L<perlipc/"Signals">.
+
+ eval {
+ local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
+ alarm $timeout;
+ $nread = sysread SOCKET, $buffer, $size;
+ alarm 0;
+ };
+ if ($@) {
+ die unless $@ eq "alarm\n"; # propagate unexpected errors
+ # timed out
+ }
+ else {
+ # didn't
+ }
+
+=item atan2 Y,X
+
+Returns the arctangent of Y/X in the range -PI to PI.
+
+For the tangent operation, you may use the C<POSIX::tan()>
+function, or use the familiar relation:
+
+ sub tan { sin($_[0]) / cos($_[0]) }
+
+=item bind SOCKET,NAME
+
+Binds a network address to a socket, just as the bind system call
+does. Returns TRUE if it succeeded, FALSE otherwise. NAME should be a
+packed address of the appropriate type for the socket. See the examples in
+L<perlipc/"Sockets: Client/Server Communication">.
+
+=item binmode FILEHANDLE
+
+Arranges for the file to be read or written in "binary" mode in operating
+systems that distinguish between binary and text files. Files that are
+not in binary mode have CR LF sequences translated to LF on input and LF
+translated to CR LF on output. Binmode has no effect under Unix; in MS-DOS
+and similarly archaic systems, it may be imperative--otherwise your
+MS-DOS-damaged C library may mangle your file. The key distinction between
+systems that need C<binmode()> and those that don't is their text file
+formats. Systems like Unix, MacOS, and Plan9 that delimit lines with a single
+character, and that encode that character in C as C<"\n">, do not need
+C<binmode()>. The rest need it. If FILEHANDLE is an expression, the value
+is taken as the name of the filehandle.
+
+=item bless REF,CLASSNAME
+
+=item bless REF
+
+This function tells the thingy referenced by REF that it is now
+an object in the CLASSNAME package--or the current package if no CLASSNAME
+is specified, which is often the case. It returns the reference for
+convenience, because a C<bless()> is often the last thing in a constructor.
+Always use the two-argument version if the function doing the blessing
+might be inherited by a derived class. See L<perltoot> and L<perlobj>
+for more about the blessing (and blessings) of objects.
+
+=item caller EXPR
+
+=item caller
+
+Returns the context of the current subroutine call. In scalar context,
+returns the caller's package name if there is a caller, that is, if
+we're in a subroutine or C<eval()> or C<require()>, and the undefined value
+otherwise. In list context, returns
+
+ ($package, $filename, $line) = caller;
+
+With EXPR, it returns some extra information that the debugger uses to
+print a stack trace. The value of EXPR indicates how many call frames
+to go back before the current one.
+
+ ($package, $filename, $line, $subroutine,
+ $hasargs, $wantarray, $evaltext, $is_require) = caller($i);
+
+Here C<$subroutine> may be C<"(eval)"> if the frame is not a subroutine
+call, but an C<eval()>. In such a case additional elements C<$evaltext> and
+C<$is_require> are set: C<$is_require> is true if the frame is created by a
+C<require> or C<use> statement, C<$evaltext> contains the text of the
+C<eval EXPR> statement. In particular, for a C<eval BLOCK> statement,
+C<$filename> is C<"(eval)">, but C<$evaltext> is undefined. (Note also that
+each C<use> statement creates a C<require> frame inside an C<eval EXPR>)
+frame.
+
+Furthermore, when called from within the DB package, caller returns more
+detailed information: it sets the list variable C<@DB::args> to be the
+arguments with which the subroutine was invoked.
+
+Be aware that the optimizer might have optimized call frames away before
+C<caller()> had a chance to get the information. That means that C<caller(N)>
+might not return information about the call frame you expect it do, for
+C<N E<gt> 1>. In particular, C<@DB::args> might have information from the
+previous time C<caller()> was called.
+
+=item chdir EXPR
+
+Changes the working directory to EXPR, if possible. If EXPR is
+omitted, changes to home directory. Returns TRUE upon success, FALSE
+otherwise. See example under C<die()>.
+
+=item chmod LIST
+
+Changes the permissions of a list of files. The first element of the
+list must be the numerical mode, which should probably be an octal
+number, and which definitely should I<not> a string of octal digits:
+C<0644> is okay, C<'0644'> is not. Returns the number of files
+successfully changed. See also L</oct>, if all you have is a string.
+
+ $cnt = chmod 0755, 'foo', 'bar';
+ chmod 0755, @executables;
+ $mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to
+ # --w----r-T
+ $mode = '0644'; chmod oct($mode), 'foo'; # this is better
+ $mode = 0644; chmod $mode, 'foo'; # this is best
+
+=item chomp VARIABLE
+
+=item chomp LIST
+
+=item chomp
+
+This is a slightly safer version of L</chop>. It removes any
+line ending that corresponds to the current value of C<$/> (also known as
+$INPUT_RECORD_SEPARATOR in the C<English> module). It returns the total
+number of characters removed from all its arguments. It's often used to
+remove the newline from the end of an input record when you're worried
+that the final record may be missing its newline. When in paragraph mode
+(C<$/ = "">), it removes all trailing newlines from the string. If
+VARIABLE is omitted, it chomps C<$_>. Example:
+
+ while (<>) {
+ chomp; # avoid \n on last field
+ @array = split(/:/);
+ # ...
+ }
+
+You can actually chomp anything that's an lvalue, including an assignment:
+
+ chomp($cwd = `pwd`);
+ chomp($answer = <STDIN>);
+
+If you chomp a list, each element is chomped, and the total number of
+characters removed is returned.
+
+=item chop VARIABLE
+
+=item chop LIST
+
+=item chop
+
+Chops off the last character of a string and returns the character
+chopped. It's used primarily to remove the newline from the end of an
+input record, but is much more efficient than C<s/\n//> because it neither
+scans nor copies the string. If VARIABLE is omitted, chops C<$_>.
+Example:
+
+ while (<>) {
+ chop; # avoid \n on last field
+ @array = split(/:/);
+ #...
+ }
+
+You can actually chop anything that's an lvalue, including an assignment:
+
+ chop($cwd = `pwd`);
+ chop($answer = <STDIN>);
+
+If you chop a list, each element is chopped. Only the value of the
+last C<chop()> is returned.
+
+Note that C<chop()> returns the last character. To return all but the last
+character, use C<substr($string, 0, -1)>.
+
+=item chown LIST
+
+Changes the owner (and group) of a list of files. The first two
+elements of the list must be the I<NUMERICAL> uid and gid, in that order.
+Returns the number of files successfully changed.
+
+ $cnt = chown $uid, $gid, 'foo', 'bar';
+ chown $uid, $gid, @filenames;
+
+Here's an example that looks up nonnumeric uids in the passwd file:
+
+ print "User: ";
+ chop($user = <STDIN>);
+ print "Files: ";
+ chop($pattern = <STDIN>);
+
+ ($login,$pass,$uid,$gid) = getpwnam($user)
+ or die "$user not in passwd file";
+
+ @ary = glob($pattern); # expand filenames
+ chown $uid, $gid, @ary;
+
+On most systems, you are not allowed to change the ownership of the
+file unless you're the superuser, although you should be able to change
+the group to any of your secondary groups. On insecure systems, these
+restrictions may be relaxed, but this is not a portable assumption.
+
+=item chr NUMBER
+
+=item chr
+
+Returns the character represented by that NUMBER in the character set.
+For example, C<chr(65)> is C<"A"> in ASCII. For the reverse, use L</ord>.
+
+If NUMBER is omitted, uses C<$_>.
+
+=item chroot FILENAME
+
+=item chroot
+
+This function works like the system call by the same name: it makes the
+named directory the new root directory for all further pathnames that
+begin with a C<"/"> by your process and all its children. (It doesn't
+change your current working directory, which is unaffected.) For security
+reasons, this call is restricted to the superuser. If FILENAME is
+omitted, does a C<chroot()> to C<$_>.
+
+=item close FILEHANDLE
+
+=item close
+
+Closes the file or pipe associated with the file handle, returning TRUE
+only if stdio successfully flushes buffers and closes the system file
+descriptor. Closes the currently selected filehandle if the argument
+is omitted.
+
+You don't have to close FILEHANDLE if you are immediately going to do
+another C<open()> on it, because C<open()> will close it for you. (See
+C<open()>.) However, an explicit C<close()> on an input file resets the line
+counter (C<$.>), while the implicit close done by C<open()> does not.
+
+If the file handle came from a piped open C<close()> will additionally
+return FALSE if one of the other system calls involved fails or if the
+program exits with non-zero status. (If the only problem was that the
+program exited non-zero C<$!> will be set to C<0>.) Also, closing a pipe
+waits for the process executing on the pipe to complete, in case you
+want to look at the output of the pipe afterwards. Closing a pipe
+explicitly also puts the exit status value of the command into C<$?>.
+
+Example:
+
+ open(OUTPUT, '|sort >foo') # pipe to sort
+ or die "Can't start sort: $!";
+ #... # print stuff to output
+ close OUTPUT # wait for sort to finish
+ or warn $! ? "Error closing sort pipe: $!"
+ : "Exit status $? from sort";
+ open(INPUT, 'foo') # get sort's results
+ or die "Can't open 'foo' for input: $!";
+
+FILEHANDLE may be an expression whose value can be used as an indirect
+filehandle, usually the real filehandle name.
+
+=item closedir DIRHANDLE
+
+Closes a directory opened by C<opendir()> and returns the success of that
+system call.
+
+DIRHANDLE may be an expression whose value can be used as an indirect
+dirhandle, usually the real dirhandle name.
+
+=item connect SOCKET,NAME
+
+Attempts to connect to a remote socket, just as the connect system call
+does. Returns TRUE if it succeeded, FALSE otherwise. NAME should be a
+packed address of the appropriate type for the socket. See the examples in
+L<perlipc/"Sockets: Client/Server Communication">.
+
+=item continue BLOCK
+
+Actually a flow control statement rather than a function. If there is a
+C<continue> BLOCK attached to a BLOCK (typically in a C<while> or
+C<foreach>), it is always executed just before the conditional is about to
+be evaluated again, just like the third part of a C<for> loop in C. Thus
+it can be used to increment a loop variable, even when the loop has been
+continued via the C<next> statement (which is similar to the C C<continue>
+statement).
+
+C<last>, C<next>, or C<redo> may appear within a C<continue>
+block. C<last> and C<redo> will behave as if they had been executed within
+the main block. So will C<next>, but since it will execute a C<continue>
+block, it may be more entertaining.
+
+ while (EXPR) {
+ ### redo always comes here
+ do_something;
+ } continue {
+ ### next always comes here
+ do_something_else;
+ # then back the top to re-check EXPR
+ }
+ ### last always comes here
+
+Omitting the C<continue> section is semantically equivalent to using an
+empty one, logically enough. In that case, C<next> goes directly back
+to check the condition at the top of the loop.
+
+=item cos EXPR
+
+Returns the cosine of EXPR (expressed in radians). If EXPR is omitted,
+takes cosine of C<$_>.
+
+For the inverse cosine operation, you may use the C<POSIX::acos()>
+function, or use this relation:
+
+ sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) }
+
+=item crypt PLAINTEXT,SALT
+
+Encrypts a string exactly like the crypt(3) function in the C library
+(assuming that you actually have a version there that has not been
+extirpated as a potential munition). This can prove useful for checking
+the password file for lousy passwords, amongst other things. Only the
+guys wearing white hats should do this.
+
+Note that C<crypt()> is intended to be a one-way function, much like breaking
+eggs to make an omelette. There is no (known) corresponding decrypt
+function. As a result, this function isn't all that useful for
+cryptography. (For that, see your nearby CPAN mirror.)
+
+Here's an example that makes sure that whoever runs this program knows
+their own password:
+
+ $pwd = (getpwuid($<))[1];
+ $salt = substr($pwd, 0, 2);
+
+ system "stty -echo";
+ print "Password: ";
+ chop($word = <STDIN>);
+ print "\n";
+ system "stty echo";
+
+ if (crypt($word, $salt) ne $pwd) {
+ die "Sorry...\n";
+ } else {
+ print "ok\n";
+ }
+
+Of course, typing in your own password to whoever asks you
+for it is unwise.
+
+=item dbmclose HASH
+
+[This function has been superseded by the C<untie()> function.]
+
+Breaks the binding between a DBM file and a hash.
+
+=item dbmopen HASH,DBNAME,MODE
+
+[This function has been superseded by the C<tie()> function.]
+
+This binds a dbm(3), ndbm(3), sdbm(3), gdbm(3), or Berkeley DB file to a
+hash. HASH is the name of the hash. (Unlike normal C<open()>, the first
+argument is I<NOT> a filehandle, even though it looks like one). DBNAME
+is the name of the database (without the F<.dir> or F<.pag> extension if
+any). If the database does not exist, it is created with protection
+specified by MODE (as modified by the C<umask()>). If your system supports
+only the older DBM functions, you may perform only one C<dbmopen()> in your
+program. In older versions of Perl, if your system had neither DBM nor
+ndbm, calling C<dbmopen()> produced a fatal error; it now falls back to
+sdbm(3).
+
+If you don't have write access to the DBM file, you can only read hash
+variables, not set them. If you want to test whether you can write,
+either use file tests or try setting a dummy hash entry inside an C<eval()>,
+which will trap the error.
+
+Note that functions such as C<keys()> and C<values()> may return huge lists
+when used on large DBM files. You may prefer to use the C<each()>
+function to iterate over large DBM files. Example:
+
+ # print out history file offsets
+ dbmopen(%HIST,'/usr/lib/news/history',0666);
+ while (($key,$val) = each %HIST) {
+ print $key, ' = ', unpack('L',$val), "\n";
+ }
+ dbmclose(%HIST);
+
+See also L<AnyDBM_File> for a more general description of the pros and
+cons of the various dbm approaches, as well as L<DB_File> for a particularly
+rich implementation.
+
+=item defined EXPR
+
+=item defined
+
+Returns a Boolean value telling whether EXPR has a value other than
+the undefined value C<undef>. If EXPR is not present, C<$_> will be
+checked.
+
+Many operations return C<undef> to indicate failure, end of file,
+system error, uninitialized variable, and other exceptional
+conditions. This function allows you to distinguish C<undef> from
+other values. (A simple Boolean test will not distinguish among
+C<undef>, zero, the empty string, and C<"0">, which are all equally
+false.) Note that since C<undef> is a valid scalar, its presence
+doesn't I<necessarily> indicate an exceptional condition: C<pop()>
+returns C<undef> when its argument is an empty array, I<or> when the
+element to return happens to be C<undef>.
+
+You may also use C<defined()> to check whether a subroutine exists, by
+saying C<defined &func> without parentheses. On the other hand, use
+of C<defined()> upon aggregates (hashes and arrays) is not guaranteed to
+produce intuitive results, and should probably be avoided.
+
+When used on a hash element, it tells you whether the value is defined,
+not whether the key exists in the hash. Use L</exists> for the latter
+purpose.
+
+Examples:
+
+ print if defined $switch{'D'};
+ print "$val\n" while defined($val = pop(@ary));
+ die "Can't readlink $sym: $!"
+ unless defined($value = readlink $sym);
+ sub foo { defined &$bar ? &$bar(@_) : die "No bar"; }
+ $debugging = 0 unless defined $debugging;
+
+Note: Many folks tend to overuse C<defined()>, and then are surprised to
+discover that the number C<0> and C<""> (the zero-length string) are, in fact,
+defined values. For example, if you say
+
+ "ab" =~ /a(.*)b/;
+
+The pattern match succeeds, and C<$1> is defined, despite the fact that it
+matched "nothing". But it didn't really match nothing--rather, it
+matched something that happened to be C<0> characters long. This is all
+very above-board and honest. When a function returns an undefined value,
+it's an admission that it couldn't give you an honest answer. So you
+should use C<defined()> only when you're questioning the integrity of what
+you're trying to do. At other times, a simple comparison to C<0> or C<""> is
+what you want.
+
+Currently, using C<defined()> on an entire array or hash reports whether
+memory for that aggregate has ever been allocated. So an array you set
+to the empty list appears undefined initially, and one that once was full
+and that you then set to the empty list still appears defined. You
+should instead use a simple test for size:
+
+ if (@an_array) { print "has array elements\n" }
+ if (%a_hash) { print "has hash members\n" }
+
+Using C<undef()> on these, however, does clear their memory and then report
+them as not defined anymore, but you shouldn't do that unless you don't
+plan to use them again, because it saves time when you load them up
+again to have memory already ready to be filled. The normal way to
+free up space used by an aggregate is to assign the empty list.
+
+This counterintuitive behavior of C<defined()> on aggregates may be
+changed, fixed, or broken in a future release of Perl.
+
+See also L</undef>, L</exists>, L</ref>.
+
+=item delete EXPR
+
+Deletes the specified key(s) and their associated values from a hash.
+For each key, returns the deleted value associated with that key, or
+the undefined value if there was no such key. Deleting from C<$ENV{}>
+modifies the environment. Deleting from a hash tied to a DBM file
+deletes the entry from the DBM file. (But deleting from a C<tie()>d hash
+doesn't necessarily return anything.)
+
+The following deletes all the values of a hash:
+
+ foreach $key (keys %HASH) {
+ delete $HASH{$key};
+ }
+
+And so does this:
+
+ delete @HASH{keys %HASH}
+
+(But both of these are slower than just assigning the empty list, or
+using C<undef()>.) Note that the EXPR can be arbitrarily complicated as
+long as the final operation is a hash element lookup or hash slice:
+
+ delete $ref->[$x][$y]{$key};
+ delete @{$ref->[$x][$y]}{$key1, $key2, @morekeys};
+
+=item die LIST
+
+Outside an C<eval()>, prints the value of LIST to C<STDERR> and exits with
+the current value of C<$!> (errno). If C<$!> is C<0>, exits with the value of
+C<($? E<gt>E<gt> 8)> (backtick `command` status). If C<($? E<gt>E<gt> 8)>
+is C<0>, exits with C<255>. Inside an C<eval(),> the error message is stuffed into
+C<$@> and the C<eval()> is terminated with the undefined value. This makes
+C<die()> the way to raise an exception.
+
+Equivalent examples:
+
+ die "Can't cd to spool: $!\n" unless chdir '/usr/spool/news';
+ chdir '/usr/spool/news' or die "Can't cd to spool: $!\n"
+
+If the value of EXPR does not end in a newline, the current script line
+number and input line number (if any) are also printed, and a newline
+is supplied. Hint: sometimes appending C<", stopped"> to your message
+will cause it to make better sense when the string C<"at foo line 123"> is
+appended. Suppose you are running script "canasta".
+
+ die "/etc/games is no good";
+ die "/etc/games is no good, stopped";
+
+produce, respectively
+
+ /etc/games is no good at canasta line 123.
+ /etc/games is no good, stopped at canasta line 123.
+
+See also C<exit()> and C<warn()>.
+
+If LIST is empty and C<$@> already contains a value (typically from a
+previous eval) that value is reused after appending C<"\t...propagated">.
+This is useful for propagating exceptions:
+
+ eval { ... };
+ die unless $@ =~ /Expected exception/;
+
+If C<$@> is empty then the string C<"Died"> is used.
+
+You can arrange for a callback to be run just before the C<die()> does
+its deed, by setting the C<$SIG{__DIE__}> hook. The associated handler
+will be called with the error text and can change the error message, if
+it sees fit, by calling C<die()> again. See L<perlvar/$SIG{expr}> for details on
+setting C<%SIG> entries, and L<"eval BLOCK"> for some examples.
+
+Note that the C<$SIG{__DIE__}> hook is called even inside eval()ed
+blocks/strings. If one wants the hook to do nothing in such
+situations, put
+
+ die @_ if $^S;
+
+as the first line of the handler (see L<perlvar/$^S>).
+
+=item do BLOCK
+
+Not really a function. Returns the value of the last command in the
+sequence of commands indicated by BLOCK. When modified by a loop
+modifier, executes the BLOCK once before testing the loop condition.
+(On other statements the loop modifiers test the conditional first.)
+
+=item do SUBROUTINE(LIST)
+
+A deprecated form of subroutine call. See L<perlsub>.
+
+=item do EXPR
+
+Uses the value of EXPR as a filename and executes the contents of the
+file as a Perl script. Its primary use is to include subroutines
+from a Perl subroutine library.
+
+ do 'stat.pl';
+
+is just like
+
+ scalar eval `cat stat.pl`;
+
+except that it's more efficient and concise, keeps track of the
+current filename for error messages, and searches all the B<-I>
+libraries if the file isn't in the current directory (see also the @INC
+array in L<perlvar/Predefined Names>). It is also different in how
+code evaluated with C<do FILENAME> doesn't see lexicals in the enclosing
+scope like C<eval STRING> does. It's the same, however, in that it does
+reparse the file every time you call it, so you probably don't want to
+do this inside a loop.
+
+If C<do> cannot read the file, it returns undef and sets C<$!> to the
+error. If C<do> can read the file but cannot compile it, it
+returns undef and sets an error message in C<$@>. If the file is
+successfully compiled, C<do> returns the value of the last expression
+evaluated.
+
+Note that inclusion of library modules is better done with the
+C<use()> and C<require()> operators, which also do automatic error checking
+and raise an exception if there's a problem.
+
+You might like to use C<do> to read in a program configuration
+file. Manual error checking can be done this way:
+
+ # read in config files: system first, then user
+ for $file ("/share/prog/defaults.rc",
+ "$ENV{HOME}/.someprogrc") {
+ unless ($return = do $file) {
+ warn "couldn't parse $file: $@" if $@;
+ warn "couldn't do $file: $!" unless defined $return;
+ warn "couldn't run $file" unless $return;
+ }
+ }
+
+=item dump LABEL
+
+This causes an immediate core dump. Primarily this is so that you can
+use the B<undump> program to turn your core dump into an executable binary
+after having initialized all your variables at the beginning of the
+program. When the new binary is executed it will begin by executing a
+C<goto LABEL> (with all the restrictions that C<goto> suffers). Think of
+it as a goto with an intervening core dump and reincarnation. If C<LABEL>
+is omitted, restarts the program from the top. WARNING: Any files
+opened at the time of the dump will NOT be open any more when the
+program is reincarnated, with possible resulting confusion on the part
+of Perl. See also B<-u> option in L<perlrun>.
+
+Example:
+
+ #!/usr/bin/perl
+ require 'getopt.pl';
+ require 'stat.pl';
+ %days = (
+ 'Sun' => 1,
+ 'Mon' => 2,
+ 'Tue' => 3,
+ 'Wed' => 4,
+ 'Thu' => 5,
+ 'Fri' => 6,
+ 'Sat' => 7,
+ );
+
+ dump QUICKSTART if $ARGV[0] eq '-d';
+
+ QUICKSTART:
+ Getopt('f');
+
+This operator is largely obsolete, partly because it's very hard to
+convert a core file into an executable, and because the real perl-to-C
+compiler has superseded it.
+
+=item each HASH
+
+When called in list context, returns a 2-element list consisting of the
+key and value for the next element of a hash, so that you can iterate over
+it. When called in scalar context, returns the key for only the "next"
+element in the hash. (Note: Keys may be C<"0"> or C<"">, which are logically
+false; you may wish to avoid constructs like C<while ($k = each %foo) {}>
+for this reason.)
+
+Entries are returned in an apparently random order. When the hash is
+entirely read, a null array is returned in list context (which when
+assigned produces a FALSE (C<0>) value), and C<undef> in
+scalar context. The next call to C<each()> after that will start iterating
+again. There is a single iterator for each hash, shared by all C<each()>,
+C<keys()>, and C<values()> function calls in the program; it can be reset by
+reading all the elements from the hash, or by evaluating C<keys HASH> or
+C<values HASH>. If you add or delete elements of a hash while you're
+iterating over it, you may get entries skipped or duplicated, so don't.
+
+The following prints out your environment like the printenv(1) program,
+only in a different order:
+
+ while (($key,$value) = each %ENV) {
+ print "$key=$value\n";
+ }
+
+See also C<keys()> and C<values()>.
+
+=item eof FILEHANDLE
+
+=item eof ()
+
+=item eof
+
+Returns 1 if the next read on FILEHANDLE will return end of file, or if
+FILEHANDLE is not open. FILEHANDLE may be an expression whose value
+gives the real filehandle. (Note that this function actually
+reads a character and then C<ungetc()>s it, so isn't very useful in an
+interactive context.) Do not read from a terminal file (or call
+C<eof(FILEHANDLE)> on it) after end-of-file is reached. Filetypes such
+as terminals may lose the end-of-file condition if you do.
+
+An C<eof> without an argument uses the last file read as argument.
+Using C<eof()> with empty parentheses is very different. It indicates the pseudo file formed of
+the files listed on the command line, i.e., C<eof()> is reasonable to
+use inside a C<while (E<lt>E<gt>)> loop to detect the end of only the
+last file. Use C<eof(ARGV)> or eof without the parentheses to test
+I<EACH> file in a while (E<lt>E<gt>) loop. Examples:
+
+ # reset line numbering on each input file
+ while (<>) {
+ next if /^\s*#/; # skip comments
+ print "$.\t$_";
+ } continue {
+ close ARGV if eof; # Not eof()!
+ }
+
+ # insert dashes just before last line of last file
+ while (<>) {
+ if (eof()) { # check for end of current file
+ print "--------------\n";
+ close(ARGV); # close or break; is needed if we
+ # are reading from the terminal
+ }
+ print;
+ }
+
+Practical hint: you almost never need to use C<eof> in Perl, because the
+input operators return false values when they run out of data, or if there
+was an error.
+
+=item eval EXPR
+
+=item eval BLOCK
+
+In the first form, the return value of EXPR is parsed and executed as if it
+were a little Perl program. The value of the expression (which is itself
+determined within scalar context) is first parsed, and if there weren't any
+errors, executed in the context of the current Perl program, so that any
+variable settings or subroutine and format definitions remain afterwards.
+Note that the value is parsed every time the eval executes. If EXPR is
+omitted, evaluates C<$_>. This form is typically used to delay parsing
+and subsequent execution of the text of EXPR until run time.
+
+In the second form, the code within the BLOCK is parsed only once--at the
+same time the code surrounding the eval itself was parsed--and executed
+within the context of the current Perl program. This form is typically
+used to trap exceptions more efficiently than the first (see below), while
+also providing the benefit of checking the code within BLOCK at compile
+time.
+
+The final semicolon, if any, may be omitted from the value of EXPR or within
+the BLOCK.
+
+In both forms, the value returned is the value of the last expression
+evaluated inside the mini-program; a return statement may be also used, just
+as with subroutines. The expression providing the return value is evaluated
+in void, scalar, or list context, depending on the context of the eval itself.
+See L</wantarray> for more on how the evaluation context can be determined.
+
+If there is a syntax error or runtime error, or a C<die()> statement is
+executed, an undefined value is returned by C<eval()>, and C<$@> is set to the
+error message. If there was no error, C<$@> is guaranteed to be a null
+string. Beware that using C<eval()> neither silences perl from printing
+warnings to STDERR, nor does it stuff the text of warning messages into C<$@>.
+To do either of those, you have to use the C<$SIG{__WARN__}> facility. See
+L</warn> and L<perlvar>.
+
+Note that, because C<eval()> traps otherwise-fatal errors, it is useful for
+determining whether a particular feature (such as C<socket()> or C<symlink()>)
+is implemented. It is also Perl's exception trapping mechanism, where
+the die operator is used to raise exceptions.
+
+If the code to be executed doesn't vary, you may use the eval-BLOCK
+form to trap run-time errors without incurring the penalty of
+recompiling each time. The error, if any, is still returned in C<$@>.
+Examples:
+
+ # make divide-by-zero nonfatal
+ eval { $answer = $a / $b; }; warn $@ if $@;
+
+ # same thing, but less efficient
+ eval '$answer = $a / $b'; warn $@ if $@;
+
+ # a compile-time error
+ eval { $answer = }; # WRONG
+
+ # a run-time error
+ eval '$answer ='; # sets $@
+
+When using the C<eval{}> form as an exception trap in libraries, you may
+wish not to trigger any C<__DIE__> hooks that user code may have
+installed. You can use the C<local $SIG{__DIE__}> construct for this
+purpose, as shown in this example:
+
+ # a very private exception trap for divide-by-zero
+ eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
+ warn $@ if $@;
+
+This is especially significant, given that C<__DIE__> hooks can call
+C<die()> again, which has the effect of changing their error messages:
+
+ # __DIE__ hooks may modify error messages
+ {
+ local $SIG{'__DIE__'} =
+ sub { (my $x = $_[0]) =~ s/foo/bar/g; die $x };
+ eval { die "foo lives here" };
+ print $@ if $@; # prints "bar lives here"
+ }
+
+With an C<eval()>, you should be especially careful to remember what's
+being looked at when:
+
+ eval $x; # CASE 1
+ eval "$x"; # CASE 2
+
+ eval '$x'; # CASE 3
+ eval { $x }; # CASE 4
+
+ eval "\$$x++"; # CASE 5
+ $$x++; # CASE 6
+
+Cases 1 and 2 above behave identically: they run the code contained in
+the variable C<$x>. (Although case 2 has misleading double quotes making
+the reader wonder what else might be happening (nothing is).) Cases 3
+and 4 likewise behave in the same way: they run the code C<'$x'>, which
+does nothing but return the value of C<$x>. (Case 4 is preferred for
+purely visual reasons, but it also has the advantage of compiling at
+compile-time instead of at run-time.) Case 5 is a place where
+normally you I<WOULD> like to use double quotes, except that in this
+particular situation, you can just use symbolic references instead, as
+in case 6.
+
+=item exec LIST
+
+=item exec PROGRAM LIST
+
+The C<exec()> function executes a system command I<AND NEVER RETURNS> -
+use C<system()> instead of C<exec()> if you want it to return. It fails and
+returns FALSE only if the command does not exist I<and> it is executed
+directly instead of via your system's command shell (see below).
+
+Since it's a common mistake to use C<exec()> instead of C<system()>, Perl
+warns you if there is a following statement which isn't C<die()>, C<warn()>,
+or C<exit()> (if C<-w> is set - but you always do that). If you
+I<really> want to follow an C<exec()> with some other statement, you
+can use one of these styles to avoid the warning:
+
+ exec ('foo') or print STDERR "couldn't exec foo: $!";
+ { exec ('foo') }; print STDERR "couldn't exec foo: $!";
+
+If there is more than one argument in LIST, or if LIST is an array
+with more than one value, calls execvp(3) with the arguments in LIST.
+If there is only one scalar argument or an array with one element in it,
+the argument is checked for shell metacharacters, and if there are any,
+the entire argument is passed to the system's command shell for parsing
+(this is C</bin/sh -c> on Unix platforms, but varies on other platforms).
+If there are no shell metacharacters in the argument, it is split into
+words and passed directly to C<execvp()>, which is more efficient. Note:
+C<exec()> and C<system()> do not flush your output buffer, so you may need to
+set C<$|> to avoid lost output. Examples:
+
+ exec '/bin/echo', 'Your arguments are: ', @ARGV;
+ exec "sort $outfile | uniq";
+
+If you don't really want to execute the first argument, but want to lie
+to the program you are executing about its own name, you can specify
+the program you actually want to run as an "indirect object" (without a
+comma) in front of the LIST. (This always forces interpretation of the
+LIST as a multivalued list, even if there is only a single scalar in
+the list.) Example:
+
+ $shell = '/bin/csh';
+ exec $shell '-sh'; # pretend it's a login shell
+
+or, more directly,
+
+ exec {'/bin/csh'} '-sh'; # pretend it's a login shell
+
+When the arguments get executed via the system shell, results will
+be subject to its quirks and capabilities. See L<perlop/"`STRING`">
+for details.
+
+Using an indirect object with C<exec()> or C<system()> is also more secure.
+This usage forces interpretation of the arguments as a multivalued list,
+even if the list had just one argument. That way you're safe from the
+shell expanding wildcards or splitting up words with whitespace in them.
+
+ @args = ( "echo surprise" );
+
+ system @args; # subject to shell escapes
+ # if @args == 1
+ system { $args[0] } @args; # safe even with one-arg list
+
+The first version, the one without the indirect object, ran the I<echo>
+program, passing it C<"surprise"> an argument. The second version
+didn't--it tried to run a program literally called I<"echo surprise">,
+didn't find it, and set C<$?> to a non-zero value indicating failure.
+
+Note that C<exec()> will not call your C<END> blocks, nor will it call
+any C<DESTROY> methods in your objects.
+
+=item exists EXPR
+
+Returns TRUE if the specified hash key exists in its hash array, even
+if the corresponding value is undefined.
+
+ print "Exists\n" if exists $array{$key};
+ print "Defined\n" if defined $array{$key};
+ print "True\n" if $array{$key};
+
+A hash element can be TRUE only if it's defined, and defined if
+it exists, but the reverse doesn't necessarily hold true.
+
+Note that the EXPR can be arbitrarily complicated as long as the final
+operation is a hash key lookup:
+
+ if (exists $ref->{"A"}{"B"}{$key}) { ... }
+
+Although the last element will not spring into existence just because its
+existence was tested, intervening ones will. Thus C<$ref-E<gt>{"A"}>
+C<$ref-E<gt>{"B"}> will spring into existence due to the existence
+test for a $key element. This autovivification may be fixed in a later
+release.
+
+=item exit EXPR
+
+Evaluates EXPR and exits immediately with that value. (Actually, it
+calls any defined C<END> routines first, but the C<END> routines may not
+abort the exit. Likewise any object destructors that need to be called
+are called before exit.) Example:
+
+ $ans = <STDIN>;
+ exit 0 if $ans =~ /^[Xx]/;
+
+See also C<die()>. If EXPR is omitted, exits with C<0> status. The only
+universally portable values for EXPR are C<0> for success and C<1> for error;
+all other values are subject to unpredictable interpretation depending
+on the environment in which the Perl program is running.
+
+You shouldn't use C<exit()> to abort a subroutine if there's any chance that
+someone might want to trap whatever error happened. Use C<die()> instead,
+which can be trapped by an C<eval()>.
+
+All C<END{}> blocks are run at exit time. See L<perlsub> for details.
+
+=item exp EXPR
+
+=item exp
+
+Returns I<e> (the natural logarithm base) to the power of EXPR.
+If EXPR is omitted, gives C<exp($_)>.
+
+=item fcntl FILEHANDLE,FUNCTION,SCALAR
+
+Implements the fcntl(2) function. You'll probably have to say
+
+ use Fcntl;
+
+first to get the correct constant definitions. Argument processing and
+value return works just like C<ioctl()> below.
+For example:
+
+ use Fcntl;
+ fcntl($filehandle, F_GETFL, $packed_return_buffer)
+ or die "can't fcntl F_GETFL: $!";
+
+You don't have to check for C<defined()> on the return from
+C<fnctl()>. Like C<ioctl()>, it maps a C<0> return from the system
+call into "C<0> but true" in Perl. This string is true in
+boolean context and C<0> in numeric context. It is also
+exempt from the normal B<-w> warnings on improper numeric
+conversions.
+
+Note that C<fcntl()> will produce a fatal error if used on a machine that
+doesn't implement fcntl(2).
+
+=item fileno FILEHANDLE
+
+Returns the file descriptor for a filehandle. This is useful for
+constructing bitmaps for C<select()> and low-level POSIX tty-handling
+operations. If FILEHANDLE is an expression, the value is taken as
+an indirect filehandle, generally its name.
+
+You can use this to find out whether two handles refer to the
+same underlying descriptor:
+
+ if (fileno(THIS) == fileno(THAT)) {
+ print "THIS and THAT are dups\n";
+ }
+
+=item flock FILEHANDLE,OPERATION
+
+Calls flock(2), or an emulation of it, on FILEHANDLE. Returns TRUE for
+success, FALSE on failure. Produces a fatal error if used on a machine
+that doesn't implement flock(2), fcntl(2) locking, or lockf(3). C<flock()>
+is Perl's portable file locking interface, although it locks only entire
+files, not records.
+
+On many platforms (including most versions or clones of Unix), locks
+established by C<flock()> are B<merely advisory>. Such discretionary locks
+are more flexible, but offer fewer guarantees. This means that files
+locked with C<flock()> may be modified by programs that do not also use
+C<flock()>. Windows NT and OS/2 are among the platforms which
+enforce mandatory locking. See your local documentation for details.
+
+OPERATION is one of LOCK_SH, LOCK_EX, or LOCK_UN, possibly combined with
+LOCK_NB. These constants are traditionally valued 1, 2, 8 and 4, but
+you can use the symbolic names if import them from the Fcntl module,
+either individually, or as a group using the ':flock' tag. LOCK_SH
+requests a shared lock, LOCK_EX requests an exclusive lock, and LOCK_UN
+releases a previously requested lock. If LOCK_NB is added to LOCK_SH or
+LOCK_EX then C<flock()> will return immediately rather than blocking
+waiting for the lock (check the return status to see if you got it).
+
+To avoid the possibility of mis-coordination, Perl flushes FILEHANDLE
+before (un)locking it.
+
+Note that the emulation built with lockf(3) doesn't provide shared
+locks, and it requires that FILEHANDLE be open with write intent. These
+are the semantics that lockf(3) implements. Most (all?) systems
+implement lockf(3) in terms of fcntl(2) locking, though, so the
+differing semantics shouldn't bite too many people.
+
+Note also that some versions of C<flock()> cannot lock things over the
+network; you would need to use the more system-specific C<fcntl()> for
+that. If you like you can force Perl to ignore your system's flock(2)
+function, and so provide its own fcntl(2)-based emulation, by passing
+the switch C<-Ud_flock> to the F<Configure> program when you configure
+perl.
+
+Here's a mailbox appender for BSD systems.
+
+ use Fcntl ':flock'; # import LOCK_* constants
+
+ sub lock {
+ flock(MBOX,LOCK_EX);
+ # and, in case someone appended
+ # while we were waiting...
+ seek(MBOX, 0, 2);
+ }
+
+ sub unlock {
+ flock(MBOX,LOCK_UN);
+ }
+
+ open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}")
+ or die "Can't open mailbox: $!";
+
+ lock();
+ print MBOX $msg,"\n\n";
+ unlock();
+
+See also L<DB_File> for other flock() examples.
+
+=item fork
+
+Does a fork(2) system call. Returns the child pid to the parent process,
+C<0> to the child process, or C<undef> if the fork is unsuccessful.
+
+Note: unflushed buffers remain unflushed in both processes, which means
+you may need to set C<$|> ($AUTOFLUSH in English) or call the C<autoflush()>
+method of C<IO::Handle> to avoid duplicate output.
+
+If you C<fork()> without ever waiting on your children, you will accumulate
+zombies:
+
+ $SIG{CHLD} = sub { wait };
+
+There's also the double-fork trick (error checking on
+C<fork()> returns omitted);
+
+ unless ($pid = fork) {
+ unless (fork) {
+ exec "what you really wanna do";
+ die "no exec";
+ # ... or ...
+ ## (some_perl_code_here)
+ exit 0;
+ }
+ exit 0;
+ }
+ waitpid($pid,0);
+
+See also L<perlipc> for more examples of forking and reaping
+moribund children.
+
+Note that if your forked child inherits system file descriptors like
+STDIN and STDOUT that are actually connected by a pipe or socket, even
+if you exit, then the remote server (such as, say, httpd or rsh) won't think
+you're done. You should reopen those to F</dev/null> if it's any issue.
+
+=item format
+
+Declare a picture format for use by the C<write()> function. For
+example:
+
+ format Something =
+ Test: @<<<<<<<< @||||| @>>>>>
+ $str, $%, '$' . int($num)
+ .
+
+ $str = "widget";
+ $num = $cost/$quantity;
+ $~ = 'Something';
+ write;
+
+See L<perlform> for many details and examples.
+
+=item formline PICTURE,LIST
+
+This is an internal function used by C<format>s, though you may call it,
+too. It formats (see L<perlform>) a list of values according to the
+contents of PICTURE, placing the output into the format output
+accumulator, C<$^A> (or C<$ACCUMULATOR> in English).
+Eventually, when a C<write()> is done, the contents of
+C<$^A> are written to some filehandle, but you could also read C<$^A>
+yourself and then set C<$^A> back to C<"">. Note that a format typically
+does one C<formline()> per line of form, but the C<formline()> function itself
+doesn't care how many newlines are embedded in the PICTURE. This means
+that the C<~> and C<~~> tokens will treat the entire PICTURE as a single line.
+You may therefore need to use multiple formlines to implement a single
+record format, just like the format compiler.
+
+Be careful if you put double quotes around the picture, because an "C<@>"
+character may be taken to mean the beginning of an array name.
+C<formline()> always returns TRUE. See L<perlform> for other examples.
+
+=item getc FILEHANDLE
+
+=item getc
+
+Returns the next character from the input file attached to FILEHANDLE,
+or the undefined value at end of file, or if there was an error. If
+FILEHANDLE is omitted, reads from STDIN. This is not particularly
+efficient. It cannot be used to get unbuffered single-characters,
+however. For that, try something more like:
+
+ if ($BSD_STYLE) {
+ system "stty cbreak </dev/tty >/dev/tty 2>&1";
+ }
+ else {
+ system "stty", '-icanon', 'eol', "\001";
+ }
+
+ $key = getc(STDIN);
+
+ if ($BSD_STYLE) {
+ system "stty -cbreak </dev/tty >/dev/tty 2>&1";
+ }
+ else {
+ system "stty", 'icanon', 'eol', '^@'; # ASCII null
+ }
+ print "\n";
+
+Determination of whether $BSD_STYLE should be set
+is left as an exercise to the reader.
+
+The C<POSIX::getattr()> function can do this more portably on systems
+purporting POSIX compliance.
+See also the C<Term::ReadKey> module from your nearest CPAN site;
+details on CPAN can be found on L<perlmod/CPAN>.
+
+=item getlogin
+
+Implements the C library function of the same name, which on most
+systems returns the current login from F</etc/utmp>, if any. If null,
+use C<getpwuid()>.
+
+ $login = getlogin || getpwuid($<) || "Kilroy";
+
+Do not consider C<getlogin()> for authentication: it is not as
+secure as C<getpwuid()>.
+
+=item getpeername SOCKET
+
+Returns the packed sockaddr address of other end of the SOCKET connection.
+
+ use Socket;
+ $hersockaddr = getpeername(SOCK);
+ ($port, $iaddr) = unpack_sockaddr_in($hersockaddr);
+ $herhostname = gethostbyaddr($iaddr, AF_INET);
+ $herstraddr = inet_ntoa($iaddr);
+
+=item getpgrp PID
+
+Returns the current process group for the specified PID. Use
+a PID of C<0> to get the current process group for the
+current process. Will raise an exception if used on a machine that
+doesn't implement getpgrp(2). If PID is omitted, returns process
+group of current process. Note that the POSIX version of C<getpgrp()>
+does not accept a PID argument, so only C<PID==0> is truly portable.
+
+=item getppid
+
+Returns the process id of the parent process.
+
+=item getpriority WHICH,WHO
+
+Returns the current priority for a process, a process group, or a user.
+(See L<getpriority(2)>.) Will raise a fatal exception if used on a
+machine that doesn't implement getpriority(2).
+
+=item getpwnam NAME
+
+=item getgrnam NAME
+
+=item gethostbyname NAME
+
+=item getnetbyname NAME
+
+=item getprotobyname NAME
+
+=item getpwuid UID
+
+=item getgrgid GID
+
+=item getservbyname NAME,PROTO
+
+=item gethostbyaddr ADDR,ADDRTYPE
+
+=item getnetbyaddr ADDR,ADDRTYPE
+
+=item getprotobynumber NUMBER
+
+=item getservbyport PORT,PROTO
+
+=item getpwent
+
+=item getgrent
+
+=item gethostent
+
+=item getnetent
+
+=item getprotoent
+
+=item getservent
+
+=item setpwent
+
+=item setgrent
+
+=item sethostent STAYOPEN
+
+=item setnetent STAYOPEN
+
+=item setprotoent STAYOPEN
+
+=item setservent STAYOPEN
+
+=item endpwent
+
+=item endgrent
+
+=item endhostent
+
+=item endnetent
+
+=item endprotoent
+
+=item endservent
+
+These routines perform the same functions as their counterparts in the
+system library. In list context, the return values from the
+various get routines are as follows:
+
+ ($name,$passwd,$uid,$gid,
+ $quota,$comment,$gcos,$dir,$shell,$expire) = getpw*
+ ($name,$passwd,$gid,$members) = getgr*
+ ($name,$aliases,$addrtype,$length,@addrs) = gethost*
+ ($name,$aliases,$addrtype,$net) = getnet*
+ ($name,$aliases,$proto) = getproto*
+ ($name,$aliases,$port,$proto) = getserv*
+
+(If the entry doesn't exist you get a null list.)
+
+In scalar context, you get the name, unless the function was a
+lookup by name, in which case you get the other thing, whatever it is.
+(If the entry doesn't exist you get the undefined value.) For example:
+
+ $uid = getpwnam($name);
+ $name = getpwuid($num);
+ $name = getpwent();
+ $gid = getgrnam($name);
+ $name = getgrgid($num;
+ $name = getgrent();
+ #etc.
+
+In I<getpw*()> the fields C<$quota>, C<$comment>, and C<$expire> are special
+cases in the sense that in many systems they are unsupported. If the
+C<$quota> is unsupported, it is an empty scalar. If it is supported, it
+usually encodes the disk quota. If the C<$comment> field is unsupported,
+it is an empty scalar. If it is supported it usually encodes some
+administrative comment about the user. In some systems the $quota
+field may be C<$change> or C<$age>, fields that have to do with password
+aging. In some systems the C<$comment> field may be C<$class>. The C<$expire>
+field, if present, encodes the expiration period of the account or the
+password. For the availability and the exact meaning of these fields
+in your system, please consult your getpwnam(3) documentation and your
+F<pwd.h> file. You can also find out from within Perl which meaning
+your C<$quota> and C<$comment> fields have and whether you have the C<$expire>
+field by using the C<Config> module and the values C<d_pwquota>, C<d_pwage>,
+C<d_pwchange>, C<d_pwcomment>, and C<d_pwexpire>.
+
+The C<$members> value returned by I<getgr*()> is a space separated list of
+the login names of the members of the group.
+
+For the I<gethost*()> functions, if the C<h_errno> variable is supported in
+C, it will be returned to you via C<$?> if the function call fails. The
+C<@addrs> value returned by a successful call is a list of the raw
+addresses returned by the corresponding system library call. In the
+Internet domain, each address is four bytes long and you can unpack it
+by saying something like:
+
+ ($a,$b,$c,$d) = unpack('C4',$addr[0]);
+
+If you get tired of remembering which element of the return list contains
+which return value, by-name interfaces are also provided in modules:
+C<File::stat>, C<Net::hostent>, C<Net::netent>, C<Net::protoent>, C<Net::servent>,
+C<Time::gmtime>, C<Time::localtime>, and C<User::grent>. These override the
+normal built-in, replacing them with versions that return objects with
+the appropriate names for each field. For example:
+
+ use File::stat;
+ use User::pwent;
+ $is_his = (stat($filename)->uid == pwent($whoever)->uid);
+
+Even though it looks like they're the same method calls (uid),
+they aren't, because a C<File::stat> object is different from a C<User::pwent> object.
+
+=item getsockname SOCKET
+
+Returns the packed sockaddr address of this end of the SOCKET connection.
+
+ use Socket;
+ $mysockaddr = getsockname(SOCK);
+ ($port, $myaddr) = unpack_sockaddr_in($mysockaddr);
+
+=item getsockopt SOCKET,LEVEL,OPTNAME
+
+Returns the socket option requested, or undef if there is an error.
+
+=item glob EXPR
+
+=item glob
+
+Returns the value of EXPR with filename expansions such as the standard Unix shell F</bin/sh> would
+do. This is the internal function implementing the C<E<lt>*.cE<gt>>
+operator, but you can use it directly. If EXPR is omitted, C<$_> is used.
+The C<E<lt>*.cE<gt>> operator is discussed in more detail in
+L<perlop/"I/O Operators">.
+
+=item gmtime EXPR
+
+Converts a time as returned by the time function to a 9-element array
+with the time localized for the standard Greenwich time zone.
+Typically used as follows:
+
+ # 0 1 2 3 4 5 6 7 8
+ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+ gmtime(time);
+
+All array elements are numeric, and come straight out of a struct tm.
+In particular this means that C<$mon> has the range C<0..11> and C<$wday> has
+the range C<0..6> with sunday as day C<0>. Also, C<$year> is the number of
+years since 1900, that is, C<$year> is C<123> in year 2023, I<not> simply the last two digits of the year.
+
+If EXPR is omitted, does C<gmtime(time())>.
+
+In scalar context, returns the ctime(3) value:
+
+ $now_string = gmtime; # e.g., "Thu Oct 13 04:54:34 1994"
+
+Also see the C<timegm()> function provided by the C<Time::Local> module,
+and the strftime(3) function available via the POSIX module.
+
+This scalar value is B<not> locale dependent, see L<perllocale>, but
+instead a Perl builtin. Also see the C<Time::Local> module, and the
+strftime(3) and mktime(3) function available via the POSIX module. To
+get somewhat similar but locale dependent date strings, set up your
+locale environment variables appropriately (please see L<perllocale>)
+and try for example:
+
+ use POSIX qw(strftime);
+ $now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;
+
+Note that the C<%a> and C<%b>, the short forms of the day of the week
+and the month of the year, may not necessarily be three characters wide.
+
+=item goto LABEL
+
+=item goto EXPR
+
+=item goto &NAME
+
+The C<goto-LABEL> form finds the statement labeled with LABEL and resumes
+execution there. It may not be used to go into any construct that
+requires initialization, such as a subroutine or a C<foreach> loop. It
+also can't be used to go into a construct that is optimized away,
+or to get out of a block or subroutine given to C<sort()>.
+It can be used to go almost anywhere else within the dynamic scope,
+including out of subroutines, but it's usually better to use some other
+construct such as C<last> or C<die()>. The author of Perl has never felt the
+need to use this form of C<goto> (in Perl, that is--C is another matter).
+
+The C<goto-EXPR> form expects a label name, whose scope will be resolved
+dynamically. This allows for computed C<goto>s per FORTRAN, but isn't
+necessarily recommended if you're optimizing for maintainability:
+
+ goto ("FOO", "BAR", "GLARCH")[$i];
+
+The C<goto-&NAME> form is highly magical, and substitutes a call to the
+named subroutine for the currently running subroutine. This is used by
+C<AUTOLOAD> subroutines that wish to load another subroutine and then
+pretend that the other subroutine had been called in the first place
+(except that any modifications to C<@_> in the current subroutine are
+propagated to the other subroutine.) After the C<goto>, not even C<caller()>
+will be able to tell that this routine was called first.
+
+=item grep BLOCK LIST
+
+=item grep EXPR,LIST
+
+This is similar in spirit to, but not the same as, grep(1)
+and its relatives. In particular, it is not limited to using
+regular expressions.
+
+Evaluates the BLOCK or EXPR for each element of LIST (locally setting
+C<$_> to each element) and returns the list value consisting of those
+elements for which the expression evaluated to TRUE. In a scalar
+context, returns the number of times the expression was TRUE.
+
+ @foo = grep(!/^#/, @bar); # weed out comments
+
+or equivalently,
+
+ @foo = grep {!/^#/} @bar; # weed out comments
+
+Note that, because C<$_> is a reference into the list value, it can be used
+to modify the elements of the array. While this is useful and
+supported, it can cause bizarre results if the LIST is not a named
+array. Similarly, grep returns aliases into the original list,
+much like the way that a for loop's index variable aliases the list
+elements. That is, modifying an element of a list returned by grep
+(for example, in a C<foreach>, C<map()> or another C<grep()>)
+actually modifies the element in the original list.
+
+See also L</map> for an array composed of the results of the BLOCK or EXPR.
+
+=item hex EXPR
+
+=item hex
+
+Interprets EXPR as a hex string and returns the corresponding
+value. (To convert strings that might start with either 0 or 0x
+see L</oct>.) If EXPR is omitted, uses C<$_>.
+
+ print hex '0xAf'; # prints '175'
+ print hex 'aF'; # same
+
+=item import
+
+There is no builtin C<import()> function. It is just an ordinary
+method (subroutine) defined (or inherited) by modules that wish to export
+names to another module. The C<use()> function calls the C<import()> method
+for the package used. See also L</use()>, L<perlmod>, and L<Exporter>.
+
+=item index STR,SUBSTR,POSITION
+
+=item index STR,SUBSTR
+
+Returns the position of the first occurrence of SUBSTR in STR at or after
+POSITION. If POSITION is omitted, starts searching from the beginning of
+the string. The return value is based at C<0> (or whatever you've set the C<$[>
+variable to--but don't do that). If the substring is not found, returns
+one less than the base, ordinarily C<-1>.
+
+=item int EXPR
+
+=item int
+
+Returns the integer portion of EXPR. If EXPR is omitted, uses C<$_>.
+You should not use this for rounding, because it truncates
+towards C<0>, and because machine representations of floating point
+numbers can sometimes produce counterintuitive results. Usually C<sprintf()> or C<printf()>,
+or the C<POSIX::floor> or C<POSIX::ceil> functions, would serve you better.
+
+=item ioctl FILEHANDLE,FUNCTION,SCALAR
+
+Implements the ioctl(2) function. You'll probably have to say
+
+ require "ioctl.ph"; # probably in /usr/local/lib/perl/ioctl.ph
+
+first to get the correct function definitions. If F<ioctl.ph> doesn't
+exist or doesn't have the correct definitions you'll have to roll your
+own, based on your C header files such as F<E<lt>sys/ioctl.hE<gt>>.
+(There is a Perl script called B<h2ph> that comes with the Perl kit that
+may help you in this, but it's nontrivial.) SCALAR will be read and/or
+written depending on the FUNCTION--a pointer to the string value of SCALAR
+will be passed as the third argument of the actual C<ioctl()> call. (If SCALAR
+has no string value but does have a numeric value, that value will be
+passed rather than a pointer to the string value. To guarantee this to be
+TRUE, add a C<0> to the scalar before using it.) The C<pack()> and C<unpack()>
+functions are useful for manipulating the values of structures used by
+C<ioctl()>. The following example sets the erase character to DEL.
+
+ require 'ioctl.ph';
+ $getp = &TIOCGETP;
+ die "NO TIOCGETP" if $@ || !$getp;
+ $sgttyb_t = "ccccs"; # 4 chars and a short
+ if (ioctl(STDIN,$getp,$sgttyb)) {
+ @ary = unpack($sgttyb_t,$sgttyb);
+ $ary[2] = 127;
+ $sgttyb = pack($sgttyb_t,@ary);
+ ioctl(STDIN,&TIOCSETP,$sgttyb)
+ || die "Can't ioctl: $!";
+ }
+
+The return value of C<ioctl()> (and C<fcntl()>) is as follows:
+
+ if OS returns: then Perl returns:
+ -1 undefined value
+ 0 string "0 but true"
+ anything else that number
+
+Thus Perl returns TRUE on success and FALSE on failure, yet you can
+still easily determine the actual value returned by the operating
+system:
+
+ ($retval = ioctl(...)) || ($retval = -1);
+ printf "System returned %d\n", $retval;
+
+The special string "C<0> but true" is excempt from B<-w> complaints
+about improper numeric conversions.
+
+=item join EXPR,LIST
+
+Joins the separate strings of LIST into a single string with
+fields separated by the value of EXPR, and returns the string.
+Example:
+
+ $_ = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell);
+
+See L</split>.
+
+=item keys HASH
+
+Returns a list consisting of all the keys of the named hash. (In a
+scalar context, returns the number of keys.) The keys are returned in
+an apparently random order, but it is the same order as either the
+C<values()> or C<each()> function produces (given that the hash has not been
+modified). As a side effect, it resets HASH's iterator.
+
+Here is yet another way to print your environment:
+
+ @keys = keys %ENV;
+ @values = values %ENV;
+ while ($#keys >= 0) {
+ print pop(@keys), '=', pop(@values), "\n";
+ }
+
+or how about sorted by key:
+
+ foreach $key (sort(keys %ENV)) {
+ print $key, '=', $ENV{$key}, "\n";
+ }
+
+To sort an array by value, you'll need to use a C<sort()> function.
+Here's a descending numeric sort of a hash by its values:
+
+ foreach $key (sort { $hash{$b} <=> $hash{$a} } keys %hash) {
+ printf "%4d %s\n", $hash{$key}, $key;
+ }
+
+As an lvalue C<keys()> allows you to increase the number of hash buckets
+allocated for the given hash. This can gain you a measure of efficiency if
+you know the hash is going to get big. (This is similar to pre-extending
+an array by assigning a larger number to $#array.) If you say
+
+ keys %hash = 200;
+
+then C<%hash> will have at least 200 buckets allocated for it--256 of them, in fact, since
+it rounds up to the next power of two. These
+buckets will be retained even if you do C<%hash = ()>, use C<undef
+%hash> if you want to free the storage while C<%hash> is still in scope.
+You can't shrink the number of buckets allocated for the hash using
+C<keys()> in this way (but you needn't worry about doing this by accident,
+as trying has no effect).
+
+=item kill LIST
+
+Sends a signal to a list of processes. The first element of
+the list must be the signal to send. Returns the number of
+processes successfully signaled.
+
+ $cnt = kill 1, $child1, $child2;
+ kill 9, @goners;
+
+Unlike in the shell, in Perl if the I<SIGNAL> is negative, it kills
+process groups instead of processes. (On System V, a negative I<PROCESS>
+number will also kill process groups, but that's not portable.) That
+means you usually want to use positive not negative signals. You may also
+use a signal name in quotes. See L<perlipc/"Signals"> for details.
+
+=item last LABEL
+
+=item last
+
+The C<last> command is like the C<break> statement in C (as used in
+loops); it immediately exits the loop in question. If the LABEL is
+omitted, the command refers to the innermost enclosing loop. The
+C<continue> block, if any, is not executed:
+
+ LINE: while (<STDIN>) {
+ last LINE if /^$/; # exit when done with header
+ #...
+ }
+
+See also L</continue> for an illustration of how C<last>, C<next>, and
+C<redo> work.
+
+=item lc EXPR
+
+=item lc
+
+Returns an lowercased version of EXPR. This is the internal function
+implementing the C<\L> escape in double-quoted strings.
+Respects current C<LC_CTYPE> locale if C<use locale> in force. See L<perllocale>.
+
+If EXPR is omitted, uses C<$_>.
+
+=item lcfirst EXPR
+
+=item lcfirst
+
+Returns the value of EXPR with the first character lowercased. This is
+the internal function implementing the C<\l> escape in double-quoted strings.
+Respects current C<LC_CTYPE> locale if C<use locale> in force. See L<perllocale>.
+
+If EXPR is omitted, uses C<$_>.
+
+=item length EXPR
+
+=item length
+
+Returns the length in bytes of the value of EXPR. If EXPR is
+omitted, returns length of C<$_>.
+
+=item link OLDFILE,NEWFILE
+
+Creates a new filename linked to the old filename. Returns TRUE for
+success, FALSE otherwise.
+
+=item listen SOCKET,QUEUESIZE
+
+Does the same thing that the listen system call does. Returns TRUE if
+it succeeded, FALSE otherwise. See example in L<perlipc/"Sockets: Client/Server Communication">.
+
+=item local EXPR
+
+A local modifies the listed variables to be local to the enclosing
+block, file, or eval. If more than one value is listed, the list must
+be placed in parentheses. See L<perlsub/"Temporary Values via local()">
+for details, including issues with tied arrays and hashes.
+
+You really probably want to be using C<my()> instead, because C<local()> isn't
+what most people think of as "local". See L<perlsub/"Private Variables
+via my()"> for details.
+
+=item localtime EXPR
+
+Converts a time as returned by the time function to a 9-element array
+with the time analyzed for the local time zone. Typically used as
+follows:
+
+ # 0 1 2 3 4 5 6 7 8
+ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+ localtime(time);
+
+All array elements are numeric, and come straight out of a struct tm.
+In particular this means that C<$mon> has the range C<0..11> and C<$wday> has
+the range C<0..6> with sunday as day C<0>. Also, C<$year> is the number of
+years since 1900, that is, C<$year> is C<123> in year 2023, and I<not> simply the last two digits of the year.
+
+If EXPR is omitted, uses the current time (C<localtime(time)>).
+
+In scalar context, returns the ctime(3) value:
+
+ $now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994"
+
+This scalar value is B<not> locale dependent, see L<perllocale>, but
+instead a Perl builtin. Also see the C<Time::Local> module, and the
+strftime(3) and mktime(3) function available via the POSIX module. To
+get somewhat similar but locale dependent date strings, set up your
+locale environment variables appropriately (please see L<perllocale>)
+and try for example:
+
+ use POSIX qw(strftime);
+ $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
+
+Note that the C<%a> and C<%b>, the short forms of the day of the week
+and the month of the year, may not necessarily be three characters wide.
+
+=item log EXPR
+
+=item log
+
+Returns the natural logarithm (base I<e>) of EXPR. If EXPR is omitted, returns log
+of C<$_>.
+
+=item lstat FILEHANDLE
+
+=item lstat EXPR
+
+=item lstat
+
+Does the same thing as the C<stat()> function (including setting the
+special C<_> filehandle) but stats a symbolic link instead of the file
+the symbolic link points to. If symbolic links are unimplemented on
+your system, a normal C<stat()> is done.
+
+If EXPR is omitted, stats C<$_>.
+
+=item m//
+
+The match operator. See L<perlop>.
+
+=item map BLOCK LIST
+
+=item map EXPR,LIST
+
+Evaluates the BLOCK or EXPR for each element of LIST (locally setting C<$_> to each
+element) and returns the list value composed of the results of each such
+evaluation. Evaluates BLOCK or EXPR in a list context, so each element of LIST
+may produce zero, one, or more elements in the returned value.
+
+ @chars = map(chr, @nums);
+
+translates a list of numbers to the corresponding characters. And
+
+ %hash = map { getkey($_) => $_ } @array;
+
+is just a funny way to write
+
+ %hash = ();
+ foreach $_ (@array) {
+ $hash{getkey($_)} = $_;
+ }
+
+Note that, because C<$_> is a reference into the list value, it can be used
+to modify the elements of the array. While this is useful and
+supported, it can cause bizarre results if the LIST is not a named
+array. See also L</grep> for an array composed of those items of the
+original list for which the BLOCK or EXPR evaluates to true.
+
+=item mkdir FILENAME,MODE
+
+Creates the directory specified by FILENAME, with permissions specified
+by MODE (as modified by umask). If it succeeds it returns TRUE, otherwise
+it returns FALSE and sets C<$!> (errno).
+
+=item msgctl ID,CMD,ARG
+
+Calls the System V IPC function msgctl(2). You'll probably have to say
+
+ use IPC::SysV;
+
+first to get the correct constant definitions. If CMD is C<IPC_STAT>,
+then ARG must be a variable which will hold the returned C<msqid_ds>
+structure. Returns like C<ioctl()>: the undefined value for error, "C<0> but
+true" for zero, or the actual return value otherwise. See also
+C<IPC::SysV> and C<IPC::Semaphore::Msg> documentation.
+
+=item msgget KEY,FLAGS
+
+Calls the System V IPC function msgget(2). Returns the message queue
+id, or the undefined value if there is an error. See also C<IPC::SysV>
+and C<IPC::SysV::Msg> documentation.
+
+=item msgsnd ID,MSG,FLAGS
+
+Calls the System V IPC function msgsnd to send the message MSG to the
+message queue ID. MSG must begin with the long integer message type,
+which may be created with C<pack("l", $type)>. Returns TRUE if
+successful, or FALSE if there is an error. See also C<IPC::SysV>
+and C<IPC::SysV::Msg> documentation.
+
+=item msgrcv ID,VAR,SIZE,TYPE,FLAGS
+
+Calls the System V IPC function msgrcv to receive a message from
+message queue ID into variable VAR with a maximum message size of
+SIZE. Note that if a message is received, the message type will be
+the first thing in VAR, and the maximum length of VAR is SIZE plus the
+size of the message type. Returns TRUE if successful, or FALSE if
+there is an error. See also C<IPC::SysV> and C<IPC::SysV::Msg> documentation.
+
+=item my EXPR
+
+A C<my()> declares the listed variables to be local (lexically) to the
+enclosing block, file, or C<eval()>. If
+more than one value is listed, the list must be placed in parentheses. See
+L<perlsub/"Private Variables via my()"> for details.
+
+=item next LABEL
+
+=item next
+
+The C<next> command is like the C<continue> statement in C; it starts
+the next iteration of the loop:
+
+ LINE: while (<STDIN>) {
+ next LINE if /^#/; # discard comments
+ #...
+ }
+
+Note that if there were a C<continue> block on the above, it would get
+executed even on discarded lines. If the LABEL is omitted, the command
+refers to the innermost enclosing loop.
+
+See also L</continue> for an illustration of how C<last>, C<next>, and
+C<redo> work.
+
+=item no Module LIST
+
+See the L</use> function, which C<no> is the opposite of.
+
+=item oct EXPR
+
+=item oct
+
+Interprets EXPR as an octal string and returns the corresponding
+value. (If EXPR happens to start off with C<0x>, interprets it as
+a hex string instead.) The following will handle decimal, octal, and
+hex in the standard Perl or C notation:
+
+ $val = oct($val) if $val =~ /^0/;
+
+If EXPR is omitted, uses C<$_>. This function is commonly used when
+a string such as C<644> needs to be converted into a file mode, for
+example. (Although perl will automatically convert strings into
+numbers as needed, this automatic conversion assumes base 10.)
+
+=item open FILEHANDLE,EXPR
+
+=item open FILEHANDLE
+
+Opens the file whose filename is given by EXPR, and associates it with
+FILEHANDLE. If FILEHANDLE is an expression, its value is used as the
+name of the real filehandle wanted. If EXPR is omitted, the scalar
+variable of the same name as the FILEHANDLE contains the filename.
+(Note that lexical variables--those declared with C<my()>--will not work
+for this purpose; so if you're using C<my()>, specify EXPR in your call
+to open.)
+
+If the filename begins with C<'E<lt>'> or nothing, the file is opened for input.
+If the filename begins with C<'E<gt>'>, the file is truncated and opened for
+output, being created if necessary. If the filename begins with C<'E<gt>E<gt>'>,
+the file is opened for appending, again being created if necessary.
+You can put a C<'+'> in front of the C<'E<gt>'> or C<'E<lt>'> to indicate that
+you want both read and write access to the file; thus C<'+E<lt>'> is almost
+always preferred for read/write updates--the C<'+E<gt>'> mode would clobber the
+file first. You can't usually use either read-write mode for updating
+textfiles, since they have variable length records. See the B<-i>
+switch in L<perlrun> for a better approach.
+
+The prefix and the filename may be separated with spaces.
+These various prefixes correspond to the fopen(3) modes of C<'r'>, C<'r+'>, C<'w'>,
+C<'w+'>, C<'a'>, and C<'a+'>.
+
+If the filename begins with C<'|'>, the filename is interpreted as a
+command to which output is to be piped, and if the filename ends with a
+C<'|'>, the filename is interpreted See L<perlipc/"Using open() for IPC">
+for more examples of this. (You are not allowed to C<open()> to a command
+that pipes both in I<and> out, but see L<IPC::Open2>, L<IPC::Open3>,
+and L<perlipc/"Bidirectional Communication"> for alternatives.)
+
+Opening C<'-'> opens STDIN and opening C<'E<gt>-'> opens STDOUT. Open returns
+nonzero upon success, the undefined value otherwise. If the C<open()>
+involved a pipe, the return value happens to be the pid of the
+subprocess.
+
+If you're unfortunate enough to be running Perl on a system that
+distinguishes between text files and binary files (modern operating
+systems don't care), then you should check out L</binmode> for tips for
+dealing with this. The key distinction between systems that need C<binmode()>
+and those that don't is their text file formats. Systems like Unix, MacOS, and
+Plan9, which delimit lines with a single character, and which encode that
+character in C as C<"\n">, do not need C<binmode()>. The rest need it.
+
+When opening a file, it's usually a bad idea to continue normal execution
+if the request failed, so C<open()> is frequently used in connection with
+C<die()>. Even if C<die()> won't do what you want (say, in a CGI script,
+where you want to make a nicely formatted error message (but there are
+modules that can help with that problem)) you should always check
+the return value from opening a file. The infrequent exception is when
+working with an unopened filehandle is actually what you want to do.
+
+Examples:
+
+ $ARTICLE = 100;
+ open ARTICLE or die "Can't find article $ARTICLE: $!\n";
+ while (<ARTICLE>) {...
+
+ open(LOG, '>>/usr/spool/news/twitlog'); # (log is reserved)
+ # if the open fails, output is discarded
+
+ open(DBASE, '+<dbase.mine') # open for update
+ or die "Can't open 'dbase.mine' for update: $!";
+
+ open(ARTICLE, "caesar <$article |") # decrypt article
+ or die "Can't start caesar: $!";
+
+ open(EXTRACT, "|sort >/tmp/Tmp$$") # $$ is our process id
+ or die "Can't start sort: $!";
+
+ # process argument list of files along with any includes
+
+ foreach $file (@ARGV) {
+ process($file, 'fh00');
+ }
+
+ sub process {
+ my($filename, $input) = @_;
+ $input++; # this is a string increment
+ unless (open($input, $filename)) {
+ print STDERR "Can't open $filename: $!\n";
+ return;
+ }
+
+ local $_;
+ while (<$input>) { # note use of indirection
+ if (/^#include "(.*)"/) {
+ process($1, $input);
+ next;
+ }
+ #... # whatever
+ }
+ }
+
+You may also, in the Bourne shell tradition, specify an EXPR beginning
+with C<'E<gt>&'>, in which case the rest of the string is interpreted as the
+name of a filehandle (or file descriptor, if numeric) to be
+duped and opened. You may use C<&> after C<E<gt>>, C<E<gt>E<gt>>, C<E<lt>>, C<+E<gt>>,
+C<+E<gt>E<gt>>, and C<+E<lt>>. The
+mode you specify should match the mode of the original filehandle.
+(Duping a filehandle does not take into account any existing contents of
+stdio buffers.)
+Here is a script that saves, redirects, and restores STDOUT and
+STDERR:
+
+ #!/usr/bin/perl
+ open(OLDOUT, ">&STDOUT");
+ open(OLDERR, ">&STDERR");
+
+ open(STDOUT, ">foo.out") || die "Can't redirect stdout";
+ open(STDERR, ">&STDOUT") || die "Can't dup stdout";
+
+ select(STDERR); $| = 1; # make unbuffered
+ select(STDOUT); $| = 1; # make unbuffered
+
+ print STDOUT "stdout 1\n"; # this works for
+ print STDERR "stderr 1\n"; # subprocesses too
+
+ close(STDOUT);
+ close(STDERR);
+
+ open(STDOUT, ">&OLDOUT");
+ open(STDERR, ">&OLDERR");
+
+ print STDOUT "stdout 2\n";
+ print STDERR "stderr 2\n";
+
+
+If you specify C<'E<lt>&=N'>, where C<N> is a number, then Perl will do an
+equivalent of C's C<fdopen()> of that file descriptor; this is more
+parsimonious of file descriptors. For example:
+
+ open(FILEHANDLE, "<&=$fd")
+
+If you open a pipe on the command C<'-'>, i.e., either C<'|-'> or C<'-|'>, then
+there is an implicit fork done, and the return value of open is the pid
+of the child within the parent process, and C<0> within the child
+process. (Use C<defined($pid)> to determine whether the open was successful.)
+The filehandle behaves normally for the parent, but i/o to that
+filehandle is piped from/to the STDOUT/STDIN of the child process.
+In the child process the filehandle isn't opened--i/o happens from/to
+the new STDOUT or STDIN. Typically this is used like the normal
+piped open when you want to exercise more control over just how the
+pipe command gets executed, such as when you are running setuid, and
+don't want to have to scan shell commands for metacharacters.
+The following pairs are more or less equivalent:
+
+ open(FOO, "|tr '[a-z]' '[A-Z]'");
+ open(FOO, "|-") || exec 'tr', '[a-z]', '[A-Z]';
+
+ open(FOO, "cat -n '$file'|");
+ open(FOO, "-|") || exec 'cat', '-n', $file;
+
+See L<perlipc/"Safe Pipe Opens"> for more examples of this.
+
+NOTE: On any operation that may do a fork, any unflushed buffers remain
+unflushed in both processes, which means you may need to set C<$|> to
+avoid duplicate output.
+
+Closing any piped filehandle causes the parent process to wait for the
+child to finish, and returns the status value in C<$?>.
+
+The filename passed to open will have leading and trailing
+whitespace deleted, and the normal redirection characters
+honored. This property, known as "magic open",
+can often be used to good effect. A user could specify a filename of
+F<"rsh cat file |">, or you could change certain filenames as needed:
+
+ $filename =~ s/(.*\.gz)\s*$/gzip -dc < $1|/;
+ open(FH, $filename) or die "Can't open $filename: $!";
+
+However, to open a file with arbitrary weird characters in it, it's
+necessary to protect any leading and trailing whitespace:
+
+ $file =~ s#^(\s)#./$1#;
+ open(FOO, "< $file\0");
+
+If you want a "real" C C<open()> (see L<open(2)> on your system), then you
+should use the C<sysopen()> function, which involves no such magic. This is
+another way to protect your filenames from interpretation. For example:
+
+ use IO::Handle;
+ sysopen(HANDLE, $path, O_RDWR|O_CREAT|O_EXCL)
+ or die "sysopen $path: $!";
+ $oldfh = select(HANDLE); $| = 1; select($oldfh);
+ print HANDLE "stuff $$\n");
+ seek(HANDLE, 0, 0);
+ print "File contains: ", <HANDLE>;
+
+Using the constructor from the C<IO::Handle> package (or one of its
+subclasses, such as C<IO::File> or C<IO::Socket>), you can generate anonymous
+filehandles that have the scope of whatever variables hold references to
+them, and automatically close whenever and however you leave that scope:
+
+ use IO::File;
+ #...
+ sub read_myfile_munged {
+ my $ALL = shift;
+ my $handle = new IO::File;
+ open($handle, "myfile") or die "myfile: $!";
+ $first = <$handle>
+ or return (); # Automatically closed here.
+ mung $first or die "mung failed"; # Or here.
+ return $first, <$handle> if $ALL; # Or here.
+ $first; # Or here.
+ }
+
+See L</seek()> for some details about mixing reading and writing.
+
+=item opendir DIRHANDLE,EXPR
+
+Opens a directory named EXPR for processing by C<readdir()>, C<telldir()>,
+C<seekdir()>, C<rewinddir()>, and C<closedir()>. Returns TRUE if successful.
+DIRHANDLEs have their own namespace separate from FILEHANDLEs.
+
+=item ord EXPR
+
+=item ord
+
+Returns the numeric ascii value of the first character of EXPR. If
+EXPR is omitted, uses C<$_>. For the reverse, see L</chr>.
+
+=item pack TEMPLATE,LIST
+
+Takes an array or list of values and packs it into a binary structure,
+returning the string containing the structure. The TEMPLATE is a
+sequence of characters that give the order and type of values, as
+follows:
+
+ A An ascii string, will be space padded.
+ a An ascii string, will be null padded.
+ b A bit string (ascending bit order, like vec()).
+ B A bit string (descending bit order).
+ h A hex string (low nybble first).
+ H A hex string (high nybble first).
+
+ c A signed char value.
+ C An unsigned char value.
+
+ s A signed short value.
+ S An unsigned short value.
+ (This 'short' is _exactly_ 16 bits, which may differ from
+ what a local C compiler calls 'short'.)
+
+ i A signed integer value.
+ I An unsigned integer value.
+ (This 'integer' is _at_least_ 32 bits wide. Its exact
+ size depends on what a local C compiler calls 'int',
+ and may even be larger than the 'long' described in
+ the next item.)
+
+ l A signed long value.
+ L An unsigned long value.
+ (This 'long' is _exactly_ 32 bits, which may differ from
+ what a local C compiler calls 'long'.)
+
+ n A short in "network" (big-endian) order.
+ N A long in "network" (big-endian) order.
+ v A short in "VAX" (little-endian) order.
+ V A long in "VAX" (little-endian) order.
+ (These 'shorts' and 'longs' are _exactly_ 16 bits and
+ _exactly_ 32 bits, respectively.)
+
+ f A single-precision float in the native format.
+ d A double-precision float in the native format.
+
+ p A pointer to a null-terminated string.
+ P A pointer to a structure (fixed-length string).
+
+ u A uuencoded string.
+
+ w A BER compressed integer. Its bytes represent an unsigned
+ integer in base 128, most significant digit first, with as
+ few digits as possible. Bit eight (the high bit) is set
+ on each byte except the last.
+
+ x A null byte.
+ X Back up a byte.
+ @ Null fill to absolute position.
+
+Each letter may optionally be followed by a number giving a repeat
+count. With all types except C<"a">, C<"A">, C<"b">, C<"B">, C<"h">, C<"H">, and C<"P"> the
+pack function will gobble up that many values from the LIST. A C<*> for the
+repeat count means to use however many items are left. The C<"a"> and C<"A">
+types gobble just one value, but pack it as a string of length count,
+padding with nulls or spaces as necessary. (When unpacking, C<"A"> strips
+trailing spaces and nulls, but C<"a"> does not.) Likewise, the C<"b"> and C<"B">
+fields pack a string that many bits long. The C<"h"> and C<"H"> fields pack a
+string that many nybbles long. The C<"p"> type packs a pointer to a null-
+terminated string. You are responsible for ensuring the string is not a
+temporary value (which can potentially get deallocated before you get
+around to using the packed result). The C<"P"> packs a pointer to a structure
+of the size indicated by the length. A NULL pointer is created if the
+corresponding value for C<"p"> or C<"P"> is C<undef>.
+Real numbers (floats and doubles) are
+in the native machine format only; due to the multiplicity of floating
+formats around, and the lack of a standard "network" representation, no
+facility for interchange has been made. This means that packed floating
+point data written on one machine may not be readable on another - even if
+both use IEEE floating point arithmetic (as the endian-ness of the memory
+representation is not part of the IEEE spec). Note that Perl uses doubles
+internally for all numeric calculation, and converting from double into
+float and thence back to double again will lose precision (i.e.,
+C<unpack("f", pack("f", $foo)>) will not in general equal C<$foo>).
+
+Examples:
+
+ $foo = pack("cccc",65,66,67,68);
+ # foo eq "ABCD"
+ $foo = pack("c4",65,66,67,68);
+ # same thing
+
+ $foo = pack("ccxxcc",65,66,67,68);
+ # foo eq "AB\0\0CD"
+
+ $foo = pack("s2",1,2);
+ # "\1\0\2\0" on little-endian
+ # "\0\1\0\2" on big-endian
+
+ $foo = pack("a4","abcd","x","y","z");
+ # "abcd"
+
+ $foo = pack("aaaa","abcd","x","y","z");
+ # "axyz"
+
+ $foo = pack("a14","abcdefg");
+ # "abcdefg\0\0\0\0\0\0\0"
+
+ $foo = pack("i9pl", gmtime);
+ # a real struct tm (on my system anyway)
+
+ sub bintodec {
+ unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
+ }
+
+The same template may generally also be used in the unpack function.
+
+=item package
+
+=item package NAMESPACE
+
+Declares the compilation unit as being in the given namespace. The scope
+of the package declaration is from the declaration itself through the end of
+the enclosing block (the same scope as the C<local()> operator). All further
+unqualified dynamic identifiers will be in this namespace. A package
+statement affects only dynamic variables--including those you've used
+C<local()> on--but I<not> lexical variables created with C<my()>. Typically it
+would be the first declaration in a file to be included by the C<require>
+or C<use> operator. You can switch into a package in more than one place;
+it merely influences which symbol table is used by the compiler for the
+rest of that block. You can refer to variables and filehandles in other
+packages by prefixing the identifier with the package name and a double
+colon: C<$Package::Variable>. If the package name is null, the C<main>
+package as assumed. That is, C<$::sail> is equivalent to C<$main::sail>.
+
+If NAMESPACE is omitted, then there is no current package, and all
+identifiers must be fully qualified or lexicals. This is stricter
+than C<use strict>, since it also extends to function names.
+
+See L<perlmod/"Packages"> for more information about packages, modules,
+and classes. See L<perlsub> for other scoping issues.
+
+=item pipe READHANDLE,WRITEHANDLE
+
+Opens a pair of connected pipes like the corresponding system call.
+Note that if you set up a loop of piped processes, deadlock can occur
+unless you are very careful. In addition, note that Perl's pipes use
+stdio buffering, so you may need to set C<$|> to flush your WRITEHANDLE
+after each command, depending on the application.
+
+See L<IPC::Open2>, L<IPC::Open3>, and L<perlipc/"Bidirectional Communication">
+for examples of such things.
+
+=item pop ARRAY
+
+=item pop
+
+Pops and returns the last value of the array, shortening the array by
+1. Has a similar effect to
+
+ $tmp = $ARRAY[$#ARRAY--];
+
+If there are no elements in the array, returns the undefined value.
+If ARRAY is omitted, pops the
+C<@ARGV> array in the main program, and the C<@_> array in subroutines, just
+like C<shift()>.
+
+=item pos SCALAR
+
+=item pos
+
+Returns the offset of where the last C<m//g> search left off for the variable
+is in question (C<$_> is used when the variable is not specified). May be
+modified to change that offset. Such modification will also influence
+the C<\G> zero-width assertion in regular expressions. See L<perlre> and
+L<perlop>.
+
+=item print FILEHANDLE LIST
+
+=item print LIST
+
+=item print
+
+Prints a string or a comma-separated list of strings. Returns TRUE
+if successful. FILEHANDLE may be a scalar variable name, in which case
+the variable contains the name of or a reference to the filehandle, thus introducing one
+level of indirection. (NOTE: If FILEHANDLE is a variable and the next
+token is a term, it may be misinterpreted as an operator unless you
+interpose a C<+> or put parentheses around the arguments.) If FILEHANDLE is
+omitted, prints by default to standard output (or to the last selected
+output channel--see L</select>). If LIST is also omitted, prints C<$_> to
+the currently selected output channel. To set the default output channel to something other than
+STDOUT use the select operation. Note that, because print takes a
+LIST, anything in the LIST is evaluated in list context, and any
+subroutine that you call will have one or more of its expressions
+evaluated in list context. Also be careful not to follow the print
+keyword with a left parenthesis unless you want the corresponding right
+parenthesis to terminate the arguments to the print--interpose a C<+> or
+put parentheses around all the arguments.
+
+Note that if you're storing FILEHANDLES in an array or other expression,
+you will have to use a block returning its value instead:
+
+ print { $files[$i] } "stuff\n";
+ print { $OK ? STDOUT : STDERR } "stuff\n";
+
+=item printf FILEHANDLE FORMAT, LIST
+
+=item printf FORMAT, LIST
+
+Equivalent to C<print FILEHANDLE sprintf(FORMAT, LIST)>, except that C<$\>
+(the output record separator) is not appended. The first argument
+of the list will be interpreted as the C<printf()> format. If C<use locale> is
+in effect, the character used for the decimal point in formatted real numbers
+is affected by the LC_NUMERIC locale. See L<perllocale>.
+
+Don't fall into the trap of using a C<printf()> when a simple
+C<print()> would do. The C<print()> is more efficient and less
+error prone.
+
+=item prototype FUNCTION
+
+Returns the prototype of a function as a string (or C<undef> if the
+function has no prototype). FUNCTION is a reference to, or the name of,
+the function whose prototype you want to retrieve.
+
+If FUNCTION is a string starting with C<CORE::>, the rest is taken as
+a name for Perl builtin. If builtin is not I<overridable> (such as
+C<qw//>) or its arguments cannot be expressed by a prototype (such as
+C<system()>) - in other words, the builtin does not behave like a Perl
+function - returns C<undef>. Otherwise, the string describing the
+equivalent prototype is returned.
+
+=item push ARRAY,LIST
+
+Treats ARRAY as a stack, and pushes the values of LIST
+onto the end of ARRAY. The length of ARRAY increases by the length of
+LIST. Has the same effect as
+
+ for $value (LIST) {
+ $ARRAY[++$#ARRAY] = $value;
+ }
+
+but is more efficient. Returns the new number of elements in the array.
+
+=item q/STRING/
+
+=item qq/STRING/
+
+=item qr/STRING/
+
+=item qx/STRING/
+
+=item qw/STRING/
+
+Generalized quotes. See L<perlop>.
+
+=item quotemeta EXPR
+
+=item quotemeta
+
+Returns the value of EXPR with all non-alphanumeric
+characters backslashed. (That is, all characters not matching
+C</[A-Za-z_0-9]/> will be preceded by a backslash in the
+returned string, regardless of any locale settings.)
+This is the internal function implementing
+the C<\Q> escape in double-quoted strings.
+
+If EXPR is omitted, uses C<$_>.
+
+=item rand EXPR
+
+=item rand
+
+Returns a random fractional number greater than or equal to C<0> and less
+than the value of EXPR. (EXPR should be positive.) If EXPR is
+omitted, the value C<1> is used. Automatically calls C<srand()> unless
+C<srand()> has already been called. See also C<srand()>.
+
+(Note: If your rand function consistently returns numbers that are too
+large or too small, then your version of Perl was probably compiled
+with the wrong number of RANDBITS.)
+
+=item read FILEHANDLE,SCALAR,LENGTH,OFFSET
+
+=item read FILEHANDLE,SCALAR,LENGTH
+
+Attempts to read LENGTH bytes of data into variable SCALAR from the
+specified FILEHANDLE. Returns the number of bytes actually read,
+C<0> at end of file, or undef if there was an error. SCALAR will be grown
+or shrunk to the length actually read. An OFFSET may be specified to
+place the read data at some other place than the beginning of the
+string. This call is actually implemented in terms of stdio's fread(3)
+call. To get a true read(2) system call, see C<sysread()>.
+
+=item readdir DIRHANDLE
+
+Returns the next directory entry for a directory opened by C<opendir()>.
+If used in list context, returns all the rest of the entries in the
+directory. If there are no more entries, returns an undefined value in
+scalar context or a null list in list context.
+
+If you're planning to filetest the return values out of a C<readdir()>, you'd
+better prepend the directory in question. Otherwise, because we didn't
+C<chdir()> there, it would have been testing the wrong file.
+
+ opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
+ @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
+ closedir DIR;
+
+=item readline EXPR
+
+Reads from the filehandle whose typeglob is contained in EXPR. In scalar context, a single line
+is read and returned. In list context, reads until end-of-file is
+reached and returns a list of lines (however you've defined lines
+with C<$/> or C<$INPUT_RECORD_SEPARATOR>).
+This is the internal function implementing the C<E<lt>EXPRE<gt>>
+operator, but you can use it directly. The C<E<lt>EXPRE<gt>>
+operator is discussed in more detail in L<perlop/"I/O Operators">.
+
+ $line = <STDIN>;
+ $line = readline(*STDIN); # same thing
+
+=item readlink EXPR
+
+=item readlink
+
+Returns the value of a symbolic link, if symbolic links are
+implemented. If not, gives a fatal error. If there is some system
+error, returns the undefined value and sets C<$!> (errno). If EXPR is
+omitted, uses C<$_>.
+
+=item readpipe EXPR
+
+EXPR is executed as a system command.
+The collected standard output of the command is returned.
+In scalar context, it comes back as a single (potentially
+multi-line) string. In list context, returns a list of lines
+(however you've defined lines with C<$/> or C<$INPUT_RECORD_SEPARATOR>).
+This is the internal function implementing the C<qx/EXPR/>
+operator, but you can use it directly. The C<qx/EXPR/>
+operator is discussed in more detail in L<perlop/"I/O Operators">.
+
+=item recv SOCKET,SCALAR,LEN,FLAGS
+
+Receives a message on a socket. Attempts to receive LENGTH bytes of
+data into variable SCALAR from the specified SOCKET filehandle.
+Actually does a C C<recvfrom()>, so that it can return the address of the
+sender. Returns the undefined value if there's an error. SCALAR will
+be grown or shrunk to the length actually read. Takes the same flags
+as the system call of the same name.
+See L<perlipc/"UDP: Message Passing"> for examples.
+
+=item redo LABEL
+
+=item redo
+
+The C<redo> command restarts the loop block without evaluating the
+conditional again. The C<continue> block, if any, is not executed. If
+the LABEL is omitted, the command refers to the innermost enclosing
+loop. This command is normally used by programs that want to lie to
+themselves about what was just input:
+
+ # a simpleminded Pascal comment stripper
+ # (warning: assumes no { or } in strings)
+ LINE: while (<STDIN>) {
+ while (s|({.*}.*){.*}|$1 |) {}
+ s|{.*}| |;
+ if (s|{.*| |) {
+ $front = $_;
+ while (<STDIN>) {
+ if (/}/) { # end of comment?
+ s|^|$front\{|;
+ redo LINE;
+ }
+ }
+ }
+ print;
+ }
+
+See also L</continue> for an illustration of how C<last>, C<next>, and
+C<redo> work.
+
+=item ref EXPR
+
+=item ref
+
+Returns a TRUE value if EXPR is a reference, FALSE otherwise. If EXPR
+is not specified, C<$_> will be used. The value returned depends on the
+type of thing the reference is a reference to.
+Builtin types include:
+
+ REF
+ SCALAR
+ ARRAY
+ HASH
+ CODE
+ GLOB
+
+If the referenced object has been blessed into a package, then that package
+name is returned instead. You can think of C<ref()> as a C<typeof()> operator.
+
+ if (ref($r) eq "HASH") {
+ print "r is a reference to a hash.\n";
+ }
+ if (!ref($r)) {
+ print "r is not a reference at all.\n";
+ }
+
+See also L<perlref>.
+
+=item rename OLDNAME,NEWNAME
+
+Changes the name of a file. Returns C<1> for success, C<0> otherwise. Will
+not work across file system boundaries.
+
+=item require EXPR
+
+=item require
+
+Demands some semantics specified by EXPR, or by C<$_> if EXPR is not
+supplied. If EXPR is numeric, demands that the current version of Perl
+(C<$]> or $PERL_VERSION) be equal or greater than EXPR.
+
+Otherwise, demands that a library file be included if it hasn't already
+been included. The file is included via the do-FILE mechanism, which is
+essentially just a variety of C<eval()>. Has semantics similar to the following
+subroutine:
+
+ sub require {
+ my($filename) = @_;
+ return 1 if $INC{$filename};
+ my($realfilename,$result);
+ ITER: {
+ foreach $prefix (@INC) {
+ $realfilename = "$prefix/$filename";
+ if (-f $realfilename) {
+ $result = do $realfilename;
+ last ITER;
+ }
+ }
+ die "Can't find $filename in \@INC";
+ }
+ die $@ if $@;
+ die "$filename did not return true value" unless $result;
+ $INC{$filename} = $realfilename;
+ return $result;
+ }
+
+Note that the file will not be included twice under the same specified
+name. The file must return TRUE as the last statement to indicate
+successful execution of any initialization code, so it's customary to
+end such a file with "C<1;>" unless you're sure it'll return TRUE
+otherwise. But it's better just to put the "C<1;>", in case you add more
+statements.
+
+If EXPR is a bareword, the require assumes a "F<.pm>" extension and
+replaces "F<::>" with "F</>" in the filename for you,
+to make it easy to load standard modules. This form of loading of
+modules does not risk altering your namespace.
+
+In other words, if you try this:
+
+ require Foo::Bar; # a splendid bareword
+
+The require function will actually look for the "F<Foo/Bar.pm>" file in the
+directories specified in the C<@INC> array.
+
+But if you try this:
+
+ $class = 'Foo::Bar';
+ require $class; # $class is not a bareword
+ #or
+ require "Foo::Bar"; # not a bareword because of the ""
+
+The require function will look for the "F<Foo::Bar>" file in the @INC array and
+will complain about not finding "F<Foo::Bar>" there. In this case you can do:
+
+ eval "require $class";
+
+For a yet-more-powerful import facility, see L</use> and L<perlmod>.
+
+=item reset EXPR
+
+=item reset
+
+Generally used in a C<continue> block at the end of a loop to clear
+variables and reset C<??> searches so that they work again. The
+expression is interpreted as a list of single characters (hyphens
+allowed for ranges). All variables and arrays beginning with one of
+those letters are reset to their pristine state. If the expression is
+omitted, one-match searches (C<?pattern?>) are reset to match again. Resets
+only variables or searches in the current package. Always returns
+1. Examples:
+
+ reset 'X'; # reset all X variables
+ reset 'a-z'; # reset lower case variables
+ reset; # just reset ?? searches
+
+Resetting C<"A-Z"> is not recommended because you'll wipe out your
+C<@ARGV> and C<@INC> arrays and your C<%ENV> hash. Resets only package variables--lexical variables
+are unaffected, but they clean themselves up on scope exit anyway,
+so you'll probably want to use them instead. See L</my>.
+
+=item return EXPR
+
+=item return
+
+Returns from a subroutine, C<eval()>, or C<do FILE> with the value
+given in EXPR. Evaluation of EXPR may be in list, scalar, or void
+context, depending on how the return value will be used, and the context
+may vary from one execution to the next (see C<wantarray()>). If no EXPR
+is given, returns an empty list in list context, an undefined value in
+scalar context, or nothing in a void context.
+
+(Note that in the absence of a return, a subroutine, eval, or do FILE
+will automatically return the value of the last expression evaluated.)
+
+=item reverse LIST
+
+In list context, returns a list value consisting of the elements
+of LIST in the opposite order. In scalar context, concatenates the
+elements of LIST, and returns a string value consisting of those bytes,
+but in the opposite order.
+
+ print reverse <>; # line tac, last line first
+
+ undef $/; # for efficiency of <>
+ print scalar reverse <>; # byte tac, last line tsrif
+
+This operator is also handy for inverting a hash, although there are some
+caveats. If a value is duplicated in the original hash, only one of those
+can be represented as a key in the inverted hash. Also, this has to
+unwind one hash and build a whole new one, which may take some time
+on a large hash.
+
+ %by_name = reverse %by_address; # Invert the hash
+
+=item rewinddir DIRHANDLE
+
+Sets the current position to the beginning of the directory for the
+C<readdir()> routine on DIRHANDLE.
+
+=item rindex STR,SUBSTR,POSITION
+
+=item rindex STR,SUBSTR
+
+Works just like index except that it returns the position of the LAST
+occurrence of SUBSTR in STR. If POSITION is specified, returns the
+last occurrence at or before that position.
+
+=item rmdir FILENAME
+
+=item rmdir
+
+Deletes the directory specified by FILENAME if that directory is empty. If it
+succeeds it returns TRUE, otherwise it returns FALSE and sets C<$!> (errno). If
+FILENAME is omitted, uses C<$_>.
+
+=item s///
+
+The substitution operator. See L<perlop>.
+
+=item scalar EXPR
+
+Forces EXPR to be interpreted in scalar context and returns the value
+of EXPR.
+
+ @counts = ( scalar @a, scalar @b, scalar @c );
+
+There is no equivalent operator to force an expression to
+be interpolated in list context because it's in practice never
+needed. If you really wanted to do so, however, you could use
+the construction C<@{[ (some expression) ]}>, but usually a simple
+C<(some expression)> suffices.
+
+=item seek FILEHANDLE,POSITION,WHENCE
+
+Sets FILEHANDLE's position, just like the C<fseek()> call of C<stdio()>.
+FILEHANDLE may be an expression whose value gives the name of the
+filehandle. The values for WHENCE are C<0> to set the new position to
+POSITION, C<1> to set it to the current position plus POSITION, and C<2> to
+set it to EOF plus POSITION (typically negative). For WHENCE you may
+use the constants C<SEEK_SET>, C<SEEK_CUR>, and C<SEEK_END> from either the
+C<IO::Seekable> or the POSIX module. Returns C<1> upon success, C<0> otherwise.
+
+If you want to position file for C<sysread()> or C<syswrite()>, don't use
+C<seek()> -- buffering makes its effect on the file's system position
+unpredictable and non-portable. Use C<sysseek()> instead.
+
+On some systems you have to do a seek whenever you switch between reading
+and writing. Amongst other things, this may have the effect of calling
+stdio's clearerr(3). A WHENCE of C<1> (C<SEEK_CUR>) is useful for not moving
+the file position:
+
+ seek(TEST,0,1);
+
+This is also useful for applications emulating C<tail -f>. Once you hit
+EOF on your read, and then sleep for a while, you might have to stick in a
+seek() to reset things. The C<seek()> doesn't change the current position,
+but it I<does> clear the end-of-file condition on the handle, so that the
+next C<E<lt>FILEE<gt>> makes Perl try again to read something. We hope.
+
+If that doesn't work (some stdios are particularly cantankerous), then
+you may need something more like this:
+
+ for (;;) {
+ for ($curpos = tell(FILE); $_ = <FILE>;
+ $curpos = tell(FILE)) {
+ # search for some stuff and put it into files
+ }
+ sleep($for_a_while);
+ seek(FILE, $curpos, 0);
+ }
+
+=item seekdir DIRHANDLE,POS
+
+Sets the current position for the C<readdir()> routine on DIRHANDLE. POS
+must be a value returned by C<telldir()>. Has the same caveats about
+possible directory compaction as the corresponding system library
+routine.
+
+=item select FILEHANDLE
+
+=item select
+
+Returns the currently selected filehandle. Sets the current default
+filehandle for output, if FILEHANDLE is supplied. This has two
+effects: first, a C<write()> or a C<print()> without a filehandle will
+default to this FILEHANDLE. Second, references to variables related to
+output will refer to this output channel. For example, if you have to
+set the top of form format for more than one output channel, you might
+do the following:
+
+ select(REPORT1);
+ $^ = 'report1_top';
+ select(REPORT2);
+ $^ = 'report2_top';
+
+FILEHANDLE may be an expression whose value gives the name of the
+actual filehandle. Thus:
+
+ $oldfh = select(STDERR); $| = 1; select($oldfh);
+
+Some programmers may prefer to think of filehandles as objects with
+methods, preferring to write the last example as:
+
+ use IO::Handle;
+ STDERR->autoflush(1);
+
+=item select RBITS,WBITS,EBITS,TIMEOUT
+
+This calls the select(2) system call with the bit masks specified, which
+can be constructed using C<fileno()> and C<vec()>, along these lines:
+
+ $rin = $win = $ein = '';
+ vec($rin,fileno(STDIN),1) = 1;
+ vec($win,fileno(STDOUT),1) = 1;
+ $ein = $rin | $win;
+
+If you want to select on many filehandles you might wish to write a
+subroutine:
+
+ sub fhbits {
+ my(@fhlist) = split(' ',$_[0]);
+ my($bits);
+ for (@fhlist) {
+ vec($bits,fileno($_),1) = 1;
+ }
+ $bits;
+ }
+ $rin = fhbits('STDIN TTY SOCK');
+
+The usual idiom is:
+
+ ($nfound,$timeleft) =
+ select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
+
+or to block until something becomes ready just do this
+
+ $nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);
+
+Most systems do not bother to return anything useful in C<$timeleft>, so
+calling select() in scalar context just returns C<$nfound>.
+
+Any of the bit masks can also be undef. The timeout, if specified, is
+in seconds, which may be fractional. Note: not all implementations are
+capable of returning theC<$timeleft>. If not, they always return
+C<$timeleft> equal to the supplied C<$timeout>.
+
+You can effect a sleep of 250 milliseconds this way:
+
+ select(undef, undef, undef, 0.25);
+
+B<WARNING>: One should not attempt to mix buffered I/O (like C<read()>
+or E<lt>FHE<gt>) with C<select()>, except as permitted by POSIX, and even
+then only on POSIX systems. You have to use C<sysread()> instead.
+
+=item semctl ID,SEMNUM,CMD,ARG
+
+Calls the System V IPC function C<semctl()>. You'll probably have to say
+
+ use IPC::SysV;
+
+first to get the correct constant definitions. If CMD is IPC_STAT or
+GETALL, then ARG must be a variable which will hold the returned
+semid_ds structure or semaphore value array. Returns like C<ioctl()>: the
+undefined value for error, "C<0> but true" for zero, or the actual return
+value otherwise. See also C<IPC::SysV> and C<IPC::Semaphore> documentation.
+
+=item semget KEY,NSEMS,FLAGS
+
+Calls the System V IPC function semget. Returns the semaphore id, or
+the undefined value if there is an error. See also C<IPC::SysV> and
+C<IPC::SysV::Semaphore> documentation.
+
+=item semop KEY,OPSTRING
+
+Calls the System V IPC function semop to perform semaphore operations
+such as signaling and waiting. OPSTRING must be a packed array of
+semop structures. Each semop structure can be generated with
+C<pack("sss", $semnum, $semop, $semflag)>. The number of semaphore
+operations is implied by the length of OPSTRING. Returns TRUE if
+successful, or FALSE if there is an error. As an example, the
+following code waits on semaphore C<$semnum> of semaphore id C<$semid>:
+
+ $semop = pack("sss", $semnum, -1, 0);
+ die "Semaphore trouble: $!\n" unless semop($semid, $semop);
+
+To signal the semaphore, replace C<-1> with C<1>. See also C<IPC::SysV>
+and C<IPC::SysV::Semaphore> documentation.
+
+=item send SOCKET,MSG,FLAGS,TO
+
+=item send SOCKET,MSG,FLAGS
+
+Sends a message on a socket. Takes the same flags as the system call
+of the same name. On unconnected sockets you must specify a
+destination to send TO, in which case it does a C C<sendto()>. Returns
+the number of characters sent, or the undefined value if there is an
+error.
+See L<perlipc/"UDP: Message Passing"> for examples.
+
+=item setpgrp PID,PGRP
+
+Sets the current process group for the specified PID, C<0> for the current
+process. Will produce a fatal error if used on a machine that doesn't
+implement setpgrp(2). If the arguments are omitted, it defaults to
+C<0,0>. Note that the POSIX version of C<setpgrp()> does not accept any
+arguments, so only setpgrp C<0,0> is portable.
+
+=item setpriority WHICH,WHO,PRIORITY
+
+Sets the current priority for a process, a process group, or a user.
+(See setpriority(2).) Will produce a fatal error if used on a machine
+that doesn't implement setpriority(2).
+
+=item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
+
+Sets the socket option requested. Returns undefined if there is an
+error. OPTVAL may be specified as C<undef> if you don't want to pass an
+argument.
+
+=item shift ARRAY
+
+=item shift
+
+Shifts the first value of the array off and returns it, shortening the
+array by 1 and moving everything down. If there are no elements in the
+array, returns the undefined value. If ARRAY is omitted, shifts the
+C<@_> array within the lexical scope of subroutines and formats, and the
+C<@ARGV> array at file scopes or within the lexical scopes established by
+the C<eval ''>, C<BEGIN {}>, C<END {}>, and C<INIT {}> constructs.
+See also C<unshift()>, C<push()>, and C<pop()>. C<Shift()> and C<unshift()> do the
+same thing to the left end of an array that C<pop()> and C<push()> do to the
+right end.
+
+=item shmctl ID,CMD,ARG
+
+Calls the System V IPC function shmctl. You'll probably have to say
+
+ use IPC::SysV;
+
+first to get the correct constant definitions. If CMD is C<IPC_STAT>,
+then ARG must be a variable which will hold the returned C<shmid_ds>
+structure. Returns like ioctl: the undefined value for error, "C<0> but
+true" for zero, or the actual return value otherwise.
+See also C<IPC::SysV> documentation.
+
+=item shmget KEY,SIZE,FLAGS
+
+Calls the System V IPC function shmget. Returns the shared memory
+segment id, or the undefined value if there is an error.
+See also C<IPC::SysV> documentation.
+
+=item shmread ID,VAR,POS,SIZE
+
+=item shmwrite ID,STRING,POS,SIZE
+
+Reads or writes the System V shared memory segment ID starting at
+position POS for size SIZE by attaching to it, copying in/out, and
+detaching from it. When reading, VAR must be a variable that will
+hold the data read. When writing, if STRING is too long, only SIZE
+bytes are used; if STRING is too short, nulls are written to fill out
+SIZE bytes. Return TRUE if successful, or FALSE if there is an error.
+See also C<IPC::SysV> documentation.
+
+=item shutdown SOCKET,HOW
+
+Shuts down a socket connection in the manner indicated by HOW, which
+has the same interpretation as in the system call of the same name.
+
+ shutdown(SOCKET, 0); # I/we have stopped reading data
+ shutdown(SOCKET, 1); # I/we have stopped writing data
+ shutdown(SOCKET, 2); # I/we have stopped using this socket
+
+This is useful with sockets when you want to tell the other
+side you're done writing but not done reading, or vice versa.
+It's also a more insistent form of close because it also
+disables the filedescriptor in any forked copies in other
+processes.
+
+=item sin EXPR
+
+=item sin
+
+Returns the sine of EXPR (expressed in radians). If EXPR is omitted,
+returns sine of C<$_>.
+
+For the inverse sine operation, you may use the C<POSIX::asin()>
+function, or use this relation:
+
+ sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) }
+
+=item sleep EXPR
+
+=item sleep
+
+Causes the script to sleep for EXPR seconds, or forever if no EXPR.
+May be interrupted if the process receives a signal such as C<SIGALRM>.
+Returns the number of seconds actually slept. You probably cannot
+mix C<alarm()> and C<sleep()> calls, because C<sleep()> is often implemented
+using C<alarm()>.
+
+On some older systems, it may sleep up to a full second less than what
+you requested, depending on how it counts seconds. Most modern systems
+always sleep the full amount. They may appear to sleep longer than that,
+however, because your process might not be scheduled right away in a
+busy multitasking system.
+
+For delays of finer granularity than one second, you may use Perl's
+C<syscall()> interface to access setitimer(2) if your system supports it,
+or else see L</select()> above.
+
+See also the POSIX module's C<sigpause()> function.
+
+=item socket SOCKET,DOMAIN,TYPE,PROTOCOL
+
+Opens a socket of the specified kind and attaches it to filehandle
+SOCKET. DOMAIN, TYPE, and PROTOCOL are specified the same as for the
+system call of the same name. You should "C<use Socket;>" first to get
+the proper definitions imported. See the example in L<perlipc/"Sockets: Client/Server Communication">.
+
+=item socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL
+
+Creates an unnamed pair of sockets in the specified domain, of the
+specified type. DOMAIN, TYPE, and PROTOCOL are specified the same as
+for the system call of the same name. If unimplemented, yields a fatal
+error. Returns TRUE if successful.
+
+Some systems defined C<pipe()> in terms of C<socketpair()>, in which a call
+to C<pipe(Rdr, Wtr)> is essentially:
+
+ use Socket;
+ socketpair(Rdr, Wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
+ shutdown(Rdr, 1); # no more writing for reader
+ shutdown(Wtr, 0); # no more reading for writer
+
+See L<perlipc> for an example of socketpair use.
+
+=item sort SUBNAME LIST
+
+=item sort BLOCK LIST
+
+=item sort LIST
+
+Sorts the LIST and returns the sorted list value. If SUBNAME or BLOCK
+is omitted, C<sort()>s in standard string comparison order. If SUBNAME is
+specified, it gives the name of a subroutine that returns an integer
+less than, equal to, or greater than C<0>, depending on how the elements
+of the array are to be ordered. (The C<E<lt>=E<gt>> and C<cmp>
+operators are extremely useful in such routines.) SUBNAME may be a
+scalar variable name (unsubscripted), in which case the value provides
+the name of (or a reference to) the actual subroutine to use. In place
+of a SUBNAME, you can provide a BLOCK as an anonymous, in-line sort
+subroutine.
+
+In the interests of efficiency the normal calling code for subroutines is
+bypassed, with the following effects: the subroutine may not be a
+recursive subroutine, and the two elements to be compared are passed into
+the subroutine not via C<@_> but as the package global variables C<$a> and
+C<$b> (see example below). They are passed by reference, so don't
+modify C<$a> and C<$b>. And don't try to declare them as lexicals either.
+
+You also cannot exit out of the sort block or subroutine using any of the
+loop control operators described in L<perlsyn> or with C<goto()>.
+
+When C<use locale> is in effect, C<sort LIST> sorts LIST according to the
+current collation locale. See L<perllocale>.
+
+Examples:
+
+ # sort lexically
+ @articles = sort @files;
+
+ # same thing, but with explicit sort routine
+ @articles = sort {$a cmp $b} @files;
+
+ # now case-insensitively
+ @articles = sort {uc($a) cmp uc($b)} @files;
+
+ # same thing in reversed order
+ @articles = sort {$b cmp $a} @files;
+
+ # sort numerically ascending
+ @articles = sort {$a <=> $b} @files;
+
+ # sort numerically descending
+ @articles = sort {$b <=> $a} @files;
+
+ # sort using explicit subroutine name
+ sub byage {
+ $age{$a} <=> $age{$b}; # presuming numeric
+ }
+ @sortedclass = sort byage @class;
+
+ # this sorts the %age hash by value instead of key
+ # using an in-line function
+ @eldest = sort { $age{$b} <=> $age{$a} } keys %age;
+
+ sub backwards { $b cmp $a; }
+ @harry = ('dog','cat','x','Cain','Abel');
+ @george = ('gone','chased','yz','Punished','Axed');
+ print sort @harry;
+ # prints AbelCaincatdogx
+ print sort backwards @harry;
+ # prints xdogcatCainAbel
+ print sort @george, 'to', @harry;
+ # prints AbelAxedCainPunishedcatchaseddoggonetoxyz
+
+ # inefficiently sort by descending numeric compare using
+ # the first integer after the first = sign, or the
+ # whole record case-insensitively otherwise
+
+ @new = sort {
+ ($b =~ /=(\d+)/)[0] <=> ($a =~ /=(\d+)/)[0]
+ ||
+ uc($a) cmp uc($b)
+ } @old;
+
+ # same thing, but much more efficiently;
+ # we'll build auxiliary indices instead
+ # for speed
+ @nums = @caps = ();
+ for (@old) {
+ push @nums, /=(\d+)/;
+ push @caps, uc($_);
+ }
+
+ @new = @old[ sort {
+ $nums[$b] <=> $nums[$a]
+ ||
+ $caps[$a] cmp $caps[$b]
+ } 0..$#old
+ ];
+
+ # same thing using a Schwartzian Transform (no temps)
+ @new = map { $_->[0] }
+ sort { $b->[1] <=> $a->[1]
+ ||
+ $a->[2] cmp $b->[2]
+ } map { [$_, /=(\d+)/, uc($_)] } @old;
+
+If you're using strict, you I<MUST NOT> declare C<$a>
+and C<$b> as lexicals. They are package globals. That means
+if you're in the C<main> package, it's
+
+ @articles = sort {$main::b <=> $main::a} @files;
+
+or just
+
+ @articles = sort {$::b <=> $::a} @files;
+
+but if you're in the C<FooPack> package, it's
+
+ @articles = sort {$FooPack::b <=> $FooPack::a} @files;
+
+The comparison function is required to behave. If it returns
+inconsistent results (sometimes saying C<$x[1]> is less than C<$x[2]> and
+sometimes saying the opposite, for example) the results are not
+well-defined.
+
+=item splice ARRAY,OFFSET,LENGTH,LIST
+
+=item splice ARRAY,OFFSET,LENGTH
+
+=item splice ARRAY,OFFSET
+
+Removes the elements designated by OFFSET and LENGTH from an array, and
+replaces them with the elements of LIST, if any. In list context,
+returns the elements removed from the array. In scalar context,
+returns the last element removed, or C<undef> if no elements are
+removed. The array grows or shrinks as necessary.
+If OFFSET is negative then it start that far from the end of the array.
+If LENGTH is omitted, removes everything from OFFSET onward.
+If LENGTH is negative, leave that many elements off the end of the array.
+The following equivalences hold (assuming C<$[ == 0>):
+
+ push(@a,$x,$y) splice(@a,@a,0,$x,$y)
+ pop(@a) splice(@a,-1)
+ shift(@a) splice(@a,0,1)
+ unshift(@a,$x,$y) splice(@a,0,0,$x,$y)
+ $a[$x] = $y splice(@a,$x,1,$y)
+
+Example, assuming array lengths are passed before arrays:
+
+ sub aeq { # compare two list values
+ my(@a) = splice(@_,0,shift);
+ my(@b) = splice(@_,0,shift);
+ return 0 unless @a == @b; # same len?
+ while (@a) {
+ return 0 if pop(@a) ne pop(@b);
+ }
+ return 1;
+ }
+ if (&aeq($len,@foo[1..$len],0+@bar,@bar)) { ... }
+
+=item split /PATTERN/,EXPR,LIMIT
+
+=item split /PATTERN/,EXPR
+
+=item split /PATTERN/
+
+=item split
+
+Splits a string into an array of strings, and returns it. By default,
+empty leading fields are preserved, and empty trailing ones are deleted.
+
+If not in list context, returns the number of fields found and splits into
+the C<@_> array. (In list context, you can force the split into C<@_> by
+using C<??> as the pattern delimiters, but it still returns the list
+value.) The use of implicit split to C<@_> is deprecated, however, because
+it clobbers your subroutine arguments.
+
+If EXPR is omitted, splits the C<$_> string. If PATTERN is also omitted,
+splits on whitespace (after skipping any leading whitespace). Anything
+matching PATTERN is taken to be a delimiter separating the fields. (Note
+that the delimiter may be longer than one character.)
+
+If LIMIT is specified and positive, splits into no more than that
+many fields (though it may split into fewer). If LIMIT is unspecified
+or zero, trailing null fields are stripped (which potential users
+of C<pop()> would do well to remember). If LIMIT is negative, it is
+treated as if an arbitrarily large LIMIT had been specified.
+
+A pattern matching the null string (not to be confused with
+a null pattern C<//>, which is just one member of the set of patterns
+matching a null string) will split the value of EXPR into separate
+characters at each point it matches that way. For example:
+
+ print join(':', split(/ */, 'hi there'));
+
+produces the output 'h:i:t:h:e:r:e'.
+
+The LIMIT parameter can be used to split a line partially
+
+ ($login, $passwd, $remainder) = split(/:/, $_, 3);
+
+When assigning to a list, if LIMIT is omitted, Perl supplies a LIMIT
+one larger than the number of variables in the list, to avoid
+unnecessary work. For the list above LIMIT would have been 4 by
+default. In time critical applications it behooves you not to split
+into more fields than you really need.
+
+If the PATTERN contains parentheses, additional array elements are
+created from each matching substring in the delimiter.
+
+ split(/([,-])/, "1-10,20", 3);
+
+produces the list value
+
+ (1, '-', 10, ',', 20)
+
+If you had the entire header of a normal Unix email message in C<$header>,
+you could split it up into fields and their values this way:
+
+ $header =~ s/\n\s+/ /g; # fix continuation lines
+ %hdrs = (UNIX_FROM => split /^(\S*?):\s*/m, $header);
+
+The pattern C</PATTERN/> may be replaced with an expression to specify
+patterns that vary at runtime. (To do runtime compilation only once,
+use C</$variable/o>.)
+
+As a special case, specifying a PATTERN of space (C<' '>) will split on
+white space just as C<split()> with no arguments does. Thus, C<split(' ')> can
+be used to emulate B<awk>'s default behavior, whereas C<split(/ /)>
+will give you as many null initial fields as there are leading spaces.
+A C<split()> on C</\s+/> is like a C<split(' ')> except that any leading
+whitespace produces a null first field. A C<split()> with no arguments
+really does a C<split(' ', $_)> internally.
+
+Example:
+
+ open(PASSWD, '/etc/passwd');
+ while (<PASSWD>) {
+ ($login, $passwd, $uid, $gid,
+ $gcos, $home, $shell) = split(/:/);
+ #...
+ }
+
+(Note that C<$shell> above will still have a newline on it. See L</chop>,
+L</chomp>, and L</join>.)
+
+=item sprintf FORMAT, LIST
+
+Returns a string formatted by the usual C<printf()> conventions of the
+C library function C<sprintf()>. See L<sprintf(3)> or L<printf(3)>
+on your system for an explanation of the general principles.
+
+Perl does its own C<sprintf()> formatting -- it emulates the C
+function C<sprintf()>, but it doesn't use it (except for floating-point
+numbers, and even then only the standard modifiers are allowed). As a
+result, any non-standard extensions in your local C<sprintf()> are not
+available from Perl.
+
+Perl's C<sprintf()> permits the following universally-known conversions:
+
+ %% a percent sign
+ %c a character with the given number
+ %s a string
+ %d a signed integer, in decimal
+ %u an unsigned integer, in decimal
+ %o an unsigned integer, in octal
+ %x an unsigned integer, in hexadecimal
+ %e a floating-point number, in scientific notation
+ %f a floating-point number, in fixed decimal notation
+ %g a floating-point number, in %e or %f notation
+
+In addition, Perl permits the following widely-supported conversions:
+
+ %X like %x, but using upper-case letters
+ %E like %e, but using an upper-case "E"
+ %G like %g, but with an upper-case "E" (if applicable)
+ %p a pointer (outputs the Perl value's address in hexadecimal)
+ %n special: *stores* the number of characters output so far
+ into the next variable in the parameter list
+
+Finally, for backward (and we do mean "backward") compatibility, Perl
+permits these unnecessary but widely-supported conversions:
+
+ %i a synonym for %d
+ %D a synonym for %ld
+ %U a synonym for %lu
+ %O a synonym for %lo
+ %F a synonym for %f
+
+Perl permits the following universally-known flags between the C<%>
+and the conversion letter:
+
+ space prefix positive number with a space
+ + prefix positive number with a plus sign
+ - left-justify within the field
+ 0 use zeros, not spaces, to right-justify
+ # prefix non-zero octal with "0", non-zero hex with "0x"
+ number minimum field width
+ .number "precision": digits after decimal point for
+ floating-point, max length for string, minimum length
+ for integer
+ l interpret integer as C type "long" or "unsigned long"
+ h interpret integer as C type "short" or "unsigned short"
+
+There is also one Perl-specific flag:
+
+ V interpret integer as Perl's standard integer type
+
+Where a number would appear in the flags, an asterisk ("C<*>") may be
+used instead, in which case Perl uses the next item in the parameter
+list as the given number (that is, as the field width or precision).
+If a field width obtained through "C<*>" is negative, it has the same
+effect as the "C<->" flag: left-justification.
+
+If C<use locale> is in effect, the character used for the decimal
+point in formatted real numbers is affected by the LC_NUMERIC locale.
+See L<perllocale>.
+
+=item sqrt EXPR
+
+=item sqrt
+
+Return the square root of EXPR. If EXPR is omitted, returns square
+root of C<$_>.
+
+=item srand EXPR
+
+=item srand
+
+Sets the random number seed for the C<rand()> operator. If EXPR is
+omitted, uses a semi-random value based on the current time and process
+ID, among other things. In versions of Perl prior to 5.004 the default
+seed was just the current C<time()>. This isn't a particularly good seed,
+so many old programs supply their own seed value (often C<time ^ $$> or
+C<time ^ ($$ + ($$ E<lt>E<lt> 15))>), but that isn't necessary any more.
+
+In fact, it's usually not necessary to call C<srand()> at all, because if
+it is not called explicitly, it is called implicitly at the first use of
+the C<rand()> operator. However, this was not the case in version of Perl
+before 5.004, so if your script will run under older Perl versions, it
+should call C<srand()>.
+
+Note that you need something much more random than the default seed for
+cryptographic purposes. Checksumming the compressed output of one or more
+rapidly changing operating system status programs is the usual method. For
+example:
+
+ srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
+
+If you're particularly concerned with this, see the C<Math::TrulyRandom>
+module in CPAN.
+
+Do I<not> call C<srand()> multiple times in your program unless you know
+exactly what you're doing and why you're doing it. The point of the
+function is to "seed" the C<rand()> function so that C<rand()> can produce
+a different sequence each time you run your program. Just do it once at the
+top of your program, or you I<won't> get random numbers out of C<rand()>!
+
+Frequently called programs (like CGI scripts) that simply use
+
+ time ^ $$
+
+for a seed can fall prey to the mathematical property that
+
+ a^b == (a+1)^(b+1)
+
+one-third of the time. So don't do that.
+
+=item stat FILEHANDLE
+
+=item stat EXPR
+
+=item stat
+
+Returns a 13-element list giving the status info for a file, either
+the file opened via FILEHANDLE, or named by EXPR. If EXPR is omitted,
+it stats C<$_>. Returns a null list if the stat fails. Typically used
+as follows:
+
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks)
+ = stat($filename);
+
+Not all fields are supported on all filesystem types. Here are the
+meaning of the fields:
+
+ 0 dev device number of filesystem
+ 1 ino inode number
+ 2 mode file mode (type and permissions)
+ 3 nlink number of (hard) links to the file
+ 4 uid numeric user ID of file's owner
+ 5 gid numeric group ID of file's owner
+ 6 rdev the device identifier (special files only)
+ 7 size total size of file, in bytes
+ 8 atime last access time since the epoch
+ 9 mtime last modify time since the epoch
+ 10 ctime inode change time (NOT creation time!) since the epoch
+ 11 blksize preferred block size for file system I/O
+ 12 blocks actual number of blocks allocated
+
+(The epoch was at 00:00 January 1, 1970 GMT.)
+
+If stat is passed the special filehandle consisting of an underline, no
+stat is done, but the current contents of the stat structure from the
+last stat or filetest are returned. Example:
+
+ if (-x $file && (($d) = stat(_)) && $d < 0) {
+ print "$file is executable NFS file\n";
+ }
+
+(This works on machines only for which the device number is negative under NFS.)
+
+In scalar context, C<stat()> returns a boolean value indicating success
+or failure, and, if successful, sets the information associated with
+the special filehandle C<_>.
+
+=item study SCALAR
+
+=item study
+
+Takes extra time to study SCALAR (C<$_> if unspecified) in anticipation of
+doing many pattern matches on the string before it is next modified.
+This may or may not save time, depending on the nature and number of
+patterns you are searching on, and on the distribution of character
+frequencies in the string to be searched -- you probably want to compare
+run times with and without it to see which runs faster. Those loops
+which scan for many short constant strings (including the constant
+parts of more complex patterns) will benefit most. You may have only
+one C<study()> active at a time -- if you study a different scalar the first
+is "unstudied". (The way C<study()> works is this: a linked list of every
+character in the string to be searched is made, so we know, for
+example, where all the C<'k'> characters are. From each search string,
+the rarest character is selected, based on some static frequency tables
+constructed from some C programs and English text. Only those places
+that contain this "rarest" character are examined.)
+
+For example, here is a loop that inserts index producing entries
+before any line containing a certain pattern:
+
+ while (<>) {
+ study;
+ print ".IX foo\n" if /\bfoo\b/;
+ print ".IX bar\n" if /\bbar\b/;
+ print ".IX blurfl\n" if /\bblurfl\b/;
+ # ...
+ print;
+ }
+
+In searching for C</\bfoo\b/>, only those locations in C<$_> that contain C<"f">
+will be looked at, because C<"f"> is rarer than C<"o">. In general, this is
+a big win except in pathological cases. The only question is whether
+it saves you more time than it took to build the linked list in the
+first place.
+
+Note that if you have to look for strings that you don't know till
+runtime, you can build an entire loop as a string and C<eval()> that to
+avoid recompiling all your patterns all the time. Together with
+undefining C<$/> to input entire files as one record, this can be very
+fast, often faster than specialized programs like fgrep(1). The following
+scans a list of files (C<@files>) for a list of words (C<@words>), and prints
+out the names of those files that contain a match:
+
+ $search = 'while (<>) { study;';
+ foreach $word (@words) {
+ $search .= "++\$seen{\$ARGV} if /\\b$word\\b/;\n";
+ }
+ $search .= "}";
+ @ARGV = @files;
+ undef $/;
+ eval $search; # this screams
+ $/ = "\n"; # put back to normal input delimiter
+ foreach $file (sort keys(%seen)) {
+ print $file, "\n";
+ }
+
+=item sub BLOCK
+
+=item sub NAME
+
+=item sub NAME BLOCK
+
+This is subroutine definition, not a real function I<per se>. With just a
+NAME (and possibly prototypes), it's just a forward declaration. Without
+a NAME, it's an anonymous function declaration, and does actually return a
+value: the CODE ref of the closure you just created. See L<perlsub> and
+L<perlref> for details.
+
+=item substr EXPR,OFFSET,LEN,REPLACEMENT
+
+=item substr EXPR,OFFSET,LEN
+
+=item substr EXPR,OFFSET
+
+Extracts a substring out of EXPR and returns it. First character is at
+offset C<0>, or whatever you've set C<$[> to (but don't do that).
+If OFFSET is negative (or more precisely, less than C<$[>), starts
+that far from the end of the string. If LEN is omitted, returns
+everything to the end of the string. If LEN is negative, leaves that
+many characters off the end of the string.
+
+If you specify a substring that is partly outside the string, the part
+within the string is returned. If the substring is totally outside
+the string a warning is produced.
+
+You can use the C<substr()> function
+as an lvalue, in which case EXPR must be an lvalue. If you assign
+something shorter than LEN, the string will shrink, and if you assign
+something longer than LEN, the string will grow to accommodate it. To
+keep the string the same length you may need to pad or chop your value
+using C<sprintf()>.
+
+An alternative to using C<substr()> as an lvalue is to specify the
+replacement string as the 4th argument. This allows you to replace
+parts of the EXPR and return what was there before in one operation.
+
+=item symlink OLDFILE,NEWFILE
+
+Creates a new filename symbolically linked to the old filename.
+Returns C<1> for success, C<0> otherwise. On systems that don't support
+symbolic links, produces a fatal error at run time. To check for that,
+use eval:
+
+ $symlink_exists = eval { symlink("",""); 1 };
+
+=item syscall LIST
+
+Calls the system call specified as the first element of the list,
+passing the remaining elements as arguments to the system call. If
+unimplemented, produces a fatal error. The arguments are interpreted
+as follows: if a given argument is numeric, the argument is passed as
+an int. If not, the pointer to the string value is passed. You are
+responsible to make sure a string is pre-extended long enough to
+receive any result that might be written into a string. You can't use a
+string literal (or other read-only string) as an argument to C<syscall()>
+because Perl has to assume that any string pointer might be written
+through. If your
+integer arguments are not literals and have never been interpreted in a
+numeric context, you may need to add C<0> to them to force them to look
+like numbers. This emulates the C<syswrite()> function (or vice versa):
+
+ require 'syscall.ph'; # may need to run h2ph
+ $s = "hi there\n";
+ syscall(&SYS_write, fileno(STDOUT), $s, length $s);
+
+Note that Perl supports passing of up to only 14 arguments to your system call,
+which in practice should usually suffice.
+
+Syscall returns whatever value returned by the system call it calls.
+If the system call fails, C<syscall()> returns C<-1> and sets C<$!> (errno).
+Note that some system calls can legitimately return C<-1>. The proper
+way to handle such calls is to assign C<$!=0;> before the call and
+check the value of C<$!> if syscall returns C<-1>.
+
+There's a problem with C<syscall(&SYS_pipe)>: it returns the file
+number of the read end of the pipe it creates. There is no way
+to retrieve the file number of the other end. You can avoid this
+problem by using C<pipe()> instead.
+
+=item sysopen FILEHANDLE,FILENAME,MODE
+
+=item sysopen FILEHANDLE,FILENAME,MODE,PERMS
+
+Opens the file whose filename is given by FILENAME, and associates it
+with FILEHANDLE. If FILEHANDLE is an expression, its value is used as
+the name of the real filehandle wanted. This function calls the
+underlying operating system's C<open()> function with the parameters
+FILENAME, MODE, PERMS.
+
+The possible values and flag bits of the MODE parameter are
+system-dependent; they are available via the standard module C<Fcntl>.
+For historical reasons, some values work on almost every system
+supported by perl: zero means read-only, one means write-only, and two
+means read/write. We know that these values do I<not> work under
+OS/390 Unix and on the Macintosh; you probably don't want to use them
+in new code.
+
+If the file named by FILENAME does not exist and the C<open()> call creates
+it (typically because MODE includes the C<O_CREAT> flag), then the value of
+PERMS specifies the permissions of the newly created file. If you omit
+the PERMS argument to C<sysopen()>, Perl uses the octal value C<0666>.
+These permission values need to be in octal, and are modified by your
+process's current C<umask>. The C<umask> value is a number representing
+disabled permissions bits--if your C<umask> were C<027> (group can't write;
+others can't read, write, or execute), then passing C<sysopen()> C<0666> would
+create a file with mode C<0640> (C<0666 &~ 027> is C<0640>).
+
+If you find this C<umask()> talk confusing, here's some advice: supply a
+creation mode of C<0666> for regular files and one of C<0777> for directories
+(in C<mkdir()>) and executable files. This gives users the freedom of
+choice: if they want protected files, they might choose process umasks
+of C<022>, C<027>, or even the particularly antisocial mask of C<077>. Programs
+should rarely if ever make policy decisions better left to the user.
+The exception to this is when writing files that should be kept private:
+mail files, web browser cookies, I<.rhosts> files, and so on. In short,
+seldom if ever use C<0644> as argument to C<sysopen()> because that takes
+away the user's option to have a more permissive umask. Better to omit it.
+
+The C<IO::File> module provides a more object-oriented approach, if you're
+into that kind of thing.
+
+=item sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
+
+=item sysread FILEHANDLE,SCALAR,LENGTH
+
+Attempts to read LENGTH bytes of data into variable SCALAR from the
+specified FILEHANDLE, using the system call read(2). It bypasses
+stdio, so mixing this with other kinds of reads, C<print()>, C<write()>,
+C<seek()>, or C<tell()> can cause confusion because stdio usually buffers
+data. Returns the number of bytes actually read, C<0> at end of file,
+or undef if there was an error. SCALAR will be grown or shrunk so that
+the last byte actually read is the last byte of the scalar after the read.
+
+An OFFSET may be specified to place the read data at some place in the
+string other than the beginning. A negative OFFSET specifies
+placement at that many bytes counting backwards from the end of the
+string. A positive OFFSET greater than the length of SCALAR results
+in the string being padded to the required size with C<"\0"> bytes before
+the result of the read is appended.
+
+=item sysseek FILEHANDLE,POSITION,WHENCE
+
+Sets FILEHANDLE's system position using the system call lseek(2). It
+bypasses stdio, so mixing this with reads (other than C<sysread()>),
+C<print()>, C<write()>, C<seek()>, or C<tell()> may cause confusion. FILEHANDLE may
+be an expression whose value gives the name of the filehandle. The
+values for WHENCE are C<0> to set the new position to POSITION, C<1> to set
+the it to the current position plus POSITION, and C<2> to set it to EOF
+plus POSITION (typically negative). For WHENCE, you may use the
+constants C<SEEK_SET>, C<SEEK_CUR>, and C<SEEK_END> from either the C<IO::Seekable>
+or the POSIX module.
+
+Returns the new position, or the undefined value on failure. A position
+of zero is returned as the string "C<0> but true"; thus C<sysseek()> returns
+TRUE on success and FALSE on failure, yet you can still easily determine
+the new position.
+
+=item system LIST
+
+=item system PROGRAM LIST
+
+Does exactly the same thing as "C<exec LIST>" except that a fork is done
+first, and the parent process waits for the child process to complete.
+Note that argument processing varies depending on the number of
+arguments. If there is more than one argument in LIST, or if LIST is
+an array with more than one value, starts the program given by the
+first element of the list with arguments given by the rest of the list.
+If there is only one scalar argument, the argument is
+checked for shell metacharacters, and if there are any, the entire
+argument is passed to the system's command shell for parsing (this is
+C</bin/sh -c> on Unix platforms, but varies on other platforms). If
+there are no shell metacharacters in the argument, it is split into
+words and passed directly to C<execvp()>, which is more efficient.
+
+The return value is the exit status of the program as
+returned by the C<wait()> call. To get the actual exit value divide by
+256. See also L</exec>. This is I<NOT> what you want to use to capture
+the output from a command, for that you should use merely backticks or
+C<qx//>, as described in L<perlop/"`STRING`">.
+
+Like C<exec()>, C<system()> allows you to lie to a program about its name if
+you use the "C<system PROGRAM LIST>" syntax. Again, see L</exec>.
+
+Because C<system()> and backticks block C<SIGINT> and C<SIGQUIT>, killing the
+program they're running doesn't actually interrupt your program.
+
+ @args = ("command", "arg1", "arg2");
+ system(@args) == 0
+ or die "system @args failed: $?"
+
+You can check all the failure possibilities by inspecting
+C<$?> like this:
+
+ $exit_value = $? >> 8;
+ $signal_num = $? & 127;
+ $dumped_core = $? & 128;
+
+When the arguments get executed via the system shell, results
+and return codes will be subject to its quirks and capabilities.
+See L<perlop/"`STRING`"> and L</exec> for details.
+
+=item syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
+
+=item syswrite FILEHANDLE,SCALAR,LENGTH
+
+Attempts to write LENGTH bytes of data from variable SCALAR to the
+specified FILEHANDLE, using the system call write(2). It bypasses
+stdio, so mixing this with reads (other than C<sysread())>, C<print()>,
+C<write()>, C<seek()>, or C<tell()> may cause confusion because stdio usually
+buffers data. Returns the number of bytes actually written, or C<undef>
+if there was an error. If the LENGTH is greater than the available
+data in the SCALAR after the OFFSET, only as much data as is available
+will be written.
+
+An OFFSET may be specified to write the data from some part of the
+string other than the beginning. A negative OFFSET specifies writing
+that many bytes counting backwards from the end of the string. In the
+case the SCALAR is empty you can use OFFSET but only zero offset.
+
+=item tell FILEHANDLE
+
+=item tell
+
+Returns the current position for FILEHANDLE. FILEHANDLE may be an
+expression whose value gives the name of the actual filehandle. If
+FILEHANDLE is omitted, assumes the file last read.
+
+=item telldir DIRHANDLE
+
+Returns the current position of the C<readdir()> routines on DIRHANDLE.
+Value may be given to C<seekdir()> to access a particular location in a
+directory. Has the same caveats about possible directory compaction as
+the corresponding system library routine.
+
+=item tie VARIABLE,CLASSNAME,LIST
+
+This function binds a variable to a package class that will provide the
+implementation for the variable. VARIABLE is the name of the variable
+to be enchanted. CLASSNAME is the name of a class implementing objects
+of correct type. Any additional arguments are passed to the "C<new()>"
+method of the class (meaning C<TIESCALAR>, C<TIEARRAY>, or C<TIEHASH>).
+Typically these are arguments such as might be passed to the C<dbm_open()>
+function of C. The object returned by the "C<new()>" method is also
+returned by the C<tie()> function, which would be useful if you want to
+access other methods in CLASSNAME.
+
+Note that functions such as C<keys()> and C<values()> may return huge lists
+when used on large objects, like DBM files. You may prefer to use the
+C<each()> function to iterate over such. Example:
+
+ # print out history file offsets
+ use NDBM_File;
+ tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
+ while (($key,$val) = each %HIST) {
+ print $key, ' = ', unpack('L',$val), "\n";
+ }
+ untie(%HIST);
+
+A class implementing a hash should have the following methods:
+
+ TIEHASH classname, LIST
+ DESTROY this
+ FETCH this, key
+ STORE this, key, value
+ DELETE this, key
+ EXISTS this, key
+ FIRSTKEY this
+ NEXTKEY this, lastkey
+
+A class implementing an ordinary array should have the following methods:
+
+ TIEARRAY classname, LIST
+ DESTROY this
+ FETCH this, key
+ STORE this, key, value
+ [others TBD]
+
+A class implementing a scalar should have the following methods:
+
+ TIESCALAR classname, LIST
+ DESTROY this
+ FETCH this,
+ STORE this, value
+
+Unlike C<dbmopen()>, the C<tie()> function will not use or require a module
+for you--you need to do that explicitly yourself. See L<DB_File>
+or the F<Config> module for interesting C<tie()> implementations.
+
+For further details see L<perltie>, L<tied VARIABLE>.
+
+=item tied VARIABLE
+
+Returns a reference to the object underlying VARIABLE (the same value
+that was originally returned by the C<tie()> call that bound the variable
+to a package.) Returns the undefined value if VARIABLE isn't tied to a
+package.
+
+=item time
+
+Returns the number of non-leap seconds since whatever time the system
+considers to be the epoch (that's 00:00:00, January 1, 1904 for MacOS,
+and 00:00:00 UTC, January 1, 1970 for most other systems).
+Suitable for feeding to C<gmtime()> and C<localtime()>.
+
+=item times
+
+Returns a four-element list giving the user and system times, in
+seconds, for this process and the children of this process.
+
+ ($user,$system,$cuser,$csystem) = times;
+
+=item tr///
+
+The transliteration operator. Same as C<y///>. See L<perlop>.
+
+=item truncate FILEHANDLE,LENGTH
+
+=item truncate EXPR,LENGTH
+
+Truncates the file opened on FILEHANDLE, or named by EXPR, to the
+specified length. Produces a fatal error if truncate isn't implemented
+on your system. Returns TRUE if successful, the undefined value
+otherwise.
+
+=item uc EXPR
+
+=item uc
+
+Returns an uppercased version of EXPR. This is the internal function
+implementing the C<\U> escape in double-quoted strings.
+Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>.
+
+If EXPR is omitted, uses C<$_>.
+
+=item ucfirst EXPR
+
+=item ucfirst
+
+Returns the value of EXPR with the first character uppercased. This is
+the internal function implementing the C<\u> escape in double-quoted strings.
+Respects current LC_CTYPE locale if C<use locale> in force. See L<perllocale>.
+
+If EXPR is omitted, uses C<$_>.
+
+=item umask EXPR
+
+=item umask
+
+Sets the umask for the process to EXPR and returns the previous value.
+If EXPR is omitted, merely returns the current umask.
+
+If umask(2) is not implemented on your system and you are trying to
+restrict access for I<yourself> (i.e., (EXPR & 0700) > 0), produces a
+fatal error at run time. If umask(2) is not implemented and you are
+not trying to restrict access for yourself, returns C<undef>.
+
+Remember that a umask is a number, usually given in octal; it is I<not> a
+string of octal digits. See also L</oct>, if all you have is a string.
+
+=item undef EXPR
+
+=item undef
+
+Undefines the value of EXPR, which must be an lvalue. Use only on a
+scalar value, an array (using "C<@>"), a hash (using "C<%>"), a subroutine
+(using "C<&>"), or a typeglob (using "<*>"). (Saying C<undef $hash{$key}>
+will probably not do what you expect on most predefined variables or
+DBM list values, so don't do that; see L<delete>.) Always returns the
+undefined value. You can omit the EXPR, in which case nothing is
+undefined, but you still get an undefined value that you could, for
+instance, return from a subroutine, assign to a variable or pass as a
+parameter. Examples:
+
+ undef $foo;
+ undef $bar{'blurfl'}; # Compare to: delete $bar{'blurfl'};
+ undef @ary;
+ undef %hash;
+ undef &mysub;
+ undef *xyz; # destroys $xyz, @xyz, %xyz, &xyz, etc.
+ return (wantarray ? (undef, $errmsg) : undef) if $they_blew_it;
+ select undef, undef, undef, 0.25;
+ ($a, $b, undef, $c) = &foo; # Ignore third value returned
+
+Note that this is a unary operator, not a list operator.
+
+=item unlink LIST
+
+=item unlink
+
+Deletes a list of files. Returns the number of files successfully
+deleted.
+
+ $cnt = unlink 'a', 'b', 'c';
+ unlink @goners;
+ unlink <*.bak>;
+
+Note: C<unlink()> will not delete directories unless you are superuser and
+the B<-U> flag is supplied to Perl. Even if these conditions are
+met, be warned that unlinking a directory can inflict damage on your
+filesystem. Use C<rmdir()> instead.
+
+If LIST is omitted, uses C<$_>.
+
+=item unpack TEMPLATE,EXPR
+
+C<Unpack()> does the reverse of C<pack()>: it takes a string representing a
+structure and expands it out into a list value, returning the array
+value. (In scalar context, it returns merely the first value
+produced.) The TEMPLATE has the same format as in the C<pack()> function.
+Here's a subroutine that does substring:
+
+ sub substr {
+ my($what,$where,$howmuch) = @_;
+ unpack("x$where a$howmuch", $what);
+ }
+
+and then there's
+
+ sub ordinal { unpack("c",$_[0]); } # same as ord()
+
+In addition, you may prefix a field with a %E<lt>numberE<gt> to indicate that
+you want a E<lt>numberE<gt>-bit checksum of the items instead of the items
+themselves. Default is a 16-bit checksum. For example, the following
+computes the same number as the System V sum program:
+
+ while (<>) {
+ $checksum += unpack("%16C*", $_);
+ }
+ $checksum %= 65536;
+
+The following efficiently counts the number of set bits in a bit vector:
+
+ $setbits = unpack("%32b*", $selectmask);
+
+=item untie VARIABLE
+
+Breaks the binding between a variable and a package. (See C<tie()>.)
+
+=item unshift ARRAY,LIST
+
+Does the opposite of a C<shift()>. Or the opposite of a C<push()>,
+depending on how you look at it. Prepends list to the front of the
+array, and returns the new number of elements in the array.
+
+ unshift(ARGV, '-e') unless $ARGV[0] =~ /^-/;
+
+Note the LIST is prepended whole, not one element at a time, so the
+prepended elements stay in the same order. Use C<reverse()> to do the
+reverse.
+
+=item use Module LIST
+
+=item use Module
+
+=item use Module VERSION LIST
+
+=item use VERSION
+
+Imports some semantics into the current package from the named module,
+generally by aliasing certain subroutine or variable names into your
+package. It is exactly equivalent to
+
+ BEGIN { require Module; import Module LIST; }
+
+except that Module I<must> be a bareword.
+
+If the first argument to C<use> is a number, it is treated as a version
+number instead of a module name. If the version of the Perl interpreter
+is less than VERSION, then an error message is printed and Perl exits
+immediately. This is often useful if you need to check the current
+Perl version before C<use>ing library modules that have changed in
+incompatible ways from older versions of Perl. (We try not to do
+this more than we have to.)
+
+The C<BEGIN> forces the C<require> and C<import()> to happen at compile time. The
+C<require> makes sure the module is loaded into memory if it hasn't been
+yet. The C<import()> is not a builtin--it's just an ordinary static method
+call into the "C<Module>" package to tell the module to import the list of
+features back into the current package. The module can implement its
+C<import()> method any way it likes, though most modules just choose to
+derive their C<import()> method via inheritance from the C<Exporter> class that
+is defined in the C<Exporter> module. See L<Exporter>. If no C<import()>
+method can be found then the error is currently silently ignored. This
+may change to a fatal error in a future version.
+
+If you don't want your namespace altered, explicitly supply an empty list:
+
+ use Module ();
+
+That is exactly equivalent to
+
+ BEGIN { require Module }
+
+If the VERSION argument is present between Module and LIST, then the
+C<use> will call the VERSION method in class Module with the given
+version as an argument. The default VERSION method, inherited from
+the Universal class, croaks if the given version is larger than the
+value of the variable C<$Module::VERSION>. (Note that there is not a
+comma after VERSION!)
+
+Because this is a wide-open interface, pragmas (compiler directives)
+are also implemented this way. Currently implemented pragmas are:
+
+ use integer;
+ use diagnostics;
+ use sigtrap qw(SEGV BUS);
+ use strict qw(subs vars refs);
+ use subs qw(afunc blurfl);
+
+Some of these these pseudo-modules import semantics into the current
+block scope (like C<strict> or C<integer>, unlike ordinary modules,
+which import symbols into the current package (which are effective
+through the end of the file).
+
+There's a corresponding "C<no>" command that unimports meanings imported
+by C<use>, i.e., it calls C<unimport Module LIST> instead of C<import()>.
+
+ no integer;
+ no strict 'refs';
+
+If no C<unimport()> method can be found the call fails with a fatal error.
+
+See L<perlmod> for a list of standard modules and pragmas.
+
+=item utime LIST
+
+Changes the access and modification times on each file of a list of
+files. The first two elements of the list must be the NUMERICAL access
+and modification times, in that order. Returns the number of files
+successfully changed. The inode modification time of each file is set
+to the current time. This code has the same effect as the "C<touch>"
+command if the files already exist:
+
+ #!/usr/bin/perl
+ $now = time;
+ utime $now, $now, @ARGV;
+
+=item values HASH
+
+Returns a list consisting of all the values of the named hash. (In a
+scalar context, returns the number of values.) The values are
+returned in an apparently random order, but it is the same order as
+either the C<keys()> or C<each()> function would produce on the same hash.
+As a side effect, it resets HASH's iterator. See also C<keys()>, C<each()>,
+and C<sort()>.
+
+=item vec EXPR,OFFSET,BITS
+
+Treats the string in EXPR as a vector of unsigned integers, and
+returns the value of the bit field specified by OFFSET. BITS specifies
+the number of bits that are reserved for each entry in the bit
+vector. This must be a power of two from 1 to 32. C<vec()> may also be
+assigned to, in which case parentheses are needed to give the expression
+the correct precedence as in
+
+ vec($image, $max_x * $x + $y, 8) = 3;
+
+Vectors created with C<vec()> can also be manipulated with the logical
+operators C<|>, C<&>, and C<^>, which will assume a bit vector operation is
+desired when both operands are strings.
+
+The following code will build up an ASCII string saying C<'PerlPerlPerl'>.
+The comments show the string after each step. Note that this code works
+in the same way on big-endian or little-endian machines.
+
+ my $foo = '';
+ vec($foo, 0, 32) = 0x5065726C; # 'Perl'
+ vec($foo, 2, 16) = 0x5065; # 'PerlPe'
+ vec($foo, 3, 16) = 0x726C; # 'PerlPerl'
+ vec($foo, 8, 8) = 0x50; # 'PerlPerlP'
+ vec($foo, 9, 8) = 0x65; # 'PerlPerlPe'
+ vec($foo, 20, 4) = 2; # 'PerlPerlPe' . "\x02"
+ vec($foo, 21, 4) = 7; # 'PerlPerlPer'
+ # 'r' is "\x72"
+ vec($foo, 45, 2) = 3; # 'PerlPerlPer' . "\x0c"
+ vec($foo, 93, 1) = 1; # 'PerlPerlPer' . "\x2c"
+ vec($foo, 94, 1) = 1; # 'PerlPerlPerl'
+ # 'l' is "\x6c"
+
+To transform a bit vector into a string or array of 0's and 1's, use these:
+
+ $bits = unpack("b*", $vector);
+ @bits = split(//, unpack("b*", $vector));
+
+If you know the exact length in bits, it can be used in place of the C<*>.
+
+=item wait
+
+Waits for a child process to terminate and returns the pid of the
+deceased process, or C<-1> if there are no child processes. The status is
+returned in C<$?>.
+
+=item waitpid PID,FLAGS
+
+Waits for a particular child process to terminate and returns the pid
+of the deceased process, or C<-1> if there is no such child process. The
+status is returned in C<$?>. If you say
+
+ use POSIX ":sys_wait_h";
+ #...
+ waitpid(-1,&WNOHANG);
+
+then you can do a non-blocking wait for any process. Non-blocking wait
+is available on machines supporting either the waitpid(2) or
+wait4(2) system calls. However, waiting for a particular pid with
+FLAGS of C<0> is implemented everywhere. (Perl emulates the system call
+by remembering the status values of processes that have exited but have
+not been harvested by the Perl script yet.)
+
+See L<perlipc> for other examples.
+
+=item wantarray
+
+Returns TRUE if the context of the currently executing subroutine is
+looking for a list value. Returns FALSE if the context is looking
+for a scalar. Returns the undefined value if the context is looking
+for no value (void context).
+
+ return unless defined wantarray; # don't bother doing more
+ my @a = complex_calculation();
+ return wantarray ? @a : "@a";
+
+=item warn LIST
+
+Produces a message on STDERR just like C<die()>, but doesn't exit or throw
+an exception.
+
+If LIST is empty and C<$@> already contains a value (typically from a
+previous eval) that value is used after appending C<"\t...caught">
+to C<$@>. This is useful for staying almost, but not entirely similar to
+C<die()>.
+
+If C<$@> is empty then the string C<"Warning: Something's wrong"> is used.
+
+No message is printed if there is a C<$SIG{__WARN__}> handler
+installed. It is the handler's responsibility to deal with the message
+as it sees fit (like, for instance, converting it into a C<die()>). Most
+handlers must therefore make arrangements to actually display the
+warnings that they are not prepared to deal with, by calling C<warn()>
+again in the handler. Note that this is quite safe and will not
+produce an endless loop, since C<__WARN__> hooks are not called from
+inside one.
+
+You will find this behavior is slightly different from that of
+C<$SIG{__DIE__}> handlers (which don't suppress the error text, but can
+instead call C<die()> again to change it).
+
+Using a C<__WARN__> handler provides a powerful way to silence all
+warnings (even the so-called mandatory ones). An example:
+
+ # wipe out *all* compile-time warnings
+ BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
+ my $foo = 10;
+ my $foo = 20; # no warning about duplicate my $foo,
+ # but hey, you asked for it!
+ # no compile-time or run-time warnings before here
+ $DOWARN = 1;
+
+ # run-time warnings enabled after here
+ warn "\$foo is alive and $foo!"; # does show up
+
+See L<perlvar> for details on setting C<%SIG> entries, and for more
+examples.
+
+=item write FILEHANDLE
+
+=item write EXPR
+
+=item write
+
+Writes a formatted record (possibly multi-line) to the specified FILEHANDLE,
+using the format associated with that file. By default the format for
+a file is the one having the same name as the filehandle, but the
+format for the current output channel (see the C<select()> function) may be set
+explicitly by assigning the name of the format to the C<$~> variable.
+
+Top of form processing is handled automatically: if there is
+insufficient room on the current page for the formatted record, the
+page is advanced by writing a form feed, a special top-of-page format
+is used to format the new page header, and then the record is written.
+By default the top-of-page format is the name of the filehandle with
+"_TOP" appended, but it may be dynamically set to the format of your
+choice by assigning the name to the C<$^> variable while the filehandle is
+selected. The number of lines remaining on the current page is in
+variable C<$->, which can be set to C<0> to force a new page.
+
+If FILEHANDLE is unspecified, output goes to the current default output
+channel, which starts out as STDOUT but may be changed by the
+C<select()> operator. If the FILEHANDLE is an EXPR, then the expression
+is evaluated and the resulting string is used to look up the name of
+the FILEHANDLE at run time. For more on formats, see L<perlform>.
+
+Note that write is I<NOT> the opposite of C<read()>. Unfortunately.
+
+=item y///
+
+The transliteration operator. Same as C<tr///>. See L<perlop>.
+
+=back
diff --git a/contrib/perl5/pod/perlguts.pod b/contrib/perl5/pod/perlguts.pod
new file mode 100644
index 0000000..20a07d3
--- /dev/null
+++ b/contrib/perl5/pod/perlguts.pod
@@ -0,0 +1,3557 @@
+=head1 NAME
+
+perlguts - Perl's Internal Functions
+
+=head1 DESCRIPTION
+
+This document attempts to describe some of the internal functions of the
+Perl executable. It is far from complete and probably contains many errors.
+Please refer any questions or comments to the author below.
+
+=head1 Variables
+
+=head2 Datatypes
+
+Perl has three typedefs that handle Perl's three main data types:
+
+ SV Scalar Value
+ AV Array Value
+ HV Hash Value
+
+Each typedef has specific routines that manipulate the various data types.
+
+=head2 What is an "IV"?
+
+Perl uses a special typedef IV which is a simple integer type that is
+guaranteed to be large enough to hold a pointer (as well as an integer).
+
+Perl also uses two special typedefs, I32 and I16, which will always be at
+least 32-bits and 16-bits long, respectively.
+
+=head2 Working with SVs
+
+An SV can be created and loaded with one command. There are four types of
+values that can be loaded: an integer value (IV), a double (NV), a string,
+(PV), and another scalar (SV).
+
+The six routines are:
+
+ SV* newSViv(IV);
+ SV* newSVnv(double);
+ SV* newSVpv(char*, int);
+ SV* newSVpvn(char*, int);
+ SV* newSVpvf(const char*, ...);
+ SV* newSVsv(SV*);
+
+To change the value of an *already-existing* SV, there are seven routines:
+
+ void sv_setiv(SV*, IV);
+ void sv_setuv(SV*, UV);
+ void sv_setnv(SV*, double);
+ void sv_setpv(SV*, char*);
+ void sv_setpvn(SV*, char*, int)
+ void sv_setpvf(SV*, const char*, ...);
+ void sv_setpvfn(SV*, const char*, STRLEN, va_list *, SV **, I32, bool);
+ void sv_setsv(SV*, SV*);
+
+Notice that you can choose to specify the length of the string to be
+assigned by using C<sv_setpvn>, C<newSVpvn>, or C<newSVpv>, or you may
+allow Perl to calculate the length by using C<sv_setpv> or by specifying
+0 as the second argument to C<newSVpv>. Be warned, though, that Perl will
+determine the string's length by using C<strlen>, which depends on the
+string terminating with a NUL character.
+
+The arguments of C<sv_setpvf> are processed like C<sprintf>, and the
+formatted output becomes the value.
+
+C<sv_setpvfn> is an analogue of C<vsprintf>, but it allows you to specify
+either a pointer to a variable argument list or the address and length of
+an array of SVs. The last argument points to a boolean; on return, if that
+boolean is true, then locale-specific information has been used to format
+the string, and the string's contents are therefore untrustworty (see
+L<perlsec>). This pointer may be NULL if that information is not
+important. Note that this function requires you to specify the length of
+the format.
+
+The C<sv_set*()> functions are not generic enough to operate on values
+that have "magic". See L<Magic Virtual Tables> later in this document.
+
+All SVs that contain strings should be terminated with a NUL character.
+If it is not NUL-terminated there is a risk of
+core dumps and corruptions from code which passes the string to C
+functions or system calls which expect a NUL-terminated string.
+Perl's own functions typically add a trailing NUL for this reason.
+Nevertheless, you should be very careful when you pass a string stored
+in an SV to a C function or system call.
+
+To access the actual value that an SV points to, you can use the macros:
+
+ SvIV(SV*)
+ SvNV(SV*)
+ SvPV(SV*, STRLEN len)
+
+which will automatically coerce the actual scalar type into an IV, double,
+or string.
+
+In the C<SvPV> macro, the length of the string returned is placed into the
+variable C<len> (this is a macro, so you do I<not> use C<&len>). If you do not
+care what the length of the data is, use the global variable C<PL_na>. Remember,
+however, that Perl allows arbitrary strings of data that may both contain
+NULs and might not be terminated by a NUL.
+
+If you want to know if the scalar value is TRUE, you can use:
+
+ SvTRUE(SV*)
+
+Although Perl will automatically grow strings for you, if you need to force
+Perl to allocate more memory for your SV, you can use the macro
+
+ SvGROW(SV*, STRLEN newlen)
+
+which will determine if more memory needs to be allocated. If so, it will
+call the function C<sv_grow>. Note that C<SvGROW> can only increase, not
+decrease, the allocated memory of an SV and that it does not automatically
+add a byte for the a trailing NUL (perl's own string functions typically do
+C<SvGROW(sv, len + 1)>).
+
+If you have an SV and want to know what kind of data Perl thinks is stored
+in it, you can use the following macros to check the type of SV you have.
+
+ SvIOK(SV*)
+ SvNOK(SV*)
+ SvPOK(SV*)
+
+You can get and set the current length of the string stored in an SV with
+the following macros:
+
+ SvCUR(SV*)
+ SvCUR_set(SV*, I32 val)
+
+You can also get a pointer to the end of the string stored in the SV
+with the macro:
+
+ SvEND(SV*)
+
+But note that these last three macros are valid only if C<SvPOK()> is true.
+
+If you want to append something to the end of string stored in an C<SV*>,
+you can use the following functions:
+
+ void sv_catpv(SV*, char*);
+ void sv_catpvn(SV*, char*, int);
+ void sv_catpvf(SV*, const char*, ...);
+ void sv_catpvfn(SV*, const char*, STRLEN, va_list *, SV **, I32, bool);
+ void sv_catsv(SV*, SV*);
+
+The first function calculates the length of the string to be appended by
+using C<strlen>. In the second, you specify the length of the string
+yourself. The third function processes its arguments like C<sprintf> and
+appends the formatted output. The fourth function works like C<vsprintf>.
+You can specify the address and length of an array of SVs instead of the
+va_list argument. The fifth function extends the string stored in the first
+SV with the string stored in the second SV. It also forces the second SV
+to be interpreted as a string.
+
+The C<sv_cat*()> functions are not generic enough to operate on values that
+have "magic". See L<Magic Virtual Tables> later in this document.
+
+If you know the name of a scalar variable, you can get a pointer to its SV
+by using the following:
+
+ SV* perl_get_sv("package::varname", FALSE);
+
+This returns NULL if the variable does not exist.
+
+If you want to know if this variable (or any other SV) is actually C<defined>,
+you can call:
+
+ SvOK(SV*)
+
+The scalar C<undef> value is stored in an SV instance called C<PL_sv_undef>. Its
+address can be used whenever an C<SV*> is needed.
+
+There are also the two values C<PL_sv_yes> and C<PL_sv_no>, which contain Boolean
+TRUE and FALSE values, respectively. Like C<PL_sv_undef>, their addresses can
+be used whenever an C<SV*> is needed.
+
+Do not be fooled into thinking that C<(SV *) 0> is the same as C<&PL_sv_undef>.
+Take this code:
+
+ SV* sv = (SV*) 0;
+ if (I-am-to-return-a-real-value) {
+ sv = sv_2mortal(newSViv(42));
+ }
+ sv_setsv(ST(0), sv);
+
+This code tries to return a new SV (which contains the value 42) if it should
+return a real value, or undef otherwise. Instead it has returned a NULL
+pointer which, somewhere down the line, will cause a segmentation violation,
+bus error, or just weird results. Change the zero to C<&PL_sv_undef> in the first
+line and all will be well.
+
+To free an SV that you've created, call C<SvREFCNT_dec(SV*)>. Normally this
+call is not necessary (see L<Reference Counts and Mortality>).
+
+=head2 What's Really Stored in an SV?
+
+Recall that the usual method of determining the type of scalar you have is
+to use C<Sv*OK> macros. Because a scalar can be both a number and a string,
+usually these macros will always return TRUE and calling the C<Sv*V>
+macros will do the appropriate conversion of string to integer/double or
+integer/double to string.
+
+If you I<really> need to know if you have an integer, double, or string
+pointer in an SV, you can use the following three macros instead:
+
+ SvIOKp(SV*)
+ SvNOKp(SV*)
+ SvPOKp(SV*)
+
+These will tell you if you truly have an integer, double, or string pointer
+stored in your SV. The "p" stands for private.
+
+In general, though, it's best to use the C<Sv*V> macros.
+
+=head2 Working with AVs
+
+There are two ways to create and load an AV. The first method creates an
+empty AV:
+
+ AV* newAV();
+
+The second method both creates the AV and initially populates it with SVs:
+
+ AV* av_make(I32 num, SV **ptr);
+
+The second argument points to an array containing C<num> C<SV*>'s. Once the
+AV has been created, the SVs can be destroyed, if so desired.
+
+Once the AV has been created, the following operations are possible on AVs:
+
+ void av_push(AV*, SV*);
+ SV* av_pop(AV*);
+ SV* av_shift(AV*);
+ void av_unshift(AV*, I32 num);
+
+These should be familiar operations, with the exception of C<av_unshift>.
+This routine adds C<num> elements at the front of the array with the C<undef>
+value. You must then use C<av_store> (described below) to assign values
+to these new elements.
+
+Here are some other functions:
+
+ I32 av_len(AV*);
+ SV** av_fetch(AV*, I32 key, I32 lval);
+ SV** av_store(AV*, I32 key, SV* val);
+
+The C<av_len> function returns the highest index value in array (just
+like $#array in Perl). If the array is empty, -1 is returned. The
+C<av_fetch> function returns the value at index C<key>, but if C<lval>
+is non-zero, then C<av_fetch> will store an undef value at that index.
+The C<av_store> function stores the value C<val> at index C<key>, and does
+not increment the reference count of C<val>. Thus the caller is responsible
+for taking care of that, and if C<av_store> returns NULL, the caller will
+have to decrement the reference count to avoid a memory leak. Note that
+C<av_fetch> and C<av_store> both return C<SV**>'s, not C<SV*>'s as their
+return value.
+
+ void av_clear(AV*);
+ void av_undef(AV*);
+ void av_extend(AV*, I32 key);
+
+The C<av_clear> function deletes all the elements in the AV* array, but
+does not actually delete the array itself. The C<av_undef> function will
+delete all the elements in the array plus the array itself. The
+C<av_extend> function extends the array so that it contains C<key>
+elements. If C<key> is less than the current length of the array, then
+nothing is done.
+
+If you know the name of an array variable, you can get a pointer to its AV
+by using the following:
+
+ AV* perl_get_av("package::varname", FALSE);
+
+This returns NULL if the variable does not exist.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use the array access functions on tied arrays.
+
+=head2 Working with HVs
+
+To create an HV, you use the following routine:
+
+ HV* newHV();
+
+Once the HV has been created, the following operations are possible on HVs:
+
+ SV** hv_store(HV*, char* key, U32 klen, SV* val, U32 hash);
+ SV** hv_fetch(HV*, char* key, U32 klen, I32 lval);
+
+The C<klen> parameter is the length of the key being passed in (Note that
+you cannot pass 0 in as a value of C<klen> to tell Perl to measure the
+length of the key). The C<val> argument contains the SV pointer to the
+scalar being stored, and C<hash> is the precomputed hash value (zero if
+you want C<hv_store> to calculate it for you). The C<lval> parameter
+indicates whether this fetch is actually a part of a store operation, in
+which case a new undefined value will be added to the HV with the supplied
+key and C<hv_fetch> will return as if the value had already existed.
+
+Remember that C<hv_store> and C<hv_fetch> return C<SV**>'s and not just
+C<SV*>. To access the scalar value, you must first dereference the return
+value. However, you should check to make sure that the return value is
+not NULL before dereferencing it.
+
+These two functions check if a hash table entry exists, and deletes it.
+
+ bool hv_exists(HV*, char* key, U32 klen);
+ SV* hv_delete(HV*, char* key, U32 klen, I32 flags);
+
+If C<flags> does not include the C<G_DISCARD> flag then C<hv_delete> will
+create and return a mortal copy of the deleted value.
+
+And more miscellaneous functions:
+
+ void hv_clear(HV*);
+ void hv_undef(HV*);
+
+Like their AV counterparts, C<hv_clear> deletes all the entries in the hash
+table but does not actually delete the hash table. The C<hv_undef> deletes
+both the entries and the hash table itself.
+
+Perl keeps the actual data in linked list of structures with a typedef of HE.
+These contain the actual key and value pointers (plus extra administrative
+overhead). The key is a string pointer; the value is an C<SV*>. However,
+once you have an C<HE*>, to get the actual key and value, use the routines
+specified below.
+
+ I32 hv_iterinit(HV*);
+ /* Prepares starting point to traverse hash table */
+ HE* hv_iternext(HV*);
+ /* Get the next entry, and return a pointer to a
+ structure that has both the key and value */
+ char* hv_iterkey(HE* entry, I32* retlen);
+ /* Get the key from an HE structure and also return
+ the length of the key string */
+ SV* hv_iterval(HV*, HE* entry);
+ /* Return a SV pointer to the value of the HE
+ structure */
+ SV* hv_iternextsv(HV*, char** key, I32* retlen);
+ /* This convenience routine combines hv_iternext,
+ hv_iterkey, and hv_iterval. The key and retlen
+ arguments are return values for the key and its
+ length. The value is returned in the SV* argument */
+
+If you know the name of a hash variable, you can get a pointer to its HV
+by using the following:
+
+ HV* perl_get_hv("package::varname", FALSE);
+
+This returns NULL if the variable does not exist.
+
+The hash algorithm is defined in the C<PERL_HASH(hash, key, klen)> macro:
+
+ i = klen;
+ hash = 0;
+ s = key;
+ while (i--)
+ hash = hash * 33 + *s++;
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use the hash access functions on tied hashes.
+
+=head2 Hash API Extensions
+
+Beginning with version 5.004, the following functions are also supported:
+
+ HE* hv_fetch_ent (HV* tb, SV* key, I32 lval, U32 hash);
+ HE* hv_store_ent (HV* tb, SV* key, SV* val, U32 hash);
+
+ bool hv_exists_ent (HV* tb, SV* key, U32 hash);
+ SV* hv_delete_ent (HV* tb, SV* key, I32 flags, U32 hash);
+
+ SV* hv_iterkeysv (HE* entry);
+
+Note that these functions take C<SV*> keys, which simplifies writing
+of extension code that deals with hash structures. These functions
+also allow passing of C<SV*> keys to C<tie> functions without forcing
+you to stringify the keys (unlike the previous set of functions).
+
+They also return and accept whole hash entries (C<HE*>), making their
+use more efficient (since the hash number for a particular string
+doesn't have to be recomputed every time). See L<API LISTING> later in
+this document for detailed descriptions.
+
+The following macros must always be used to access the contents of hash
+entries. Note that the arguments to these macros must be simple
+variables, since they may get evaluated more than once. See
+L<API LISTING> later in this document for detailed descriptions of these
+macros.
+
+ HePV(HE* he, STRLEN len)
+ HeVAL(HE* he)
+ HeHASH(HE* he)
+ HeSVKEY(HE* he)
+ HeSVKEY_force(HE* he)
+ HeSVKEY_set(HE* he, SV* sv)
+
+These two lower level macros are defined, but must only be used when
+dealing with keys that are not C<SV*>s:
+
+ HeKEY(HE* he)
+ HeKLEN(HE* he)
+
+Note that both C<hv_store> and C<hv_store_ent> do not increment the
+reference count of the stored C<val>, which is the caller's responsibility.
+If these functions return a NULL value, the caller will usually have to
+decrement the reference count of C<val> to avoid a memory leak.
+
+=head2 References
+
+References are a special type of scalar that point to other data types
+(including references).
+
+To create a reference, use either of the following functions:
+
+ SV* newRV_inc((SV*) thing);
+ SV* newRV_noinc((SV*) thing);
+
+The C<thing> argument can be any of an C<SV*>, C<AV*>, or C<HV*>. The
+functions are identical except that C<newRV_inc> increments the reference
+count of the C<thing>, while C<newRV_noinc> does not. For historical
+reasons, C<newRV> is a synonym for C<newRV_inc>.
+
+Once you have a reference, you can use the following macro to dereference
+the reference:
+
+ SvRV(SV*)
+
+then call the appropriate routines, casting the returned C<SV*> to either an
+C<AV*> or C<HV*>, if required.
+
+To determine if an SV is a reference, you can use the following macro:
+
+ SvROK(SV*)
+
+To discover what type of value the reference refers to, use the following
+macro and then check the return value.
+
+ SvTYPE(SvRV(SV*))
+
+The most useful types that will be returned are:
+
+ SVt_IV Scalar
+ SVt_NV Scalar
+ SVt_PV Scalar
+ SVt_RV Scalar
+ SVt_PVAV Array
+ SVt_PVHV Hash
+ SVt_PVCV Code
+ SVt_PVGV Glob (possible a file handle)
+ SVt_PVMG Blessed or Magical Scalar
+
+ See the sv.h header file for more details.
+
+=head2 Blessed References and Class Objects
+
+References are also used to support object-oriented programming. In the
+OO lexicon, an object is simply a reference that has been blessed into a
+package (or class). Once blessed, the programmer may now use the reference
+to access the various methods in the class.
+
+A reference can be blessed into a package with the following function:
+
+ SV* sv_bless(SV* sv, HV* stash);
+
+The C<sv> argument must be a reference. The C<stash> argument specifies
+which class the reference will belong to. See
+L<Stashes and Globs> for information on converting class names into stashes.
+
+/* Still under construction */
+
+Upgrades rv to reference if not already one. Creates new SV for rv to
+point to. If C<classname> is non-null, the SV is blessed into the specified
+class. SV is returned.
+
+ SV* newSVrv(SV* rv, char* classname);
+
+Copies integer or double into an SV whose reference is C<rv>. SV is blessed
+if C<classname> is non-null.
+
+ SV* sv_setref_iv(SV* rv, char* classname, IV iv);
+ SV* sv_setref_nv(SV* rv, char* classname, NV iv);
+
+Copies the pointer value (I<the address, not the string!>) into an SV whose
+reference is rv. SV is blessed if C<classname> is non-null.
+
+ SV* sv_setref_pv(SV* rv, char* classname, PV iv);
+
+Copies string into an SV whose reference is C<rv>. Set length to 0 to let
+Perl calculate the string length. SV is blessed if C<classname> is non-null.
+
+ SV* sv_setref_pvn(SV* rv, char* classname, PV iv, int length);
+
+Tests whether the SV is blessed into the specified class. It does not
+check inheritance relationships.
+
+ int sv_isa(SV* sv, char* name);
+
+Tests whether the SV is a reference to a blessed object.
+
+ int sv_isobject(SV* sv);
+
+Tests whether the SV is derived from the specified class. SV can be either
+a reference to a blessed object or a string containing a class name. This
+is the function implementing the C<UNIVERSAL::isa> functionality.
+
+ bool sv_derived_from(SV* sv, char* name);
+
+To check if you've got an object derived from a specific class you have
+to write:
+
+ if (sv_isobject(sv) && sv_derived_from(sv, class)) { ... }
+
+=head2 Creating New Variables
+
+To create a new Perl variable with an undef value which can be accessed from
+your Perl script, use the following routines, depending on the variable type.
+
+ SV* perl_get_sv("package::varname", TRUE);
+ AV* perl_get_av("package::varname", TRUE);
+ HV* perl_get_hv("package::varname", TRUE);
+
+Notice the use of TRUE as the second parameter. The new variable can now
+be set, using the routines appropriate to the data type.
+
+There are additional macros whose values may be bitwise OR'ed with the
+C<TRUE> argument to enable certain extra features. Those bits are:
+
+ GV_ADDMULTI Marks the variable as multiply defined, thus preventing the
+ "Name <varname> used only once: possible typo" warning.
+ GV_ADDWARN Issues the warning "Had to create <varname> unexpectedly" if
+ the variable did not exist before the function was called.
+
+If you do not specify a package name, the variable is created in the current
+package.
+
+=head2 Reference Counts and Mortality
+
+Perl uses an reference count-driven garbage collection mechanism. SVs,
+AVs, or HVs (xV for short in the following) start their life with a
+reference count of 1. If the reference count of an xV ever drops to 0,
+then it will be destroyed and its memory made available for reuse.
+
+This normally doesn't happen at the Perl level unless a variable is
+undef'ed or the last variable holding a reference to it is changed or
+overwritten. At the internal level, however, reference counts can be
+manipulated with the following macros:
+
+ int SvREFCNT(SV* sv);
+ SV* SvREFCNT_inc(SV* sv);
+ void SvREFCNT_dec(SV* sv);
+
+However, there is one other function which manipulates the reference
+count of its argument. The C<newRV_inc> function, you will recall,
+creates a reference to the specified argument. As a side effect,
+it increments the argument's reference count. If this is not what
+you want, use C<newRV_noinc> instead.
+
+For example, imagine you want to return a reference from an XSUB function.
+Inside the XSUB routine, you create an SV which initially has a reference
+count of one. Then you call C<newRV_inc>, passing it the just-created SV.
+This returns the reference as a new SV, but the reference count of the
+SV you passed to C<newRV_inc> has been incremented to two. Now you
+return the reference from the XSUB routine and forget about the SV.
+But Perl hasn't! Whenever the returned reference is destroyed, the
+reference count of the original SV is decreased to one and nothing happens.
+The SV will hang around without any way to access it until Perl itself
+terminates. This is a memory leak.
+
+The correct procedure, then, is to use C<newRV_noinc> instead of
+C<newRV_inc>. Then, if and when the last reference is destroyed,
+the reference count of the SV will go to zero and it will be destroyed,
+stopping any memory leak.
+
+There are some convenience functions available that can help with the
+destruction of xVs. These functions introduce the concept of "mortality".
+An xV that is mortal has had its reference count marked to be decremented,
+but not actually decremented, until "a short time later". Generally the
+term "short time later" means a single Perl statement, such as a call to
+an XSUB function. The actual determinant for when mortal xVs have their
+reference count decremented depends on two macros, SAVETMPS and FREETMPS.
+See L<perlcall> and L<perlxs> for more details on these macros.
+
+"Mortalization" then is at its simplest a deferred C<SvREFCNT_dec>.
+However, if you mortalize a variable twice, the reference count will
+later be decremented twice.
+
+You should be careful about creating mortal variables. Strange things
+can happen if you make the same value mortal within multiple contexts,
+or if you make a variable mortal multiple times.
+
+To create a mortal variable, use the functions:
+
+ SV* sv_newmortal()
+ SV* sv_2mortal(SV*)
+ SV* sv_mortalcopy(SV*)
+
+The first call creates a mortal SV, the second converts an existing
+SV to a mortal SV (and thus defers a call to C<SvREFCNT_dec>), and the
+third creates a mortal copy of an existing SV.
+
+The mortal routines are not just for SVs -- AVs and HVs can be
+made mortal by passing their address (type-casted to C<SV*>) to the
+C<sv_2mortal> or C<sv_mortalcopy> routines.
+
+=head2 Stashes and Globs
+
+A "stash" is a hash that contains all of the different objects that
+are contained within a package. Each key of the stash is a symbol
+name (shared by all the different types of objects that have the same
+name), and each value in the hash table is a GV (Glob Value). This GV
+in turn contains references to the various objects of that name,
+including (but not limited to) the following:
+
+ Scalar Value
+ Array Value
+ Hash Value
+ I/O Handle
+ Format
+ Subroutine
+
+There is a single stash called "PL_defstash" that holds the items that exist
+in the "main" package. To get at the items in other packages, append the
+string "::" to the package name. The items in the "Foo" package are in
+the stash "Foo::" in PL_defstash. The items in the "Bar::Baz" package are
+in the stash "Baz::" in "Bar::"'s stash.
+
+To get the stash pointer for a particular package, use the function:
+
+ HV* gv_stashpv(char* name, I32 create)
+ HV* gv_stashsv(SV*, I32 create)
+
+The first function takes a literal string, the second uses the string stored
+in the SV. Remember that a stash is just a hash table, so you get back an
+C<HV*>. The C<create> flag will create a new package if it is set.
+
+The name that C<gv_stash*v> wants is the name of the package whose symbol table
+you want. The default package is called C<main>. If you have multiply nested
+packages, pass their names to C<gv_stash*v>, separated by C<::> as in the Perl
+language itself.
+
+Alternately, if you have an SV that is a blessed reference, you can find
+out the stash pointer by using:
+
+ HV* SvSTASH(SvRV(SV*));
+
+then use the following to get the package name itself:
+
+ char* HvNAME(HV* stash);
+
+If you need to bless or re-bless an object you can use the following
+function:
+
+ SV* sv_bless(SV*, HV* stash)
+
+where the first argument, an C<SV*>, must be a reference, and the second
+argument is a stash. The returned C<SV*> can now be used in the same way
+as any other SV.
+
+For more information on references and blessings, consult L<perlref>.
+
+=head2 Double-Typed SVs
+
+Scalar variables normally contain only one type of value, an integer,
+double, pointer, or reference. Perl will automatically convert the
+actual scalar data from the stored type into the requested type.
+
+Some scalar variables contain more than one type of scalar data. For
+example, the variable C<$!> contains either the numeric value of C<errno>
+or its string equivalent from either C<strerror> or C<sys_errlist[]>.
+
+To force multiple data values into an SV, you must do two things: use the
+C<sv_set*v> routines to add the additional scalar type, then set a flag
+so that Perl will believe it contains more than one type of data. The
+four macros to set the flags are:
+
+ SvIOK_on
+ SvNOK_on
+ SvPOK_on
+ SvROK_on
+
+The particular macro you must use depends on which C<sv_set*v> routine
+you called first. This is because every C<sv_set*v> routine turns on
+only the bit for the particular type of data being set, and turns off
+all the rest.
+
+For example, to create a new Perl variable called "dberror" that contains
+both the numeric and descriptive string error values, you could use the
+following code:
+
+ extern int dberror;
+ extern char *dberror_list;
+
+ SV* sv = perl_get_sv("dberror", TRUE);
+ sv_setiv(sv, (IV) dberror);
+ sv_setpv(sv, dberror_list[dberror]);
+ SvIOK_on(sv);
+
+If the order of C<sv_setiv> and C<sv_setpv> had been reversed, then the
+macro C<SvPOK_on> would need to be called instead of C<SvIOK_on>.
+
+=head2 Magic Variables
+
+[This section still under construction. Ignore everything here. Post no
+bills. Everything not permitted is forbidden.]
+
+Any SV may be magical, that is, it has special features that a normal
+SV does not have. These features are stored in the SV structure in a
+linked list of C<struct magic>'s, typedef'ed to C<MAGIC>.
+
+ struct magic {
+ MAGIC* mg_moremagic;
+ MGVTBL* mg_virtual;
+ U16 mg_private;
+ char mg_type;
+ U8 mg_flags;
+ SV* mg_obj;
+ char* mg_ptr;
+ I32 mg_len;
+ };
+
+Note this is current as of patchlevel 0, and could change at any time.
+
+=head2 Assigning Magic
+
+Perl adds magic to an SV using the sv_magic function:
+
+ void sv_magic(SV* sv, SV* obj, int how, char* name, I32 namlen);
+
+The C<sv> argument is a pointer to the SV that is to acquire a new magical
+feature.
+
+If C<sv> is not already magical, Perl uses the C<SvUPGRADE> macro to
+set the C<SVt_PVMG> flag for the C<sv>. Perl then continues by adding
+it to the beginning of the linked list of magical features. Any prior
+entry of the same type of magic is deleted. Note that this can be
+overridden, and multiple instances of the same type of magic can be
+associated with an SV.
+
+The C<name> and C<namlen> arguments are used to associate a string with
+the magic, typically the name of a variable. C<namlen> is stored in the
+C<mg_len> field and if C<name> is non-null and C<namlen> >= 0 a malloc'd
+copy of the name is stored in C<mg_ptr> field.
+
+The sv_magic function uses C<how> to determine which, if any, predefined
+"Magic Virtual Table" should be assigned to the C<mg_virtual> field.
+See the "Magic Virtual Table" section below. The C<how> argument is also
+stored in the C<mg_type> field.
+
+The C<obj> argument is stored in the C<mg_obj> field of the C<MAGIC>
+structure. If it is not the same as the C<sv> argument, the reference
+count of the C<obj> object is incremented. If it is the same, or if
+the C<how> argument is "#", or if it is a NULL pointer, then C<obj> is
+merely stored, without the reference count being incremented.
+
+There is also a function to add magic to an C<HV>:
+
+ void hv_magic(HV *hv, GV *gv, int how);
+
+This simply calls C<sv_magic> and coerces the C<gv> argument into an C<SV>.
+
+To remove the magic from an SV, call the function sv_unmagic:
+
+ void sv_unmagic(SV *sv, int type);
+
+The C<type> argument should be equal to the C<how> value when the C<SV>
+was initially made magical.
+
+=head2 Magic Virtual Tables
+
+The C<mg_virtual> field in the C<MAGIC> structure is a pointer to a
+C<MGVTBL>, which is a structure of function pointers and stands for
+"Magic Virtual Table" to handle the various operations that might be
+applied to that variable.
+
+The C<MGVTBL> has five pointers to the following routine types:
+
+ int (*svt_get)(SV* sv, MAGIC* mg);
+ int (*svt_set)(SV* sv, MAGIC* mg);
+ U32 (*svt_len)(SV* sv, MAGIC* mg);
+ int (*svt_clear)(SV* sv, MAGIC* mg);
+ int (*svt_free)(SV* sv, MAGIC* mg);
+
+This MGVTBL structure is set at compile-time in C<perl.h> and there are
+currently 19 types (or 21 with overloading turned on). These different
+structures contain pointers to various routines that perform additional
+actions depending on which function is being called.
+
+ Function pointer Action taken
+ ---------------- ------------
+ svt_get Do something after the value of the SV is retrieved.
+ svt_set Do something after the SV is assigned a value.
+ svt_len Report on the SV's length.
+ svt_clear Clear something the SV represents.
+ svt_free Free any extra storage associated with the SV.
+
+For instance, the MGVTBL structure called C<vtbl_sv> (which corresponds
+to an C<mg_type> of '\0') contains:
+
+ { magic_get, magic_set, magic_len, 0, 0 }
+
+Thus, when an SV is determined to be magical and of type '\0', if a get
+operation is being performed, the routine C<magic_get> is called. All
+the various routines for the various magical types begin with C<magic_>.
+
+The current kinds of Magic Virtual Tables are:
+
+ mg_type MGVTBL Type of magic
+ ------- ------ ----------------------------
+ \0 vtbl_sv Special scalar variable
+ A vtbl_amagic %OVERLOAD hash
+ a vtbl_amagicelem %OVERLOAD hash element
+ c (none) Holds overload table (AMT) on stash
+ B vtbl_bm Boyer-Moore (fast string search)
+ E vtbl_env %ENV hash
+ e vtbl_envelem %ENV hash element
+ f vtbl_fm Formline ('compiled' format)
+ g vtbl_mglob m//g target / study()ed string
+ I vtbl_isa @ISA array
+ i vtbl_isaelem @ISA array element
+ k vtbl_nkeys scalar(keys()) lvalue
+ L (none) Debugger %_<filename
+ l vtbl_dbline Debugger %_<filename element
+ o vtbl_collxfrm Locale transformation
+ P vtbl_pack Tied array or hash
+ p vtbl_packelem Tied array or hash element
+ q vtbl_packelem Tied scalar or handle
+ S vtbl_sig %SIG hash
+ s vtbl_sigelem %SIG hash element
+ t vtbl_taint Taintedness
+ U vtbl_uvar Available for use by extensions
+ v vtbl_vec vec() lvalue
+ x vtbl_substr substr() lvalue
+ y vtbl_defelem Shadow "foreach" iterator variable /
+ smart parameter vivification
+ * vtbl_glob GV (typeglob)
+ # vtbl_arylen Array length ($#ary)
+ . vtbl_pos pos() lvalue
+ ~ (none) Available for use by extensions
+
+When an uppercase and lowercase letter both exist in the table, then the
+uppercase letter is used to represent some kind of composite type (a list
+or a hash), and the lowercase letter is used to represent an element of
+that composite type.
+
+The '~' and 'U' magic types are defined specifically for use by
+extensions and will not be used by perl itself. Extensions can use
+'~' magic to 'attach' private information to variables (typically
+objects). This is especially useful because there is no way for
+normal perl code to corrupt this private information (unlike using
+extra elements of a hash object).
+
+Similarly, 'U' magic can be used much like tie() to call a C function
+any time a scalar's value is used or changed. The C<MAGIC>'s
+C<mg_ptr> field points to a C<ufuncs> structure:
+
+ struct ufuncs {
+ I32 (*uf_val)(IV, SV*);
+ I32 (*uf_set)(IV, SV*);
+ IV uf_index;
+ };
+
+When the SV is read from or written to, the C<uf_val> or C<uf_set>
+function will be called with C<uf_index> as the first arg and a
+pointer to the SV as the second.
+
+Note that because multiple extensions may be using '~' or 'U' magic,
+it is important for extensions to take extra care to avoid conflict.
+Typically only using the magic on objects blessed into the same class
+as the extension is sufficient. For '~' magic, it may also be
+appropriate to add an I32 'signature' at the top of the private data
+area and check that.
+
+Also note that the C<sv_set*()> and C<sv_cat*()> functions described
+earlier do B<not> invoke 'set' magic on their targets. This must
+be done by the user either by calling the C<SvSETMAGIC()> macro after
+calling these functions, or by using one of the C<sv_set*_mg()> or
+C<sv_cat*_mg()> functions. Similarly, generic C code must call the
+C<SvGETMAGIC()> macro to invoke any 'get' magic if they use an SV
+obtained from external sources in functions that don't handle magic.
+L<API LISTING> later in this document identifies such functions.
+For example, calls to the C<sv_cat*()> functions typically need to be
+followed by C<SvSETMAGIC()>, but they don't need a prior C<SvGETMAGIC()>
+since their implementation handles 'get' magic.
+
+=head2 Finding Magic
+
+ MAGIC* mg_find(SV*, int type); /* Finds the magic pointer of that type */
+
+This routine returns a pointer to the C<MAGIC> structure stored in the SV.
+If the SV does not have that magical feature, C<NULL> is returned. Also,
+if the SV is not of type SVt_PVMG, Perl may core dump.
+
+ int mg_copy(SV* sv, SV* nsv, char* key, STRLEN klen);
+
+This routine checks to see what types of magic C<sv> has. If the mg_type
+field is an uppercase letter, then the mg_obj is copied to C<nsv>, but
+the mg_type field is changed to be the lowercase letter.
+
+=head2 Understanding the Magic of Tied Hashes and Arrays
+
+Tied hashes and arrays are magical beasts of the 'P' magic type.
+
+WARNING: As of the 5.004 release, proper usage of the array and hash
+access functions requires understanding a few caveats. Some
+of these caveats are actually considered bugs in the API, to be fixed
+in later releases, and are bracketed with [MAYCHANGE] below. If
+you find yourself actually applying such information in this section, be
+aware that the behavior may change in the future, umm, without warning.
+
+The C<av_store> function, when given a tied array argument, merely
+copies the magic of the array onto the value to be "stored", using
+C<mg_copy>. It may also return NULL, indicating that the value did not
+actually need to be stored in the array. [MAYCHANGE] After a call to
+C<av_store> on a tied array, the caller will usually need to call
+C<mg_set(val)> to actually invoke the perl level "STORE" method on the
+TIEARRAY object. If C<av_store> did return NULL, a call to
+C<SvREFCNT_dec(val)> will also be usually necessary to avoid a memory
+leak. [/MAYCHANGE]
+
+The previous paragraph is applicable verbatim to tied hash access using the
+C<hv_store> and C<hv_store_ent> functions as well.
+
+C<av_fetch> and the corresponding hash functions C<hv_fetch> and
+C<hv_fetch_ent> actually return an undefined mortal value whose magic
+has been initialized using C<mg_copy>. Note the value so returned does not
+need to be deallocated, as it is already mortal. [MAYCHANGE] But you will
+need to call C<mg_get()> on the returned value in order to actually invoke
+the perl level "FETCH" method on the underlying TIE object. Similarly,
+you may also call C<mg_set()> on the return value after possibly assigning
+a suitable value to it using C<sv_setsv>, which will invoke the "STORE"
+method on the TIE object. [/MAYCHANGE]
+
+[MAYCHANGE]
+In other words, the array or hash fetch/store functions don't really
+fetch and store actual values in the case of tied arrays and hashes. They
+merely call C<mg_copy> to attach magic to the values that were meant to be
+"stored" or "fetched". Later calls to C<mg_get> and C<mg_set> actually
+do the job of invoking the TIE methods on the underlying objects. Thus
+the magic mechanism currently implements a kind of lazy access to arrays
+and hashes.
+
+Currently (as of perl version 5.004), use of the hash and array access
+functions requires the user to be aware of whether they are operating on
+"normal" hashes and arrays, or on their tied variants. The API may be
+changed to provide more transparent access to both tied and normal data
+types in future versions.
+[/MAYCHANGE]
+
+You would do well to understand that the TIEARRAY and TIEHASH interfaces
+are mere sugar to invoke some perl method calls while using the uniform hash
+and array syntax. The use of this sugar imposes some overhead (typically
+about two to four extra opcodes per FETCH/STORE operation, in addition to
+the creation of all the mortal variables required to invoke the methods).
+This overhead will be comparatively small if the TIE methods are themselves
+substantial, but if they are only a few statements long, the overhead
+will not be insignificant.
+
+=head2 Localizing changes
+
+Perl has a very handy construction
+
+ {
+ local $var = 2;
+ ...
+ }
+
+This construction is I<approximately> equivalent to
+
+ {
+ my $oldvar = $var;
+ $var = 2;
+ ...
+ $var = $oldvar;
+ }
+
+The biggest difference is that the first construction would
+reinstate the initial value of $var, irrespective of how control exits
+the block: C<goto>, C<return>, C<die>/C<eval> etc. It is a little bit
+more efficient as well.
+
+There is a way to achieve a similar task from C via Perl API: create a
+I<pseudo-block>, and arrange for some changes to be automatically
+undone at the end of it, either explicit, or via a non-local exit (via
+die()). A I<block>-like construct is created by a pair of
+C<ENTER>/C<LEAVE> macros (see L<perlcall/EXAMPLE/"Returning a
+Scalar">). Such a construct may be created specially for some
+important localized task, or an existing one (like boundaries of
+enclosing Perl subroutine/block, or an existing pair for freeing TMPs)
+may be used. (In the second case the overhead of additional
+localization must be almost negligible.) Note that any XSUB is
+automatically enclosed in an C<ENTER>/C<LEAVE> pair.
+
+Inside such a I<pseudo-block> the following service is available:
+
+=over
+
+=item C<SAVEINT(int i)>
+
+=item C<SAVEIV(IV i)>
+
+=item C<SAVEI32(I32 i)>
+
+=item C<SAVELONG(long i)>
+
+These macros arrange things to restore the value of integer variable
+C<i> at the end of enclosing I<pseudo-block>.
+
+=item C<SAVESPTR(s)>
+
+=item C<SAVEPPTR(p)>
+
+These macros arrange things to restore the value of pointers C<s> and
+C<p>. C<s> must be a pointer of a type which survives conversion to
+C<SV*> and back, C<p> should be able to survive conversion to C<char*>
+and back.
+
+=item C<SAVEFREESV(SV *sv)>
+
+The refcount of C<sv> would be decremented at the end of
+I<pseudo-block>. This is similar to C<sv_2mortal>, which should (?) be
+used instead.
+
+=item C<SAVEFREEOP(OP *op)>
+
+The C<OP *> is op_free()ed at the end of I<pseudo-block>.
+
+=item C<SAVEFREEPV(p)>
+
+The chunk of memory which is pointed to by C<p> is Safefree()ed at the
+end of I<pseudo-block>.
+
+=item C<SAVECLEARSV(SV *sv)>
+
+Clears a slot in the current scratchpad which corresponds to C<sv> at
+the end of I<pseudo-block>.
+
+=item C<SAVEDELETE(HV *hv, char *key, I32 length)>
+
+The key C<key> of C<hv> is deleted at the end of I<pseudo-block>. The
+string pointed to by C<key> is Safefree()ed. If one has a I<key> in
+short-lived storage, the corresponding string may be reallocated like
+this:
+
+ SAVEDELETE(PL_defstash, savepv(tmpbuf), strlen(tmpbuf));
+
+=item C<SAVEDESTRUCTOR(f,p)>
+
+At the end of I<pseudo-block> the function C<f> is called with the
+only argument (of type C<void*>) C<p>.
+
+=item C<SAVESTACK_POS()>
+
+The current offset on the Perl internal stack (cf. C<SP>) is restored
+at the end of I<pseudo-block>.
+
+=back
+
+The following API list contains functions, thus one needs to
+provide pointers to the modifiable data explicitly (either C pointers,
+or Perlish C<GV *>s). Where the above macros take C<int>, a similar
+function takes C<int *>.
+
+=over
+
+=item C<SV* save_scalar(GV *gv)>
+
+Equivalent to Perl code C<local $gv>.
+
+=item C<AV* save_ary(GV *gv)>
+
+=item C<HV* save_hash(GV *gv)>
+
+Similar to C<save_scalar>, but localize C<@gv> and C<%gv>.
+
+=item C<void save_item(SV *item)>
+
+Duplicates the current value of C<SV>, on the exit from the current
+C<ENTER>/C<LEAVE> I<pseudo-block> will restore the value of C<SV>
+using the stored value.
+
+=item C<void save_list(SV **sarg, I32 maxsarg)>
+
+A variant of C<save_item> which takes multiple arguments via an array
+C<sarg> of C<SV*> of length C<maxsarg>.
+
+=item C<SV* save_svref(SV **sptr)>
+
+Similar to C<save_scalar>, but will reinstate a C<SV *>.
+
+=item C<void save_aptr(AV **aptr)>
+
+=item C<void save_hptr(HV **hptr)>
+
+Similar to C<save_svref>, but localize C<AV *> and C<HV *>.
+
+=back
+
+The C<Alias> module implements localization of the basic types within the
+I<caller's scope>. People who are interested in how to localize things in
+the containing scope should take a look there too.
+
+=head1 Subroutines
+
+=head2 XSUBs and the Argument Stack
+
+The XSUB mechanism is a simple way for Perl programs to access C subroutines.
+An XSUB routine will have a stack that contains the arguments from the Perl
+program, and a way to map from the Perl data structures to a C equivalent.
+
+The stack arguments are accessible through the C<ST(n)> macro, which returns
+the C<n>'th stack argument. Argument 0 is the first argument passed in the
+Perl subroutine call. These arguments are C<SV*>, and can be used anywhere
+an C<SV*> is used.
+
+Most of the time, output from the C routine can be handled through use of
+the RETVAL and OUTPUT directives. However, there are some cases where the
+argument stack is not already long enough to handle all the return values.
+An example is the POSIX tzname() call, which takes no arguments, but returns
+two, the local time zone's standard and summer time abbreviations.
+
+To handle this situation, the PPCODE directive is used and the stack is
+extended using the macro:
+
+ EXTEND(SP, num);
+
+where C<SP> is the macro that represents the local copy of the stack pointer,
+and C<num> is the number of elements the stack should be extended by.
+
+Now that there is room on the stack, values can be pushed on it using the
+macros to push IVs, doubles, strings, and SV pointers respectively:
+
+ PUSHi(IV)
+ PUSHn(double)
+ PUSHp(char*, I32)
+ PUSHs(SV*)
+
+And now the Perl program calling C<tzname>, the two values will be assigned
+as in:
+
+ ($standard_abbrev, $summer_abbrev) = POSIX::tzname;
+
+An alternate (and possibly simpler) method to pushing values on the stack is
+to use the macros:
+
+ XPUSHi(IV)
+ XPUSHn(double)
+ XPUSHp(char*, I32)
+ XPUSHs(SV*)
+
+These macros automatically adjust the stack for you, if needed. Thus, you
+do not need to call C<EXTEND> to extend the stack.
+
+For more information, consult L<perlxs> and L<perlxstut>.
+
+=head2 Calling Perl Routines from within C Programs
+
+There are four routines that can be used to call a Perl subroutine from
+within a C program. These four are:
+
+ I32 perl_call_sv(SV*, I32);
+ I32 perl_call_pv(char*, I32);
+ I32 perl_call_method(char*, I32);
+ I32 perl_call_argv(char*, I32, register char**);
+
+The routine most often used is C<perl_call_sv>. The C<SV*> argument
+contains either the name of the Perl subroutine to be called, or a
+reference to the subroutine. The second argument consists of flags
+that control the context in which the subroutine is called, whether
+or not the subroutine is being passed arguments, how errors should be
+trapped, and how to treat return values.
+
+All four routines return the number of arguments that the subroutine returned
+on the Perl stack.
+
+When using any of these routines (except C<perl_call_argv>), the programmer
+must manipulate the Perl stack. These include the following macros and
+functions:
+
+ dSP
+ SP
+ PUSHMARK()
+ PUTBACK
+ SPAGAIN
+ ENTER
+ SAVETMPS
+ FREETMPS
+ LEAVE
+ XPUSH*()
+ POP*()
+
+For a detailed description of calling conventions from C to Perl,
+consult L<perlcall>.
+
+=head2 Memory Allocation
+
+It is suggested that you use the version of malloc that is distributed
+with Perl. It keeps pools of various sizes of unallocated memory in
+order to satisfy allocation requests more quickly. However, on some
+platforms, it may cause spurious malloc or free errors.
+
+ New(x, pointer, number, type);
+ Newc(x, pointer, number, type, cast);
+ Newz(x, pointer, number, type);
+
+These three macros are used to initially allocate memory.
+
+The first argument C<x> was a "magic cookie" that was used to keep track
+of who called the macro, to help when debugging memory problems. However,
+the current code makes no use of this feature (most Perl developers now
+use run-time memory checkers), so this argument can be any number.
+
+The second argument C<pointer> should be the name of a variable that will
+point to the newly allocated memory.
+
+The third and fourth arguments C<number> and C<type> specify how many of
+the specified type of data structure should be allocated. The argument
+C<type> is passed to C<sizeof>. The final argument to C<Newc>, C<cast>,
+should be used if the C<pointer> argument is different from the C<type>
+argument.
+
+Unlike the C<New> and C<Newc> macros, the C<Newz> macro calls C<memzero>
+to zero out all the newly allocated memory.
+
+ Renew(pointer, number, type);
+ Renewc(pointer, number, type, cast);
+ Safefree(pointer)
+
+These three macros are used to change a memory buffer size or to free a
+piece of memory no longer needed. The arguments to C<Renew> and C<Renewc>
+match those of C<New> and C<Newc> with the exception of not needing the
+"magic cookie" argument.
+
+ Move(source, dest, number, type);
+ Copy(source, dest, number, type);
+ Zero(dest, number, type);
+
+These three macros are used to move, copy, or zero out previously allocated
+memory. The C<source> and C<dest> arguments point to the source and
+destination starting points. Perl will move, copy, or zero out C<number>
+instances of the size of the C<type> data structure (using the C<sizeof>
+function).
+
+=head2 PerlIO
+
+The most recent development releases of Perl has been experimenting with
+removing Perl's dependency on the "normal" standard I/O suite and allowing
+other stdio implementations to be used. This involves creating a new
+abstraction layer that then calls whichever implementation of stdio Perl
+was compiled with. All XSUBs should now use the functions in the PerlIO
+abstraction layer and not make any assumptions about what kind of stdio
+is being used.
+
+For a complete description of the PerlIO abstraction, consult L<perlapio>.
+
+=head2 Putting a C value on Perl stack
+
+A lot of opcodes (this is an elementary operation in the internal perl
+stack machine) put an SV* on the stack. However, as an optimization
+the corresponding SV is (usually) not recreated each time. The opcodes
+reuse specially assigned SVs (I<target>s) which are (as a corollary)
+not constantly freed/created.
+
+Each of the targets is created only once (but see
+L<Scratchpads and recursion> below), and when an opcode needs to put
+an integer, a double, or a string on stack, it just sets the
+corresponding parts of its I<target> and puts the I<target> on stack.
+
+The macro to put this target on stack is C<PUSHTARG>, and it is
+directly used in some opcodes, as well as indirectly in zillions of
+others, which use it via C<(X)PUSH[pni]>.
+
+=head2 Scratchpads
+
+The question remains on when the SVs which are I<target>s for opcodes
+are created. The answer is that they are created when the current unit --
+a subroutine or a file (for opcodes for statements outside of
+subroutines) -- is compiled. During this time a special anonymous Perl
+array is created, which is called a scratchpad for the current
+unit.
+
+A scratchpad keeps SVs which are lexicals for the current unit and are
+targets for opcodes. One can deduce that an SV lives on a scratchpad
+by looking on its flags: lexicals have C<SVs_PADMY> set, and
+I<target>s have C<SVs_PADTMP> set.
+
+The correspondence between OPs and I<target>s is not 1-to-1. Different
+OPs in the compile tree of the unit can use the same target, if this
+would not conflict with the expected life of the temporary.
+
+=head2 Scratchpads and recursion
+
+In fact it is not 100% true that a compiled unit contains a pointer to
+the scratchpad AV. In fact it contains a pointer to an AV of
+(initially) one element, and this element is the scratchpad AV. Why do
+we need an extra level of indirection?
+
+The answer is B<recursion>, and maybe (sometime soon) B<threads>. Both
+these can create several execution pointers going into the same
+subroutine. For the subroutine-child not write over the temporaries
+for the subroutine-parent (lifespan of which covers the call to the
+child), the parent and the child should have different
+scratchpads. (I<And> the lexicals should be separate anyway!)
+
+So each subroutine is born with an array of scratchpads (of length 1).
+On each entry to the subroutine it is checked that the current
+depth of the recursion is not more than the length of this array, and
+if it is, new scratchpad is created and pushed into the array.
+
+The I<target>s on this scratchpad are C<undef>s, but they are already
+marked with correct flags.
+
+=head1 Compiled code
+
+=head2 Code tree
+
+Here we describe the internal form your code is converted to by
+Perl. Start with a simple example:
+
+ $a = $b + $c;
+
+This is converted to a tree similar to this one:
+
+ assign-to
+ / \
+ + $a
+ / \
+ $b $c
+
+(but slightly more complicated). This tree reflects the way Perl
+parsed your code, but has nothing to do with the execution order.
+There is an additional "thread" going through the nodes of the tree
+which shows the order of execution of the nodes. In our simplified
+example above it looks like:
+
+ $b ---> $c ---> + ---> $a ---> assign-to
+
+But with the actual compile tree for C<$a = $b + $c> it is different:
+some nodes I<optimized away>. As a corollary, though the actual tree
+contains more nodes than our simplified example, the execution order
+is the same as in our example.
+
+=head2 Examining the tree
+
+If you have your perl compiled for debugging (usually done with C<-D
+optimize=-g> on C<Configure> command line), you may examine the
+compiled tree by specifying C<-Dx> on the Perl command line. The
+output takes several lines per node, and for C<$b+$c> it looks like
+this:
+
+ 5 TYPE = add ===> 6
+ TARG = 1
+ FLAGS = (SCALAR,KIDS)
+ {
+ TYPE = null ===> (4)
+ (was rv2sv)
+ FLAGS = (SCALAR,KIDS)
+ {
+ 3 TYPE = gvsv ===> 4
+ FLAGS = (SCALAR)
+ GV = main::b
+ }
+ }
+ {
+ TYPE = null ===> (5)
+ (was rv2sv)
+ FLAGS = (SCALAR,KIDS)
+ {
+ 4 TYPE = gvsv ===> 5
+ FLAGS = (SCALAR)
+ GV = main::c
+ }
+ }
+
+This tree has 5 nodes (one per C<TYPE> specifier), only 3 of them are
+not optimized away (one per number in the left column). The immediate
+children of the given node correspond to C<{}> pairs on the same level
+of indentation, thus this listing corresponds to the tree:
+
+ add
+ / \
+ null null
+ | |
+ gvsv gvsv
+
+The execution order is indicated by C<===E<gt>> marks, thus it is C<3
+4 5 6> (node C<6> is not included into above listing), i.e.,
+C<gvsv gvsv add whatever>.
+
+=head2 Compile pass 1: check routines
+
+The tree is created by the I<pseudo-compiler> while yacc code feeds it
+the constructions it recognizes. Since yacc works bottom-up, so does
+the first pass of perl compilation.
+
+What makes this pass interesting for perl developers is that some
+optimization may be performed on this pass. This is optimization by
+so-called I<check routines>. The correspondence between node names
+and corresponding check routines is described in F<opcode.pl> (do not
+forget to run C<make regen_headers> if you modify this file).
+
+A check routine is called when the node is fully constructed except
+for the execution-order thread. Since at this time there are no
+back-links to the currently constructed node, one can do most any
+operation to the top-level node, including freeing it and/or creating
+new nodes above/below it.
+
+The check routine returns the node which should be inserted into the
+tree (if the top-level node was not modified, check routine returns
+its argument).
+
+By convention, check routines have names C<ck_*>. They are usually
+called from C<new*OP> subroutines (or C<convert>) (which in turn are
+called from F<perly.y>).
+
+=head2 Compile pass 1a: constant folding
+
+Immediately after the check routine is called the returned node is
+checked for being compile-time executable. If it is (the value is
+judged to be constant) it is immediately executed, and a I<constant>
+node with the "return value" of the corresponding subtree is
+substituted instead. The subtree is deleted.
+
+If constant folding was not performed, the execution-order thread is
+created.
+
+=head2 Compile pass 2: context propagation
+
+When a context for a part of compile tree is known, it is propagated
+down through the tree. At this time the context can have 5 values
+(instead of 2 for runtime context): void, boolean, scalar, list, and
+lvalue. In contrast with the pass 1 this pass is processed from top
+to bottom: a node's context determines the context for its children.
+
+Additional context-dependent optimizations are performed at this time.
+Since at this moment the compile tree contains back-references (via
+"thread" pointers), nodes cannot be free()d now. To allow
+optimized-away nodes at this stage, such nodes are null()ified instead
+of free()ing (i.e. their type is changed to OP_NULL).
+
+=head2 Compile pass 3: peephole optimization
+
+After the compile tree for a subroutine (or for an C<eval> or a file)
+is created, an additional pass over the code is performed. This pass
+is neither top-down or bottom-up, but in the execution order (with
+additional complications for conditionals). These optimizations are
+done in the subroutine peep(). Optimizations performed at this stage
+are subject to the same restrictions as in the pass 2.
+
+=head1 API LISTING
+
+This is a listing of functions, macros, flags, and variables that may be
+useful to extension writers or that may be found while reading other
+extensions.
+
+Note that all Perl API global variables must be referenced with the C<PL_>
+prefix. Some macros are provided for compatibility with the older,
+unadorned names, but this support will be removed in a future release.
+
+It is strongly recommended that all Perl API functions that don't begin
+with C<perl> be referenced with an explicit C<Perl_> prefix.
+
+The sort order of the listing is case insensitive, with any
+occurrences of '_' ignored for the the purpose of sorting.
+
+=over 8
+
+=item av_clear
+
+Clears an array, making it empty. Does not free the memory used by the
+array itself.
+
+ void av_clear (AV* ar)
+
+=item av_extend
+
+Pre-extend an array. The C<key> is the index to which the array should be
+extended.
+
+ void av_extend (AV* ar, I32 key)
+
+=item av_fetch
+
+Returns the SV at the specified index in the array. The C<key> is the
+index. If C<lval> is set then the fetch will be part of a store. Check
+that the return value is non-null before dereferencing it to a C<SV*>.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied arrays.
+
+ SV** av_fetch (AV* ar, I32 key, I32 lval)
+
+=item AvFILL
+
+Same as C<av_len()>. Deprecated, use C<av_len()> instead.
+
+=item av_len
+
+Returns the highest index in the array. Returns -1 if the array is empty.
+
+ I32 av_len (AV* ar)
+
+=item av_make
+
+Creates a new AV and populates it with a list of SVs. The SVs are copied
+into the array, so they may be freed after the call to av_make. The new AV
+will have a reference count of 1.
+
+ AV* av_make (I32 size, SV** svp)
+
+=item av_pop
+
+Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array is
+empty.
+
+ SV* av_pop (AV* ar)
+
+=item av_push
+
+Pushes an SV onto the end of the array. The array will grow automatically
+to accommodate the addition.
+
+ void av_push (AV* ar, SV* val)
+
+=item av_shift
+
+Shifts an SV off the beginning of the array.
+
+ SV* av_shift (AV* ar)
+
+=item av_store
+
+Stores an SV in an array. The array index is specified as C<key>. The
+return value will be NULL if the operation failed or if the value did not
+need to be actually stored within the array (as in the case of tied arrays).
+Otherwise it can be dereferenced to get the original C<SV*>. Note that the
+caller is responsible for suitably incrementing the reference count of C<val>
+before the call, and decrementing it if the function returned NULL.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied arrays.
+
+ SV** av_store (AV* ar, I32 key, SV* val)
+
+=item av_undef
+
+Undefines the array. Frees the memory used by the array itself.
+
+ void av_undef (AV* ar)
+
+=item av_unshift
+
+Unshift the given number of C<undef> values onto the beginning of the
+array. The array will grow automatically to accommodate the addition.
+You must then use C<av_store> to assign values to these new elements.
+
+ void av_unshift (AV* ar, I32 num)
+
+=item CLASS
+
+Variable which is setup by C<xsubpp> to indicate the class name for a C++ XS
+constructor. This is always a C<char*>. See C<THIS> and
+L<perlxs/"Using XS With C++">.
+
+=item Copy
+
+The XSUB-writer's interface to the C C<memcpy> function. The C<s> is the
+source, C<d> is the destination, C<n> is the number of items, and C<t> is
+the type. May fail on overlapping copies. See also C<Move>.
+
+ void Copy( s, d, n, t )
+
+=item croak
+
+This is the XSUB-writer's interface to Perl's C<die> function. Use this
+function the same way you use the C C<printf> function. See C<warn>.
+
+=item CvSTASH
+
+Returns the stash of the CV.
+
+ HV* CvSTASH( SV* sv )
+
+=item PL_DBsingle
+
+When Perl is run in debugging mode, with the B<-d> switch, this SV is a
+boolean which indicates whether subs are being single-stepped.
+Single-stepping is automatically turned on after every step. This is the C
+variable which corresponds to Perl's $DB::single variable. See C<PL_DBsub>.
+
+=item PL_DBsub
+
+When Perl is run in debugging mode, with the B<-d> switch, this GV contains
+the SV which holds the name of the sub being debugged. This is the C
+variable which corresponds to Perl's $DB::sub variable. See C<PL_DBsingle>.
+The sub name can be found by
+
+ SvPV( GvSV( PL_DBsub ), PL_na )
+
+=item PL_DBtrace
+
+Trace variable used when Perl is run in debugging mode, with the B<-d>
+switch. This is the C variable which corresponds to Perl's $DB::trace
+variable. See C<PL_DBsingle>.
+
+=item dMARK
+
+Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
+C<dORIGMARK>.
+
+=item dORIGMARK
+
+Saves the original stack mark for the XSUB. See C<ORIGMARK>.
+
+=item PL_dowarn
+
+The C variable which corresponds to Perl's $^W warning variable.
+
+=item dSP
+
+Declares a local copy of perl's stack pointer for the XSUB, available via
+the C<SP> macro. See C<SP>.
+
+=item dXSARGS
+
+Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. This is
+usually handled automatically by C<xsubpp>. Declares the C<items> variable
+to indicate the number of items on the stack.
+
+=item dXSI32
+
+Sets up the C<ix> variable for an XSUB which has aliases. This is usually
+handled automatically by C<xsubpp>.
+
+=item do_binmode
+
+Switches filehandle to binmode. C<iotype> is what C<IoTYPE(io)> would
+contain.
+
+ do_binmode(fp, iotype, TRUE);
+
+=item ENTER
+
+Opening bracket on a callback. See C<LEAVE> and L<perlcall>.
+
+ ENTER;
+
+=item EXTEND
+
+Used to extend the argument stack for an XSUB's return values.
+
+ EXTEND( sp, int x )
+
+=item fbm_compile
+
+Analyses the string in order to make fast searches on it using fbm_instr() --
+the Boyer-Moore algorithm.
+
+ void fbm_compile(SV* sv, U32 flags)
+
+=item fbm_instr
+
+Returns the location of the SV in the string delimited by C<str> and
+C<strend>. It returns C<Nullch> if the string can't be found. The
+C<sv> does not have to be fbm_compiled, but the search will not be as
+fast then.
+
+ char* fbm_instr(char *str, char *strend, SV *sv, U32 flags)
+
+=item FREETMPS
+
+Closing bracket for temporaries on a callback. See C<SAVETMPS> and
+L<perlcall>.
+
+ FREETMPS;
+
+=item G_ARRAY
+
+Used to indicate array context. See C<GIMME_V>, C<GIMME> and L<perlcall>.
+
+=item G_DISCARD
+
+Indicates that arguments returned from a callback should be discarded. See
+L<perlcall>.
+
+=item G_EVAL
+
+Used to force a Perl C<eval> wrapper around a callback. See L<perlcall>.
+
+=item GIMME
+
+A backward-compatible version of C<GIMME_V> which can only return
+C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.
+
+=item GIMME_V
+
+The XSUB-writer's equivalent to Perl's C<wantarray>. Returns
+C<G_VOID>, C<G_SCALAR> or C<G_ARRAY> for void, scalar or array
+context, respectively.
+
+=item G_NOARGS
+
+Indicates that no arguments are being sent to a callback. See L<perlcall>.
+
+=item G_SCALAR
+
+Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and L<perlcall>.
+
+=item gv_fetchmeth
+
+Returns the glob with the given C<name> and a defined subroutine or
+C<NULL>. The glob lives in the given C<stash>, or in the stashes
+accessible via @ISA and @UNIVERSAL.
+
+The argument C<level> should be either 0 or -1. If C<level==0>, as a
+side-effect creates a glob with the given C<name> in the given
+C<stash> which in the case of success contains an alias for the
+subroutine, and sets up caching info for this glob. Similarly for all
+the searched stashes.
+
+This function grants C<"SUPER"> token as a postfix of the stash name.
+
+The GV returned from C<gv_fetchmeth> may be a method cache entry,
+which is not visible to Perl code. So when calling C<perl_call_sv>,
+you should not use the GV directly; instead, you should use the
+method's CV, which can be obtained from the GV with the C<GvCV> macro.
+
+ GV* gv_fetchmeth (HV* stash, char* name, STRLEN len, I32 level)
+
+=item gv_fetchmethod
+
+=item gv_fetchmethod_autoload
+
+Returns the glob which contains the subroutine to call to invoke the
+method on the C<stash>. In fact in the presense of autoloading this may
+be the glob for "AUTOLOAD". In this case the corresponding variable
+$AUTOLOAD is already setup.
+
+The third parameter of C<gv_fetchmethod_autoload> determines whether AUTOLOAD
+lookup is performed if the given method is not present: non-zero means
+yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. Calling
+C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload> with a
+non-zero C<autoload> parameter.
+
+These functions grant C<"SUPER"> token as a prefix of the method name.
+
+Note that if you want to keep the returned glob for a long time, you
+need to check for it being "AUTOLOAD", since at the later time the call
+may load a different subroutine due to $AUTOLOAD changing its value.
+Use the glob created via a side effect to do this.
+
+These functions have the same side-effects and as C<gv_fetchmeth> with
+C<level==0>. C<name> should be writable if contains C<':'> or C<'\''>.
+The warning against passing the GV returned by C<gv_fetchmeth> to
+C<perl_call_sv> apply equally to these functions.
+
+ GV* gv_fetchmethod (HV* stash, char* name)
+ GV* gv_fetchmethod_autoload (HV* stash, char* name, I32 autoload)
+
+=item G_VOID
+
+Used to indicate void context. See C<GIMME_V> and L<perlcall>.
+
+=item gv_stashpv
+
+Returns a pointer to the stash for a specified package. If C<create> is set
+then the package will be created if it does not already exist. If C<create>
+is not set and the package does not exist then NULL is returned.
+
+ HV* gv_stashpv (char* name, I32 create)
+
+=item gv_stashsv
+
+Returns a pointer to the stash for a specified package. See C<gv_stashpv>.
+
+ HV* gv_stashsv (SV* sv, I32 create)
+
+=item GvSV
+
+Return the SV from the GV.
+
+=item HEf_SVKEY
+
+This flag, used in the length slot of hash entries and magic
+structures, specifies the structure contains a C<SV*> pointer where a
+C<char*> pointer is to be expected. (For information only--not to be used).
+
+=item HeHASH
+
+Returns the computed hash stored in the hash entry.
+
+ U32 HeHASH(HE* he)
+
+=item HeKEY
+
+Returns the actual pointer stored in the key slot of the hash entry.
+The pointer may be either C<char*> or C<SV*>, depending on the value of
+C<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros
+are usually preferable for finding the value of a key.
+
+ char* HeKEY(HE* he)
+
+=item HeKLEN
+
+If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry
+holds an C<SV*> key. Otherwise, holds the actual length of the key.
+Can be assigned to. The C<HePV()> macro is usually preferable for finding
+key lengths.
+
+ int HeKLEN(HE* he)
+
+=item HePV
+
+Returns the key slot of the hash entry as a C<char*> value, doing any
+necessary dereferencing of possibly C<SV*> keys. The length of
+the string is placed in C<len> (this is a macro, so do I<not> use
+C<&len>). If you do not care about what the length of the key is,
+you may use the global variable C<PL_na>. Remember though, that hash
+keys in perl are free to contain embedded nulls, so using C<strlen()>
+or similar is not a good way to find the length of hash keys.
+This is very similar to the C<SvPV()> macro described elsewhere in
+this document.
+
+ char* HePV(HE* he, STRLEN len)
+
+=item HeSVKEY
+
+Returns the key as an C<SV*>, or C<Nullsv> if the hash entry
+does not contain an C<SV*> key.
+
+ HeSVKEY(HE* he)
+
+=item HeSVKEY_force
+
+Returns the key as an C<SV*>. Will create and return a temporary
+mortal C<SV*> if the hash entry contains only a C<char*> key.
+
+ HeSVKEY_force(HE* he)
+
+=item HeSVKEY_set
+
+Sets the key to a given C<SV*>, taking care to set the appropriate flags
+to indicate the presence of an C<SV*> key, and returns the same C<SV*>.
+
+ HeSVKEY_set(HE* he, SV* sv)
+
+=item HeVAL
+
+Returns the value slot (type C<SV*>) stored in the hash entry.
+
+ HeVAL(HE* he)
+
+=item hv_clear
+
+Clears a hash, making it empty.
+
+ void hv_clear (HV* tb)
+
+=item hv_delayfree_ent
+
+Releases a hash entry, such as while iterating though the hash, but
+delays actual freeing of key and value until the end of the current
+statement (or thereabouts) with C<sv_2mortal>. See C<hv_iternext>
+and C<hv_free_ent>.
+
+ void hv_delayfree_ent (HV* hv, HE* entry)
+
+=item hv_delete
+
+Deletes a key/value pair in the hash. The value SV is removed from the hash
+and returned to the caller. The C<klen> is the length of the key. The
+C<flags> value will normally be zero; if set to G_DISCARD then NULL will be
+returned.
+
+ SV* hv_delete (HV* tb, char* key, U32 klen, I32 flags)
+
+=item hv_delete_ent
+
+Deletes a key/value pair in the hash. The value SV is removed from the hash
+and returned to the caller. The C<flags> value will normally be zero; if set
+to G_DISCARD then NULL will be returned. C<hash> can be a valid precomputed
+hash value, or 0 to ask for it to be computed.
+
+ SV* hv_delete_ent (HV* tb, SV* key, I32 flags, U32 hash)
+
+=item hv_exists
+
+Returns a boolean indicating whether the specified hash key exists. The
+C<klen> is the length of the key.
+
+ bool hv_exists (HV* tb, char* key, U32 klen)
+
+=item hv_exists_ent
+
+Returns a boolean indicating whether the specified hash key exists. C<hash>
+can be a valid precomputed hash value, or 0 to ask for it to be computed.
+
+ bool hv_exists_ent (HV* tb, SV* key, U32 hash)
+
+=item hv_fetch
+
+Returns the SV which corresponds to the specified key in the hash. The
+C<klen> is the length of the key. If C<lval> is set then the fetch will be
+part of a store. Check that the return value is non-null before
+dereferencing it to a C<SV*>.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied hashes.
+
+ SV** hv_fetch (HV* tb, char* key, U32 klen, I32 lval)
+
+=item hv_fetch_ent
+
+Returns the hash entry which corresponds to the specified key in the hash.
+C<hash> must be a valid precomputed hash number for the given C<key>, or
+0 if you want the function to compute it. IF C<lval> is set then the
+fetch will be part of a store. Make sure the return value is non-null
+before accessing it. The return value when C<tb> is a tied hash
+is a pointer to a static location, so be sure to make a copy of the
+structure if you need to store it somewhere.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied hashes.
+
+ HE* hv_fetch_ent (HV* tb, SV* key, I32 lval, U32 hash)
+
+=item hv_free_ent
+
+Releases a hash entry, such as while iterating though the hash. See
+C<hv_iternext> and C<hv_delayfree_ent>.
+
+ void hv_free_ent (HV* hv, HE* entry)
+
+=item hv_iterinit
+
+Prepares a starting point to traverse a hash table.
+
+ I32 hv_iterinit (HV* tb)
+
+Returns the number of keys in the hash (i.e. the same as C<HvKEYS(tb)>).
+The return value is currently only meaningful for hashes without tie
+magic.
+
+NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number
+of hash buckets that happen to be in use. If you still need that
+esoteric value, you can get it through the macro C<HvFILL(tb)>.
+
+=item hv_iterkey
+
+Returns the key from the current position of the hash iterator. See
+C<hv_iterinit>.
+
+ char* hv_iterkey (HE* entry, I32* retlen)
+
+=item hv_iterkeysv
+
+Returns the key as an C<SV*> from the current position of the hash
+iterator. The return value will always be a mortal copy of the
+key. Also see C<hv_iterinit>.
+
+ SV* hv_iterkeysv (HE* entry)
+
+=item hv_iternext
+
+Returns entries from a hash iterator. See C<hv_iterinit>.
+
+ HE* hv_iternext (HV* tb)
+
+=item hv_iternextsv
+
+Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one
+operation.
+
+ SV* hv_iternextsv (HV* hv, char** key, I32* retlen)
+
+=item hv_iterval
+
+Returns the value from the current position of the hash iterator. See
+C<hv_iterkey>.
+
+ SV* hv_iterval (HV* tb, HE* entry)
+
+=item hv_magic
+
+Adds magic to a hash. See C<sv_magic>.
+
+ void hv_magic (HV* hv, GV* gv, int how)
+
+=item HvNAME
+
+Returns the package name of a stash. See C<SvSTASH>, C<CvSTASH>.
+
+ char* HvNAME (HV* stash)
+
+=item hv_store
+
+Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is
+the length of the key. The C<hash> parameter is the precomputed hash
+value; if it is zero then Perl will compute it. The return value will be
+NULL if the operation failed or if the value did not need to be actually
+stored within the hash (as in the case of tied hashes). Otherwise it can
+be dereferenced to get the original C<SV*>. Note that the caller is
+responsible for suitably incrementing the reference count of C<val>
+before the call, and decrementing it if the function returned NULL.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied hashes.
+
+ SV** hv_store (HV* tb, char* key, U32 klen, SV* val, U32 hash)
+
+=item hv_store_ent
+
+Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash>
+parameter is the precomputed hash value; if it is zero then Perl will
+compute it. The return value is the new hash entry so created. It will be
+NULL if the operation failed or if the value did not need to be actually
+stored within the hash (as in the case of tied hashes). Otherwise the
+contents of the return value can be accessed using the C<He???> macros
+described here. Note that the caller is responsible for suitably
+incrementing the reference count of C<val> before the call, and decrementing
+it if the function returned NULL.
+
+See L<Understanding the Magic of Tied Hashes and Arrays> for more
+information on how to use this function on tied hashes.
+
+ HE* hv_store_ent (HV* tb, SV* key, SV* val, U32 hash)
+
+=item hv_undef
+
+Undefines the hash.
+
+ void hv_undef (HV* tb)
+
+=item isALNUM
+
+Returns a boolean indicating whether the C C<char> is an ascii alphanumeric
+character or digit.
+
+ int isALNUM (char c)
+
+=item isALPHA
+
+Returns a boolean indicating whether the C C<char> is an ascii alphabetic
+character.
+
+ int isALPHA (char c)
+
+=item isDIGIT
+
+Returns a boolean indicating whether the C C<char> is an ascii digit.
+
+ int isDIGIT (char c)
+
+=item isLOWER
+
+Returns a boolean indicating whether the C C<char> is a lowercase character.
+
+ int isLOWER (char c)
+
+=item isSPACE
+
+Returns a boolean indicating whether the C C<char> is whitespace.
+
+ int isSPACE (char c)
+
+=item isUPPER
+
+Returns a boolean indicating whether the C C<char> is an uppercase character.
+
+ int isUPPER (char c)
+
+=item items
+
+Variable which is setup by C<xsubpp> to indicate the number of items on the
+stack. See L<perlxs/"Variable-length Parameter Lists">.
+
+=item ix
+
+Variable which is setup by C<xsubpp> to indicate which of an XSUB's aliases
+was used to invoke it. See L<perlxs/"The ALIAS: Keyword">.
+
+=item LEAVE
+
+Closing bracket on a callback. See C<ENTER> and L<perlcall>.
+
+ LEAVE;
+
+=item looks_like_number
+
+Test if an the content of an SV looks like a number (or is a number).
+
+ int looks_like_number(SV*)
+
+
+=item MARK
+
+Stack marker variable for the XSUB. See C<dMARK>.
+
+=item mg_clear
+
+Clear something magical that the SV represents. See C<sv_magic>.
+
+ int mg_clear (SV* sv)
+
+=item mg_copy
+
+Copies the magic from one SV to another. See C<sv_magic>.
+
+ int mg_copy (SV *, SV *, char *, STRLEN)
+
+=item mg_find
+
+Finds the magic pointer for type matching the SV. See C<sv_magic>.
+
+ MAGIC* mg_find (SV* sv, int type)
+
+=item mg_free
+
+Free any magic storage used by the SV. See C<sv_magic>.
+
+ int mg_free (SV* sv)
+
+=item mg_get
+
+Do magic after a value is retrieved from the SV. See C<sv_magic>.
+
+ int mg_get (SV* sv)
+
+=item mg_len
+
+Report on the SV's length. See C<sv_magic>.
+
+ U32 mg_len (SV* sv)
+
+=item mg_magical
+
+Turns on the magical status of an SV. See C<sv_magic>.
+
+ void mg_magical (SV* sv)
+
+=item mg_set
+
+Do magic after a value is assigned to the SV. See C<sv_magic>.
+
+ int mg_set (SV* sv)
+
+=item Move
+
+The XSUB-writer's interface to the C C<memmove> function. The C<s> is the
+source, C<d> is the destination, C<n> is the number of items, and C<t> is
+the type. Can do overlapping moves. See also C<Copy>.
+
+ void Move( s, d, n, t )
+
+=item PL_na
+
+A variable which may be used with C<SvPV> to tell Perl to calculate the
+string length.
+
+=item New
+
+The XSUB-writer's interface to the C C<malloc> function.
+
+ void* New( x, void *ptr, int size, type )
+
+=item newAV
+
+Creates a new AV. The reference count is set to 1.
+
+ AV* newAV (void)
+
+=item Newc
+
+The XSUB-writer's interface to the C C<malloc> function, with cast.
+
+ void* Newc( x, void *ptr, int size, type, cast )
+
+=item newCONSTSUB
+
+Creates a constant sub equivalent to Perl C<sub FOO () { 123 }>
+which is eligible for inlining at compile-time.
+
+ void newCONSTSUB(HV* stash, char* name, SV* sv)
+
+=item newHV
+
+Creates a new HV. The reference count is set to 1.
+
+ HV* newHV (void)
+
+=item newRV_inc
+
+Creates an RV wrapper for an SV. The reference count for the original SV is
+incremented.
+
+ SV* newRV_inc (SV* ref)
+
+For historical reasons, "newRV" is a synonym for "newRV_inc".
+
+=item newRV_noinc
+
+Creates an RV wrapper for an SV. The reference count for the original
+SV is B<not> incremented.
+
+ SV* newRV_noinc (SV* ref)
+
+=item NEWSV
+
+Creates a new SV. A non-zero C<len> parameter indicates the number of
+bytes of preallocated string space the SV should have. An extra byte
+for a tailing NUL is also reserved. (SvPOK is not set for the SV even
+if string space is allocated.) The reference count for the new SV is
+set to 1. C<id> is an integer id between 0 and 1299 (used to identify
+leaks).
+
+ SV* NEWSV (int id, STRLEN len)
+
+=item newSViv
+
+Creates a new SV and copies an integer into it. The reference count for the
+SV is set to 1.
+
+ SV* newSViv (IV i)
+
+=item newSVnv
+
+Creates a new SV and copies a double into it. The reference count for the
+SV is set to 1.
+
+ SV* newSVnv (NV i)
+
+=item newSVpv
+
+Creates a new SV and copies a string into it. The reference count for the
+SV is set to 1. If C<len> is zero then Perl will compute the length.
+
+ SV* newSVpv (char* s, STRLEN len)
+
+=item newSVpvf
+
+Creates a new SV an initialize it with the string formatted like
+C<sprintf>.
+
+ SV* newSVpvf(const char* pat, ...);
+
+=item newSVpvn
+
+Creates a new SV and copies a string into it. The reference count for the
+SV is set to 1. If C<len> is zero then Perl will create a zero length
+string.
+
+ SV* newSVpvn (char* s, STRLEN len)
+
+=item newSVrv
+
+Creates a new SV for the RV, C<rv>, to point to. If C<rv> is not an RV then
+it will be upgraded to one. If C<classname> is non-null then the new SV will
+be blessed in the specified package. The new SV is returned and its
+reference count is 1.
+
+ SV* newSVrv (SV* rv, char* classname)
+
+=item newSVsv
+
+Creates a new SV which is an exact duplicate of the original SV.
+
+ SV* newSVsv (SV* old)
+
+=item newXS
+
+Used by C<xsubpp> to hook up XSUBs as Perl subs.
+
+=item newXSproto
+
+Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to
+the subs.
+
+=item Newz
+
+The XSUB-writer's interface to the C C<malloc> function. The allocated
+memory is zeroed with C<memzero>.
+
+ void* Newz( x, void *ptr, int size, type )
+
+=item Nullav
+
+Null AV pointer.
+
+=item Nullch
+
+Null character pointer.
+
+=item Nullcv
+
+Null CV pointer.
+
+=item Nullhv
+
+Null HV pointer.
+
+=item Nullsv
+
+Null SV pointer.
+
+=item ORIGMARK
+
+The original stack mark for the XSUB. See C<dORIGMARK>.
+
+=item perl_alloc
+
+Allocates a new Perl interpreter. See L<perlembed>.
+
+=item perl_call_argv
+
+Performs a callback to the specified Perl sub. See L<perlcall>.
+
+ I32 perl_call_argv (char* subname, I32 flags, char** argv)
+
+=item perl_call_method
+
+Performs a callback to the specified Perl method. The blessed object must
+be on the stack. See L<perlcall>.
+
+ I32 perl_call_method (char* methname, I32 flags)
+
+=item perl_call_pv
+
+Performs a callback to the specified Perl sub. See L<perlcall>.
+
+ I32 perl_call_pv (char* subname, I32 flags)
+
+=item perl_call_sv
+
+Performs a callback to the Perl sub whose name is in the SV. See
+L<perlcall>.
+
+ I32 perl_call_sv (SV* sv, I32 flags)
+
+=item perl_construct
+
+Initializes a new Perl interpreter. See L<perlembed>.
+
+=item perl_destruct
+
+Shuts down a Perl interpreter. See L<perlembed>.
+
+=item perl_eval_sv
+
+Tells Perl to C<eval> the string in the SV.
+
+ I32 perl_eval_sv (SV* sv, I32 flags)
+
+=item perl_eval_pv
+
+Tells Perl to C<eval> the given string and return an SV* result.
+
+ SV* perl_eval_pv (char* p, I32 croak_on_error)
+
+=item perl_free
+
+Releases a Perl interpreter. See L<perlembed>.
+
+=item perl_get_av
+
+Returns the AV of the specified Perl array. If C<create> is set and the
+Perl variable does not exist then it will be created. If C<create> is not
+set and the variable does not exist then NULL is returned.
+
+ AV* perl_get_av (char* name, I32 create)
+
+=item perl_get_cv
+
+Returns the CV of the specified Perl sub. If C<create> is set and the Perl
+variable does not exist then it will be created. If C<create> is not
+set and the variable does not exist then NULL is returned.
+
+ CV* perl_get_cv (char* name, I32 create)
+
+=item perl_get_hv
+
+Returns the HV of the specified Perl hash. If C<create> is set and the Perl
+variable does not exist then it will be created. If C<create> is not
+set and the variable does not exist then NULL is returned.
+
+ HV* perl_get_hv (char* name, I32 create)
+
+=item perl_get_sv
+
+Returns the SV of the specified Perl scalar. If C<create> is set and the
+Perl variable does not exist then it will be created. If C<create> is not
+set and the variable does not exist then NULL is returned.
+
+ SV* perl_get_sv (char* name, I32 create)
+
+=item perl_parse
+
+Tells a Perl interpreter to parse a Perl script. See L<perlembed>.
+
+=item perl_require_pv
+
+Tells Perl to C<require> a module.
+
+ void perl_require_pv (char* pv)
+
+=item perl_run
+
+Tells a Perl interpreter to run. See L<perlembed>.
+
+=item POPi
+
+Pops an integer off the stack.
+
+ int POPi()
+
+=item POPl
+
+Pops a long off the stack.
+
+ long POPl()
+
+=item POPp
+
+Pops a string off the stack.
+
+ char* POPp()
+
+=item POPn
+
+Pops a double off the stack.
+
+ double POPn()
+
+=item POPs
+
+Pops an SV off the stack.
+
+ SV* POPs()
+
+=item PUSHMARK
+
+Opening bracket for arguments on a callback. See C<PUTBACK> and L<perlcall>.
+
+ PUSHMARK(p)
+
+=item PUSHi
+
+Push an integer onto the stack. The stack must have room for this element.
+Handles 'set' magic. See C<XPUSHi>.
+
+ void PUSHi(int d)
+
+=item PUSHn
+
+Push a double onto the stack. The stack must have room for this element.
+Handles 'set' magic. See C<XPUSHn>.
+
+ void PUSHn(double d)
+
+=item PUSHp
+
+Push a string onto the stack. The stack must have room for this element.
+The C<len> indicates the length of the string. Handles 'set' magic. See
+C<XPUSHp>.
+
+ void PUSHp(char *c, int len )
+
+=item PUSHs
+
+Push an SV onto the stack. The stack must have room for this element. Does
+not handle 'set' magic. See C<XPUSHs>.
+
+ void PUSHs(sv)
+
+=item PUSHu
+
+Push an unsigned integer onto the stack. The stack must have room for
+this element. See C<XPUSHu>.
+
+ void PUSHu(unsigned int d)
+
+
+=item PUTBACK
+
+Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
+See C<PUSHMARK> and L<perlcall> for other uses.
+
+ PUTBACK;
+
+=item Renew
+
+The XSUB-writer's interface to the C C<realloc> function.
+
+ void* Renew( void *ptr, int size, type )
+
+=item Renewc
+
+The XSUB-writer's interface to the C C<realloc> function, with cast.
+
+ void* Renewc( void *ptr, int size, type, cast )
+
+=item RETVAL
+
+Variable which is setup by C<xsubpp> to hold the return value for an XSUB.
+This is always the proper type for the XSUB.
+See L<perlxs/"The RETVAL Variable">.
+
+=item safefree
+
+The XSUB-writer's interface to the C C<free> function.
+
+=item safemalloc
+
+The XSUB-writer's interface to the C C<malloc> function.
+
+=item saferealloc
+
+The XSUB-writer's interface to the C C<realloc> function.
+
+=item savepv
+
+Copy a string to a safe spot. This does not use an SV.
+
+ char* savepv (char* sv)
+
+=item savepvn
+
+Copy a string to a safe spot. The C<len> indicates number of bytes to
+copy. This does not use an SV.
+
+ char* savepvn (char* sv, I32 len)
+
+=item SAVETMPS
+
+Opening bracket for temporaries on a callback. See C<FREETMPS> and
+L<perlcall>.
+
+ SAVETMPS;
+
+=item SP
+
+Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
+C<SPAGAIN>.
+
+=item SPAGAIN
+
+Refetch the stack pointer. Used after a callback. See L<perlcall>.
+
+ SPAGAIN;
+
+=item ST
+
+Used to access elements on the XSUB's stack.
+
+ SV* ST(int x)
+
+=item strEQ
+
+Test two strings to see if they are equal. Returns true or false.
+
+ int strEQ( char *s1, char *s2 )
+
+=item strGE
+
+Test two strings to see if the first, C<s1>, is greater than or equal to the
+second, C<s2>. Returns true or false.
+
+ int strGE( char *s1, char *s2 )
+
+=item strGT
+
+Test two strings to see if the first, C<s1>, is greater than the second,
+C<s2>. Returns true or false.
+
+ int strGT( char *s1, char *s2 )
+
+=item strLE
+
+Test two strings to see if the first, C<s1>, is less than or equal to the
+second, C<s2>. Returns true or false.
+
+ int strLE( char *s1, char *s2 )
+
+=item strLT
+
+Test two strings to see if the first, C<s1>, is less than the second,
+C<s2>. Returns true or false.
+
+ int strLT( char *s1, char *s2 )
+
+=item strNE
+
+Test two strings to see if they are different. Returns true or false.
+
+ int strNE( char *s1, char *s2 )
+
+=item strnEQ
+
+Test two strings to see if they are equal. The C<len> parameter indicates
+the number of bytes to compare. Returns true or false.
+
+ int strnEQ( char *s1, char *s2 )
+
+=item strnNE
+
+Test two strings to see if they are different. The C<len> parameter
+indicates the number of bytes to compare. Returns true or false.
+
+ int strnNE( char *s1, char *s2, int len )
+
+=item sv_2mortal
+
+Marks an SV as mortal. The SV will be destroyed when the current context
+ends.
+
+ SV* sv_2mortal (SV* sv)
+
+=item sv_bless
+
+Blesses an SV into a specified package. The SV must be an RV. The package
+must be designated by its stash (see C<gv_stashpv()>). The reference count
+of the SV is unaffected.
+
+ SV* sv_bless (SV* sv, HV* stash)
+
+=item sv_catpv
+
+Concatenates the string onto the end of the string which is in the SV.
+Handles 'get' magic, but not 'set' magic. See C<sv_catpv_mg>.
+
+ void sv_catpv (SV* sv, char* ptr)
+
+=item sv_catpv_mg
+
+Like C<sv_catpv>, but also handles 'set' magic.
+
+ void sv_catpvn (SV* sv, char* ptr)
+
+=item sv_catpvn
+
+Concatenates the string onto the end of the string which is in the SV. The
+C<len> indicates number of bytes to copy. Handles 'get' magic, but not
+'set' magic. See C<sv_catpvn_mg>.
+
+ void sv_catpvn (SV* sv, char* ptr, STRLEN len)
+
+=item sv_catpvn_mg
+
+Like C<sv_catpvn>, but also handles 'set' magic.
+
+ void sv_catpvn_mg (SV* sv, char* ptr, STRLEN len)
+
+=item sv_catpvf
+
+Processes its arguments like C<sprintf> and appends the formatted output
+to an SV. Handles 'get' magic, but not 'set' magic. C<SvSETMAGIC()> must
+typically be called after calling this function to handle 'set' magic.
+
+ void sv_catpvf (SV* sv, const char* pat, ...)
+
+=item sv_catpvf_mg
+
+Like C<sv_catpvf>, but also handles 'set' magic.
+
+ void sv_catpvf_mg (SV* sv, const char* pat, ...)
+
+=item sv_catsv
+
+Concatenates the string from SV C<ssv> onto the end of the string in SV
+C<dsv>. Handles 'get' magic, but not 'set' magic. See C<sv_catsv_mg>.
+
+ void sv_catsv (SV* dsv, SV* ssv)
+
+=item sv_catsv_mg
+
+Like C<sv_catsv>, but also handles 'set' magic.
+
+ void sv_catsv_mg (SV* dsv, SV* ssv)
+
+=item sv_chop
+
+Efficient removal of characters from the beginning of the string
+buffer. SvPOK(sv) must be true and the C<ptr> must be a pointer to
+somewhere inside the string buffer. The C<ptr> becomes the first
+character of the adjusted string.
+
+ void sv_chop(SV* sv, char *ptr)
+
+
+=item sv_cmp
+
+Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the
+string in C<sv1> is less than, equal to, or greater than the string in
+C<sv2>.
+
+ I32 sv_cmp (SV* sv1, SV* sv2)
+
+=item SvCUR
+
+Returns the length of the string which is in the SV. See C<SvLEN>.
+
+ int SvCUR (SV* sv)
+
+=item SvCUR_set
+
+Set the length of the string which is in the SV. See C<SvCUR>.
+
+ void SvCUR_set (SV* sv, int val )
+
+=item sv_dec
+
+Auto-decrement of the value in the SV.
+
+ void sv_dec (SV* sv)
+
+=item sv_derived_from
+
+Returns a boolean indicating whether the SV is a subclass of the
+specified class.
+
+ int sv_derived_from(SV* sv, char* class)
+
+=item sv_derived_from
+
+Returns a boolean indicating whether the SV is derived from the specified
+class. This is the function that implements C<UNIVERSAL::isa>. It works
+for class names as well as for objects.
+
+ bool sv_derived_from _((SV* sv, char* name));
+
+=item SvEND
+
+Returns a pointer to the last character in the string which is in the SV.
+See C<SvCUR>. Access the character as
+
+ char* SvEND(sv)
+
+=item sv_eq
+
+Returns a boolean indicating whether the strings in the two SVs are
+identical.
+
+ I32 sv_eq (SV* sv1, SV* sv2)
+
+=item SvGETMAGIC
+
+Invokes C<mg_get> on an SV if it has 'get' magic. This macro evaluates
+its argument more than once.
+
+ void SvGETMAGIC( SV *sv )
+
+=item SvGROW
+
+Expands the character buffer in the SV so that it has room for the
+indicated number of bytes (remember to reserve space for an extra
+trailing NUL character). Calls C<sv_grow> to perform the expansion if
+necessary. Returns a pointer to the character buffer.
+
+ char* SvGROW( SV* sv, int len )
+
+=item sv_grow
+
+Expands the character buffer in the SV. This will use C<sv_unref> and will
+upgrade the SV to C<SVt_PV>. Returns a pointer to the character buffer.
+Use C<SvGROW>.
+
+=item sv_inc
+
+Auto-increment of the value in the SV.
+
+ void sv_inc (SV* sv)
+
+=item sv_insert
+
+Inserts a string at the specified offset/length within the SV.
+Similar to the Perl substr() function.
+
+ void sv_insert(SV *sv, STRLEN offset, STRLEN len,
+ char *str, STRLEN strlen)
+
+=item SvIOK
+
+Returns a boolean indicating whether the SV contains an integer.
+
+ int SvIOK (SV* SV)
+
+=item SvIOK_off
+
+Unsets the IV status of an SV.
+
+ void SvIOK_off (SV* sv)
+
+=item SvIOK_on
+
+Tells an SV that it is an integer.
+
+ void SvIOK_on (SV* sv)
+
+=item SvIOK_only
+
+Tells an SV that it is an integer and disables all other OK bits.
+
+ void SvIOK_only (SV* sv)
+
+=item SvIOKp
+
+Returns a boolean indicating whether the SV contains an integer. Checks the
+B<private> setting. Use C<SvIOK>.
+
+ int SvIOKp (SV* SV)
+
+=item sv_isa
+
+Returns a boolean indicating whether the SV is blessed into the specified
+class. This does not check for subtypes; use C<sv_derived_from> to verify
+an inheritance relationship.
+
+ int sv_isa (SV* sv, char* name)
+
+=item sv_isobject
+
+Returns a boolean indicating whether the SV is an RV pointing to a blessed
+object. If the SV is not an RV, or if the object is not blessed, then this
+will return false.
+
+ int sv_isobject (SV* sv)
+
+=item SvIV
+
+Returns the integer which is in the SV.
+
+ int SvIV (SV* sv)
+
+=item SvIVX
+
+Returns the integer which is stored in the SV.
+
+ int SvIVX (SV* sv)
+
+=item SvLEN
+
+Returns the size of the string buffer in the SV. See C<SvCUR>.
+
+ int SvLEN (SV* sv)
+
+=item sv_len
+
+Returns the length of the string in the SV. Use C<SvCUR>.
+
+ STRLEN sv_len (SV* sv)
+
+=item sv_magic
+
+Adds magic to an SV.
+
+ void sv_magic (SV* sv, SV* obj, int how, char* name, I32 namlen)
+
+=item sv_mortalcopy
+
+Creates a new SV which is a copy of the original SV. The new SV is marked
+as mortal.
+
+ SV* sv_mortalcopy (SV* oldsv)
+
+=item sv_newmortal
+
+Creates a new SV which is mortal. The reference count of the SV is set to 1.
+
+ SV* sv_newmortal (void)
+
+=item SvNIOK
+
+Returns a boolean indicating whether the SV contains a number, integer or
+double.
+
+ int SvNIOK (SV* SV)
+
+=item SvNIOK_off
+
+Unsets the NV/IV status of an SV.
+
+ void SvNIOK_off (SV* sv)
+
+=item SvNIOKp
+
+Returns a boolean indicating whether the SV contains a number, integer or
+double. Checks the B<private> setting. Use C<SvNIOK>.
+
+ int SvNIOKp (SV* SV)
+
+=item PL_sv_no
+
+This is the C<false> SV. See C<PL_sv_yes>. Always refer to this as C<&PL_sv_no>.
+
+=item SvNOK
+
+Returns a boolean indicating whether the SV contains a double.
+
+ int SvNOK (SV* SV)
+
+=item SvNOK_off
+
+Unsets the NV status of an SV.
+
+ void SvNOK_off (SV* sv)
+
+=item SvNOK_on
+
+Tells an SV that it is a double.
+
+ void SvNOK_on (SV* sv)
+
+=item SvNOK_only
+
+Tells an SV that it is a double and disables all other OK bits.
+
+ void SvNOK_only (SV* sv)
+
+=item SvNOKp
+
+Returns a boolean indicating whether the SV contains a double. Checks the
+B<private> setting. Use C<SvNOK>.
+
+ int SvNOKp (SV* SV)
+
+=item SvNV
+
+Returns the double which is stored in the SV.
+
+ double SvNV (SV* sv)
+
+=item SvNVX
+
+Returns the double which is stored in the SV.
+
+ double SvNVX (SV* sv)
+
+=item SvOK
+
+Returns a boolean indicating whether the value is an SV.
+
+ int SvOK (SV* sv)
+
+=item SvOOK
+
+Returns a boolean indicating whether the SvIVX is a valid offset value
+for the SvPVX. This hack is used internally to speed up removal of
+characters from the beginning of a SvPV. When SvOOK is true, then the
+start of the allocated string buffer is really (SvPVX - SvIVX).
+
+ int SvOOK(SV* sv)
+
+=item SvPOK
+
+Returns a boolean indicating whether the SV contains a character string.
+
+ int SvPOK (SV* SV)
+
+=item SvPOK_off
+
+Unsets the PV status of an SV.
+
+ void SvPOK_off (SV* sv)
+
+=item SvPOK_on
+
+Tells an SV that it is a string.
+
+ void SvPOK_on (SV* sv)
+
+=item SvPOK_only
+
+Tells an SV that it is a string and disables all other OK bits.
+
+ void SvPOK_only (SV* sv)
+
+=item SvPOKp
+
+Returns a boolean indicating whether the SV contains a character string.
+Checks the B<private> setting. Use C<SvPOK>.
+
+ int SvPOKp (SV* SV)
+
+=item SvPV
+
+Returns a pointer to the string in the SV, or a stringified form of the SV
+if the SV does not contain a string. If C<len> is C<PL_na> then Perl will
+handle the length on its own. Handles 'get' magic.
+
+ char* SvPV (SV* sv, int len )
+
+=item SvPV_force
+
+Like <SvPV> but will force the SV into becoming a string (SvPOK). You
+want force if you are going to update the SvPVX directly.
+
+ char* SvPV_force(SV* sv, int len)
+
+
+=item SvPVX
+
+Returns a pointer to the string in the SV. The SV must contain a string.
+
+ char* SvPVX (SV* sv)
+
+=item SvREFCNT
+
+Returns the value of the object's reference count.
+
+ int SvREFCNT (SV* sv)
+
+=item SvREFCNT_dec
+
+Decrements the reference count of the given SV.
+
+ void SvREFCNT_dec (SV* sv)
+
+=item SvREFCNT_inc
+
+Increments the reference count of the given SV.
+
+ void SvREFCNT_inc (SV* sv)
+
+=item SvROK
+
+Tests if the SV is an RV.
+
+ int SvROK (SV* sv)
+
+=item SvROK_off
+
+Unsets the RV status of an SV.
+
+ void SvROK_off (SV* sv)
+
+=item SvROK_on
+
+Tells an SV that it is an RV.
+
+ void SvROK_on (SV* sv)
+
+=item SvRV
+
+Dereferences an RV to return the SV.
+
+ SV* SvRV (SV* sv)
+
+=item SvSETMAGIC
+
+Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates
+its argument more than once.
+
+ void SvSETMAGIC( SV *sv )
+
+=item sv_setiv
+
+Copies an integer into the given SV. Does not handle 'set' magic.
+See C<sv_setiv_mg>.
+
+ void sv_setiv (SV* sv, IV num)
+
+=item sv_setiv_mg
+
+Like C<sv_setiv>, but also handles 'set' magic.
+
+ void sv_setiv_mg (SV* sv, IV num)
+
+=item sv_setnv
+
+Copies a double into the given SV. Does not handle 'set' magic.
+See C<sv_setnv_mg>.
+
+ void sv_setnv (SV* sv, double num)
+
+=item sv_setnv_mg
+
+Like C<sv_setnv>, but also handles 'set' magic.
+
+ void sv_setnv_mg (SV* sv, double num)
+
+=item sv_setpv
+
+Copies a string into an SV. The string must be null-terminated.
+Does not handle 'set' magic. See C<sv_setpv_mg>.
+
+ void sv_setpv (SV* sv, char* ptr)
+
+=item sv_setpv_mg
+
+Like C<sv_setpv>, but also handles 'set' magic.
+
+ void sv_setpv_mg (SV* sv, char* ptr)
+
+=item sv_setpviv
+
+Copies an integer into the given SV, also updating its string value.
+Does not handle 'set' magic. See C<sv_setpviv_mg>.
+
+ void sv_setpviv (SV* sv, IV num)
+
+=item sv_setpviv_mg
+
+Like C<sv_setpviv>, but also handles 'set' magic.
+
+ void sv_setpviv_mg (SV* sv, IV num)
+
+=item sv_setpvn
+
+Copies a string into an SV. The C<len> parameter indicates the number of
+bytes to be copied. Does not handle 'set' magic. See C<sv_setpvn_mg>.
+
+ void sv_setpvn (SV* sv, char* ptr, STRLEN len)
+
+=item sv_setpvn_mg
+
+Like C<sv_setpvn>, but also handles 'set' magic.
+
+ void sv_setpvn_mg (SV* sv, char* ptr, STRLEN len)
+
+=item sv_setpvf
+
+Processes its arguments like C<sprintf> and sets an SV to the formatted
+output. Does not handle 'set' magic. See C<sv_setpvf_mg>.
+
+ void sv_setpvf (SV* sv, const char* pat, ...)
+
+=item sv_setpvf_mg
+
+Like C<sv_setpvf>, but also handles 'set' magic.
+
+ void sv_setpvf_mg (SV* sv, const char* pat, ...)
+
+=item sv_setref_iv
+
+Copies an integer into a new SV, optionally blessing the SV. The C<rv>
+argument will be upgraded to an RV. That RV will be modified to point to
+the new SV. The C<classname> argument indicates the package for the
+blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
+will be returned and will have a reference count of 1.
+
+ SV* sv_setref_iv (SV *rv, char *classname, IV iv)
+
+=item sv_setref_nv
+
+Copies a double into a new SV, optionally blessing the SV. The C<rv>
+argument will be upgraded to an RV. That RV will be modified to point to
+the new SV. The C<classname> argument indicates the package for the
+blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
+will be returned and will have a reference count of 1.
+
+ SV* sv_setref_nv (SV *rv, char *classname, double nv)
+
+=item sv_setref_pv
+
+Copies a pointer into a new SV, optionally blessing the SV. The C<rv>
+argument will be upgraded to an RV. That RV will be modified to point to
+the new SV. If the C<pv> argument is NULL then C<PL_sv_undef> will be placed
+into the SV. The C<classname> argument indicates the package for the
+blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
+will be returned and will have a reference count of 1.
+
+ SV* sv_setref_pv (SV *rv, char *classname, void* pv)
+
+Do not use with integral Perl types such as HV, AV, SV, CV, because those
+objects will become corrupted by the pointer copy process.
+
+Note that C<sv_setref_pvn> copies the string while this copies the pointer.
+
+=item sv_setref_pvn
+
+Copies a string into a new SV, optionally blessing the SV. The length of the
+string must be specified with C<n>. The C<rv> argument will be upgraded to
+an RV. That RV will be modified to point to the new SV. The C<classname>
+argument indicates the package for the blessing. Set C<classname> to
+C<Nullch> to avoid the blessing. The new SV will be returned and will have
+a reference count of 1.
+
+ SV* sv_setref_pvn (SV *rv, char *classname, char* pv, I32 n)
+
+Note that C<sv_setref_pv> copies the pointer while this copies the string.
+
+=item SvSetSV
+
+Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments
+more than once.
+
+ void SvSetSV (SV* dsv, SV* ssv)
+
+=item SvSetSV_nosteal
+
+Calls a non-destructive version of C<sv_setsv> if dsv is not the same as ssv.
+May evaluate arguments more than once.
+
+ void SvSetSV_nosteal (SV* dsv, SV* ssv)
+
+=item sv_setsv
+
+Copies the contents of the source SV C<ssv> into the destination SV C<dsv>.
+The source SV may be destroyed if it is mortal. Does not handle 'set' magic.
+See the macro forms C<SvSetSV>, C<SvSetSV_nosteal> and C<sv_setsv_mg>.
+
+ void sv_setsv (SV* dsv, SV* ssv)
+
+=item sv_setsv_mg
+
+Like C<sv_setsv>, but also handles 'set' magic.
+
+ void sv_setsv_mg (SV* dsv, SV* ssv)
+
+=item sv_setuv
+
+Copies an unsigned integer into the given SV. Does not handle 'set' magic.
+See C<sv_setuv_mg>.
+
+ void sv_setuv (SV* sv, UV num)
+
+=item sv_setuv_mg
+
+Like C<sv_setuv>, but also handles 'set' magic.
+
+ void sv_setuv_mg (SV* sv, UV num)
+
+=item SvSTASH
+
+Returns the stash of the SV.
+
+ HV* SvSTASH (SV* sv)
+
+=item SvTAINT
+
+Taints an SV if tainting is enabled
+
+ void SvTAINT (SV* sv)
+
+=item SvTAINTED
+
+Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if not.
+
+ int SvTAINTED (SV* sv)
+
+=item SvTAINTED_off
+
+Untaints an SV. Be I<very> careful with this routine, as it short-circuits
+some of Perl's fundamental security features. XS module authors should
+not use this function unless they fully understand all the implications
+of unconditionally untainting the value. Untainting should be done in
+the standard perl fashion, via a carefully crafted regexp, rather than
+directly untainting variables.
+
+ void SvTAINTED_off (SV* sv)
+
+=item SvTAINTED_on
+
+Marks an SV as tainted.
+
+ void SvTAINTED_on (SV* sv)
+
+=item SVt_IV
+
+Integer type flag for scalars. See C<svtype>.
+
+=item SVt_PV
+
+Pointer type flag for scalars. See C<svtype>.
+
+=item SVt_PVAV
+
+Type flag for arrays. See C<svtype>.
+
+=item SVt_PVCV
+
+Type flag for code refs. See C<svtype>.
+
+=item SVt_PVHV
+
+Type flag for hashes. See C<svtype>.
+
+=item SVt_PVMG
+
+Type flag for blessed scalars. See C<svtype>.
+
+=item SVt_NV
+
+Double type flag for scalars. See C<svtype>.
+
+=item SvTRUE
+
+Returns a boolean indicating whether Perl would evaluate the SV as true or
+false, defined or undefined. Does not handle 'get' magic.
+
+ int SvTRUE (SV* sv)
+
+=item SvTYPE
+
+Returns the type of the SV. See C<svtype>.
+
+ svtype SvTYPE (SV* sv)
+
+=item svtype
+
+An enum of flags for Perl types. These are found in the file B<sv.h> in the
+C<svtype> enum. Test these flags with the C<SvTYPE> macro.
+
+=item PL_sv_undef
+
+This is the C<undef> SV. Always refer to this as C<&PL_sv_undef>.
+
+=item sv_unref
+
+Unsets the RV status of the SV, and decrements the reference count of
+whatever was being referenced by the RV. This can almost be thought of
+as a reversal of C<newSVrv>. See C<SvROK_off>.
+
+ void sv_unref (SV* sv)
+
+=item SvUPGRADE
+
+Used to upgrade an SV to a more complex form. Uses C<sv_upgrade> to perform
+the upgrade if necessary. See C<svtype>.
+
+ bool SvUPGRADE (SV* sv, svtype mt)
+
+=item sv_upgrade
+
+Upgrade an SV to a more complex form. Use C<SvUPGRADE>. See C<svtype>.
+
+=item sv_usepvn
+
+Tells an SV to use C<ptr> to find its string value. Normally the string is
+stored inside the SV but sv_usepvn allows the SV to use an outside string.
+The C<ptr> should point to memory that was allocated by C<malloc>. The
+string length, C<len>, must be supplied. This function will realloc the
+memory pointed to by C<ptr>, so that pointer should not be freed or used by
+the programmer after giving it to sv_usepvn. Does not handle 'set' magic.
+See C<sv_usepvn_mg>.
+
+ void sv_usepvn (SV* sv, char* ptr, STRLEN len)
+
+=item sv_usepvn_mg
+
+Like C<sv_usepvn>, but also handles 'set' magic.
+
+ void sv_usepvn_mg (SV* sv, char* ptr, STRLEN len)
+
+=item sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)
+
+Processes its arguments like C<vsprintf> and appends the formatted output
+to an SV. Uses an array of SVs if the C style variable argument list is
+missing (NULL). Indicates if locale information has been used for formatting.
+
+ void sv_catpvfn _((SV* sv, const char* pat, STRLEN patlen,
+ va_list *args, SV **svargs, I32 svmax,
+ bool *used_locale));
+
+=item sv_vsetpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)
+
+Works like C<vcatpvfn> but copies the text into the SV instead of
+appending it.
+
+ void sv_setpvfn _((SV* sv, const char* pat, STRLEN patlen,
+ va_list *args, SV **svargs, I32 svmax,
+ bool *used_locale));
+
+=item SvUV
+
+Returns the unsigned integer which is in the SV.
+
+ UV SvUV(SV* sv)
+
+=item SvUVX
+
+Returns the unsigned integer which is stored in the SV.
+
+ UV SvUVX(SV* sv)
+
+=item PL_sv_yes
+
+This is the C<true> SV. See C<PL_sv_no>. Always refer to this as C<&PL_sv_yes>.
+
+=item THIS
+
+Variable which is setup by C<xsubpp> to designate the object in a C++ XSUB.
+This is always the proper type for the C++ object. See C<CLASS> and
+L<perlxs/"Using XS With C++">.
+
+=item toLOWER
+
+Converts the specified character to lowercase.
+
+ int toLOWER (char c)
+
+=item toUPPER
+
+Converts the specified character to uppercase.
+
+ int toUPPER (char c)
+
+=item warn
+
+This is the XSUB-writer's interface to Perl's C<warn> function. Use this
+function the same way you use the C C<printf> function. See C<croak()>.
+
+=item XPUSHi
+
+Push an integer onto the stack, extending the stack if necessary. Handles
+'set' magic. See C<PUSHi>.
+
+ XPUSHi(int d)
+
+=item XPUSHn
+
+Push a double onto the stack, extending the stack if necessary. Handles 'set'
+magic. See C<PUSHn>.
+
+ XPUSHn(double d)
+
+=item XPUSHp
+
+Push a string onto the stack, extending the stack if necessary. The C<len>
+indicates the length of the string. Handles 'set' magic. See C<PUSHp>.
+
+ XPUSHp(char *c, int len)
+
+=item XPUSHs
+
+Push an SV onto the stack, extending the stack if necessary. Does not
+handle 'set' magic. See C<PUSHs>.
+
+ XPUSHs(sv)
+
+=item XPUSHu
+
+Push an unsigned integer onto the stack, extending the stack if
+necessary. See C<PUSHu>.
+
+=item XS
+
+Macro to declare an XSUB and its C parameter list. This is handled by
+C<xsubpp>.
+
+=item XSRETURN
+
+Return from XSUB, indicating number of items on the stack. This is usually
+handled by C<xsubpp>.
+
+ XSRETURN(int x)
+
+=item XSRETURN_EMPTY
+
+Return an empty list from an XSUB immediately.
+
+ XSRETURN_EMPTY;
+
+=item XSRETURN_IV
+
+Return an integer from an XSUB immediately. Uses C<XST_mIV>.
+
+ XSRETURN_IV(IV v)
+
+=item XSRETURN_NO
+
+Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>.
+
+ XSRETURN_NO;
+
+=item XSRETURN_NV
+
+Return an double from an XSUB immediately. Uses C<XST_mNV>.
+
+ XSRETURN_NV(NV v)
+
+=item XSRETURN_PV
+
+Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>.
+
+ XSRETURN_PV(char *v)
+
+=item XSRETURN_UNDEF
+
+Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>.
+
+ XSRETURN_UNDEF;
+
+=item XSRETURN_YES
+
+Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>.
+
+ XSRETURN_YES;
+
+=item XST_mIV
+
+Place an integer into the specified position C<i> on the stack. The value is
+stored in a new mortal SV.
+
+ XST_mIV( int i, IV v )
+
+=item XST_mNV
+
+Place a double into the specified position C<i> on the stack. The value is
+stored in a new mortal SV.
+
+ XST_mNV( int i, NV v )
+
+=item XST_mNO
+
+Place C<&PL_sv_no> into the specified position C<i> on the stack.
+
+ XST_mNO( int i )
+
+=item XST_mPV
+
+Place a copy of a string into the specified position C<i> on the stack. The
+value is stored in a new mortal SV.
+
+ XST_mPV( int i, char *v )
+
+=item XST_mUNDEF
+
+Place C<&PL_sv_undef> into the specified position C<i> on the stack.
+
+ XST_mUNDEF( int i )
+
+=item XST_mYES
+
+Place C<&PL_sv_yes> into the specified position C<i> on the stack.
+
+ XST_mYES( int i )
+
+=item XS_VERSION
+
+The version identifier for an XS module. This is usually handled
+automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>.
+
+=item XS_VERSION_BOOTCHECK
+
+Macro to verify that a PM module's $VERSION variable matches the XS module's
+C<XS_VERSION> variable. This is usually handled automatically by
+C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">.
+
+=item Zero
+
+The XSUB-writer's interface to the C C<memzero> function. The C<d> is the
+destination, C<n> is the number of items, and C<t> is the type.
+
+ void Zero( d, n, t )
+
+=back
+
+=head1 AUTHORS
+
+Until May 1997, this document was maintained by Jeff Okamoto
+<okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
+
+With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
+Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
+Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
+Stephen McCamant, and Gurusamy Sarathy.
+
+API Listing originally by Dean Roehrich <roehrich@cray.com>.
diff --git a/contrib/perl5/pod/perlhist.pod b/contrib/perl5/pod/perlhist.pod
new file mode 100644
index 0000000..9ed8b6f
--- /dev/null
+++ b/contrib/perl5/pod/perlhist.pod
@@ -0,0 +1,518 @@
+=pod
+
+=head1 NAME
+
+perlhist - the Perl history records
+
+=for RCS
+#
+# $Id: perlhist.pod,v 1.48 1998/08/03 08:50:12 jhi Exp $
+#
+=end RCS
+
+=head1 DESCRIPTION
+
+This document aims to record the Perl source code releases.
+
+=head1 INTRODUCTION
+
+Perl history in brief, by Larry Wall:
+
+ Perl 0 introduced Perl to my officemates.
+ Perl 1 introduced Perl to the world, and changed /\(...\|...\)/ to
+ /(...|...)/. \(Dan Faigin still hasn't forgiven me. :-\)
+ Perl 2 introduced Henry Spencer's regular expression package.
+ Perl 3 introduced the ability to handle binary data (embedded nulls).
+ Perl 4 introduced the first Camel book. Really. We mostly just
+ switched version numbers so the book could refer to 4.000.
+ Perl 5 introduced everything else, including the ability to
+ introduce everything else.
+
+=head1 THE KEEPERS OF THE PUMPKIN
+
+Larry Wall, Andy Dougherty, Tom Christiansen, Charles Bailey, Nick
+Ing-Simmons, Chip Salzenberg, Tim Bunce, Malcolm Beattie, Gurusamy
+Sarathy, Graham Barr.
+
+=head2 PUMPKIN?
+
+[from Porting/pumpkin.pod in the Perl source code distribution]
+
+Chip Salzenberg gets credit for that, with a nod to his cow orker,
+David Croy. We had passed around various names (baton, token, hot
+potato) but none caught on. Then, Chip asked:
+
+[begin quote]
+
+ Who has the patch pumpkin?
+
+To explain: David Croy once told me once that at a previous job,
+there was one tape drive and multiple systems that used it for backups.
+But instead of some high-tech exclusion software, they used a low-tech
+method to prevent multiple simultaneous backups: a stuffed pumpkin.
+No one was allowed to make backups unless they had the "backup pumpkin".
+
+[end quote]
+
+The name has stuck. The holder of the pumpkin is sometimes called
+the pumpking (keeping the source afloat?) or the pumpkineer (pulling
+the strings?).
+
+=head1 THE RECORDS
+
+ Pump- Release Date Notes
+ king (by no means
+ comprehensive,
+ see Changes*
+ for details)
+ ===========================================================================
+
+ Larry 0 Classified. Don't ask.
+
+ Larry 1.000 1987-Dec-18
+
+ 1.001..10 1988-Jan-30
+ 1.011..14 1988-Feb-02
+
+ Larry 2.000 1988-Jun-05
+
+ 2.001 1988-Jun-28
+
+ Larry 3.000 1989-Oct-18
+
+ 3.001 1989-Oct-26
+ 3.002..4 1989-Nov-11
+ 3.005 1989-Nov-18
+ 3.006..8 1989-Dec-22
+ 3.009..13 1990-Mar-02
+ 3.014 1990-Mar-13
+ 3.015 1990-Mar-14
+ 3.016..18 1990-Mar-28
+ 3.019..27 1990-Aug-10 User subs.
+ 3.028 1990-Aug-14
+ 3.029..36 1990-Oct-17
+ 3.037 1990-Oct-20
+ 3.040 1990-Nov-10
+ 3.041 1990-Nov-13
+ 3.042..43 1990-Jan-??
+ 3.044 1991-Jan-12
+
+ Larry 4.000 1991-Mar-21
+
+ 4.001..3 1991-Apr-12
+ 4.004..9 1991-Jun-07
+ 4.010 1991-Jun-10
+ 4.011..18 1991-Nov-05
+ 4.019 1991-Nov-11 Stable.
+ 4.020..33 1992-Jun-08
+ 4.034 1992-Jun-11
+ 4.035 1992-Jun-23
+ Larry 4.036 1993-Feb-05 Very stable.
+
+ 5.000alpha1 1993-Jul-31
+ 5.000alpha2 1993-Aug-16
+ 5.000alpha3 1993-Oct-10
+ 5.000alpha4 1993-???-??
+ 5.000alpha5 1993-???-??
+ 5.000alpha6 1994-Mar-18
+ 5.003alpha7 1994-Mar-25
+ Andy 5.000alpha8 1994-Apr-04
+ Larry 5.000alpha9 1994-May-05 ext appears.
+ 5.000alpha10 1994-???-??
+ 5.000alpha11 1994-???-??
+ Andy 5.000a11a 1994-Jul-07 To fit 14.
+ 5.000a11b 1994-Jul-14
+ 5.000a11c 1994-Jul-19
+ 5.000a11d 1994-Jul-22
+ Larry 5.000alpha12 1994-???-??
+ Andy 5.000a12a 1994-Aug-08
+ 5.000a12b 1994-Aug-15
+ 5.000a12c 1994-Aug-22
+ 5.000a12d 1994-Aug-22
+ 5.000a12e 1994-Aug-22
+ 5.000a12f 1994-Aug-24
+ 5.000a12g 1994-Aug-24
+ 5.000a12h 1994-Aug-24
+ Larry 5.000beta1 1994-???-??
+ Andy 5.000b1a 1994-???-??
+ Larry 5.000beta2 1994-Sep-14 Core slushified.
+ Andy 5.000b2a 1994-Sep-14
+ 5.000b2b 1994-Sep-17
+ 5.000b2c 1994-Sep-17
+ Larry 5.000beta3 1994-Sep-??
+ Andy 5.000b3a 1994-Sep-18
+ 5.000b3b 1994-Sep-22
+ 5.000b3c 1994-Sep-23
+ 5.000b3d 1994-Sep-27
+ 5.000b3e 1994-Sep-28
+ 5.000b3f 1994-Sep-30
+ 5.000b3g 1994-Oct-04
+ Andy 5.000b3h 1994-Oct-07
+
+ Larry 5.000 1994-Oct-18
+
+ Andy 5.000a 1994-Dec-19
+ 5.000b 1995-Jan-18
+ 5.000c 1995-Jan-18
+ 5.000d 1995-Jan-18
+ 5.000e 1995-Jan-18
+ 5.000f 1995-Jan-18
+ 5.000g 1995-Jan-18
+ 5.000h 1995-Jan-18
+ 5.000i 1995-Jan-26
+ 5.000j 1995-Feb-07
+ 5.000k 1995-Feb-11
+ 5.000l 1995-Feb-21
+ 5.000m 1995-???-??
+ 5.000n 1995-Mar-07
+
+ Larry 5.001 1995-Mar-13
+
+ Andy 5.001a 1995-Mar-15
+ 5.001b 1995-Mar-31
+ 5.001c 1995-Apr-07
+ 5.001d 1995-Apr-14
+ 5.001e 1995-Apr-18 Stable.
+ 5.001f 1995-May-31
+ 5.001g 1995-May-25
+ 5.001h 1995-May-25
+ 5.001i 1995-May-30
+ 5.001j 1995-Jun-05
+ 5.001k 1995-Jun-06
+ 5.001l 1995-Jun-06 Stable.
+ 5.001m 1995-Jul-02 Very stable.
+ 5.001n 1995-Oct-31 Very unstable.
+ 5.002beta1 1995-Nov-21
+ 5.002b1a 1995-Nov-??
+ 5.002b1b 1995-Dec-04
+ 5.002b1c 1995-Dec-04
+ 5.002b1d 1995-Dec-04
+ 5.002b1e 1995-Dec-08
+ 5.002b1f 1995-Dec-08
+ Tom 5.002b1g 1995-Dec-21 Doc release.
+ Andy 5.002b1h 1996-Jan-05
+ 5.002b2 1996-Jan-14
+ Larry 5.002b3 1996-Feb-02
+ Andy 5.002gamma 1996-Feb-11
+ Larry 5.002delta 1996-Feb-27
+
+ Larry 5.002 1996-Feb-29 Prototypes.
+
+ Charles 5.002_01 1996-Mar-25
+
+ 5.003 1996-Jun-25 Security release.
+
+ 5.003_01 1996-Jul-31
+ Nick 5.003_02 1996-Aug-10
+ Andy 5.003_03 1996-Aug-28
+ 5.003_04 1996-Sep-02
+ 5.003_05 1996-Sep-12
+ 5.003_06 1996-Oct-07
+ 5.003_07 1996-Oct-10
+ Chip 5.003_08 1996-Nov-19
+ 5.003_09 1996-Nov-26
+ 5.003_10 1996-Nov-29
+ 5.003_11 1996-Dec-06
+ 5.003_12 1996-Dec-19
+ 5.003_13 1996-Dec-20
+ 5.003_14 1996-Dec-23
+ 5.003_15 1996-Dec-23
+ 5.003_16 1996-Dec-24
+ 5.003_17 1996-Dec-27
+ 5.003_18 1996-Dec-31
+ 5.003_19 1997-Jan-04
+ 5.003_20 1997-Jan-07
+ 5.003_21 1997-Jan-15
+ 5.003_22 1997-Jan-16
+ 5.003_23 1997-Jan-25
+ 5.003_24 1997-Jan-29
+ 5.003_25 1997-Feb-04
+ 5.003_26 1997-Feb-10
+ 5.003_27 1997-Feb-18
+ 5.003_28 1997-Feb-21
+ 5.003_90 1997-Feb-25 Ramping up to the 5.004 release.
+ 5.003_91 1997-Mar-01
+ 5.003_92 1997-Mar-06
+ 5.003_93 1997-Mar-10
+ 5.003_94 1997-Mar-22
+ 5.003_95 1997-Mar-25
+ 5.003_96 1997-Apr-01
+ 5.003_97 1997-Apr-03 Fairly widely used.
+ 5.003_97a 1997-Apr-05
+ 5.003_97b 1997-Apr-08
+ 5.003_97c 1997-Apr-10
+ 5.003_97d 1997-Apr-13
+ 5.003_97e 1997-Apr-15
+ 5.003_97f 1997-Apr-17
+ 5.003_97g 1997-Apr-18
+ 5.003_97h 1997-Apr-24
+ 5.003_97i 1997-Apr-25
+ 5.003_97j 1997-Apr-28
+ 5.003_98 1997-Apr-30
+ 5.003_99 1997-May-01
+ 5.003_99a 1997-May-09
+ p54rc1 1997-May-12 Release Candidates.
+ p54rc2 1997-May-14
+
+ Chip 5.004 1997-May-15 A major maintenance release.
+
+ Tim 5.004_01 1997-Jun-13 The 5.004 maintenance track.
+ 5.004_02 1997-Aug-07
+ 5.004_03 1997-Sep-05
+ 5.004_04 1997-Oct-15
+ 5.004m5t1 1998-Mar-04 Maintenance Trials (for 5.004_05).
+ 5.004_04-m2 1997-May-01
+ 5.004_04-m3 1998-May-15
+ 5.004_04-m4 1998-May-19
+ 5.004_04-MT5 1998-Jul-21
+
+ Malcolm 5.004_50 1997-Sep-09 The 5.005 development track.
+ 5.004_51 1997-Oct-02
+ 5.004_52 1997-Oct-15
+ 5.004_53 1997-Oct-16
+ 5.004_54 1997-Nov-14
+ 5.004_55 1997-Nov-25
+ 5.004_56 1997-Dec-18
+ 5.004_57 1998-Feb-03
+ 5.004_58 1998-Feb-06
+ 5.004_59 1998-Feb-13
+ 5.004_60 1998-Feb-20
+ 5.004_61 1998-Feb-27
+ 5.004_62 1998-Mar-06
+ 5.004_63 1998-Mar-17
+ 5.004_64 1998-Apr-03
+ 5.004_65 1998-May-15
+ 5.004_66 1998-May-29
+ Sarathy 5.004_67 1998-Jun-15
+ 5.004_68 1998-Jun-23
+ 5.004_69 1998-Jun-29
+ 5.004_70 1998-Jul-06
+ 5.004_71 1998-Jul-09
+ 5.004_72 1998-Jul-12
+ 5.004_73 1998-Jul-13
+ 5.004_74 1998-Jul-14 5.005 beta candidate.
+ 5.004_75 1998-Jul-15 5.005 beta1.
+ 5.004_76 1998-Jul-21 5.005 beta2.
+ 5.005 1998-Jul-22 Oneperl.
+
+ Sarathy 5.005_01 1998-Jul-27 The 5.005 maintenance track.
+ 5.005_02-T1 1998-Aug-02
+ 5.005_02-T2 1998-Aug-05
+ 5.005_02 1998-Aug-08
+ Graham 5.005_03 1998-
+
+ Sarathy 5.005_50 1998-Jul-26 The 5.006 development track.
+
+=head2 SELECTED RELEASE SIZES
+
+For example the notation "core: 212 29" in the release 1.000 means that
+it had in the core 212 kilobytes, in 29 files. The "core".."doc" are
+explained below.
+
+ release core lib ext t doc
+ ======================================================================
+
+ 1.000 212 29 - - - - 38 51 62 3
+ 1.014 219 29 - - - - 39 52 68 4
+ 2.000 309 31 2 3 - - 55 57 92 4
+ 2.001 312 31 2 3 - - 55 57 94 4
+ 3.000 508 36 24 11 - - 79 73 156 5
+ 3.044 645 37 61 20 - - 90 74 190 6
+ 4.000 635 37 59 20 - - 91 75 198 4
+ 4.019 680 37 85 29 - - 98 76 199 4
+ 4.036 709 37 89 30 - - 98 76 208 5
+ 5.000alpha2 785 50 114 32 - - 112 86 209 5
+ 5.000alpha3 801 50 117 33 - - 121 87 209 5
+ 5.000alpha9 1022 56 149 43 116 29 125 90 217 6
+ 5.000a12h 978 49 140 49 205 46 152 97 228 9
+ 5.000b3h 1035 53 232 70 216 38 162 94 218 21
+ 5.000 1038 53 250 76 216 38 154 92 536 62
+ 5.001m 1071 54 388 82 240 38 159 95 544 29
+ 5.002 1121 54 661 101 287 43 155 94 847 35
+ 5.003 1129 54 680 102 291 43 166 100 853 35
+ 5.003_07 1231 60 748 106 396 53 213 137 976 39
+ 5.004 1351 60 1230 136 408 51 355 161 1587 55
+ 5.004_01 1356 60 1258 138 410 51 358 161 1587 55
+ 5.004_04 1375 60 1294 139 413 51 394 162 1629 55
+ 5.004_51 1401 61 1260 140 413 53 358 162 1594 56
+ 5.004_53 1422 62 1295 141 438 70 394 162 1637 56
+ 5.004_56 1501 66 1301 140 447 74 408 165 1648 57
+ 5.004_59 1555 72 1317 142 448 74 424 171 1678 58
+ 5.004_62 1602 77 1327 144 629 92 428 173 1674 58
+ 5.004_65 1626 77 1358 146 615 92 446 179 1698 60
+ 5.004_68 1856 74 1382 152 619 92 463 187 1784 60
+ 5.004_70 1863 75 1456 154 675 92 494 194 1809 60
+ 5.004_73 1874 76 1467 152 762 102 506 196 1883 61
+ 5.004_75 1877 76 1467 152 770 103 508 196 1896 62
+ 5.005 1896 76 1469 152 795 103 509 197 1945 63
+
+The "core"..."doc" mean the following files from the Perl source code
+distribution. The glob notation ** means recursively, (.) means
+regular files.
+
+ core *.[hcy]
+ lib lib/**/*.p[ml]
+ ext ext/**/*.{[hcyt],xs,pm}
+ t t/**/*(.)
+ doc {README*,INSTALL,*[_.]man{,.?},pod/**/*.pod}
+
+Here are some statistics for the other subdirectories and one file in
+the Perl source distribution for somewhat more selected releases.
+
+ ======================================================================
+ Legend: kB #
+
+ 1.014 2.001 3.044 4.000 4.019 4.036
+
+ atarist - - - - - - - - - - 113 31
+ Configure 31 1 37 1 62 1 73 1 83 1 86 1
+ eg - - 34 28 47 39 47 39 47 39 47 39
+ emacs - - - - - - 67 4 67 4 67 4
+ h2pl - - - - 12 12 12 12 12 12 12 12
+ hints - - - - - - - - 5 42 11 56
+ msdos - - - - 41 13 57 15 58 15 60 15
+ os2 - - - - 63 22 81 29 81 29 113 31
+ usub - - - - 21 16 25 7 43 8 43 8
+ x2p 103 17 104 17 137 17 147 18 152 19 154 19
+
+ ======================================================================
+
+ 5.000a2 5.000a12h 5.000b3h 5.000 5.001m 5.002 5.003
+
+ atarist 113 31 113 31 - - - - - - - - - -
+ bench - - 0 1 - - - - - - - - - -
+ Bugs 2 5 26 1 - - - - - - - - - -
+ dlperl 40 5 - - - - - - - - - - - -
+ do 127 71 - - - - - - - - - - - -
+ Configure - - 153 1 159 1 160 1 180 1 201 1 201 1
+ Doc - - 26 1 75 7 11 1 11 1 - - - -
+ eg 79 58 53 44 51 43 54 44 54 44 54 44 54 44
+ emacs 67 4 104 6 104 6 104 1 104 6 108 1 108 1
+ h2pl 12 12 12 12 12 12 12 12 12 12 12 12 12 12
+ hints 11 56 12 46 18 48 18 48 44 56 73 59 77 60
+ msdos 60 15 60 15 - - - - - - - - - -
+ os2 113 31 113 31 - - - - - - 84 17 56 10
+ U - - 62 8 112 42 - - - - - - - -
+ usub 43 8 - - - - - - - - - - - -
+ utils - - - - - - - - - - 87 7 88 7
+ vms - - 80 7 123 9 184 15 304 20 500 24 475 26
+ x2p 171 22 171 21 162 20 162 20 279 20 280 20 280 20
+
+ ======================================================================
+
+ 5.003_07 5.004 5.004_04 5.004_62 5.004_65 5.004_68
+
+ beos - - - - - - - - 1 1 1 1
+ Configure 217 1 225 1 225 1 240 1 248 1 256 1
+ cygwin32 - - 23 5 23 5 23 5 24 5 24 5
+ djgpp - - - - - - 14 5 14 5 14 5
+ eg 54 44 81 62 81 62 81 62 81 62 81 62
+ emacs 143 1 194 1 204 1 212 2 212 2 212 2
+ h2pl 12 12 12 12 12 12 12 12 12 12 12 12
+ hints 90 62 129 69 132 71 144 72 151 74 155 74
+ os2 117 42 121 42 127 42 127 44 129 44 129 44
+ plan9 79 15 82 15 82 15 82 15 82 15 82 15
+ Porting 51 1 94 2 109 4 203 6 234 8 241 9
+ qnx - - 1 2 1 2 1 2 1 2 1 2
+ utils 97 7 112 8 118 8 124 8 156 9 159 9
+ vms 505 27 518 34 524 34 538 34 569 34 569 34
+ win32 - - 285 33 378 36 470 39 493 39 575 41
+ x2p 280 19 281 19 281 19 281 19 282 19 281 19
+
+ ======================================================================
+
+ 5.004_70 5.004_73 5.004_75 5.005
+
+ beos 1 1 1 1 1 1 1 1
+ Configure 256 1 256 1 264 1 264 1
+ cygwin32 24 5 24 5 24 5 24 5
+ djgpp 14 5 14 5 14 5 14 5
+ eg 86 65 86 65 86 65 86 65
+ emacs 262 2 262 2 262 2 262 2
+ h2pl 12 12 12 12 12 12 12 12
+ hints 157 74 157 74 159 74 160 74
+ mpeix - - - - 5 3 5 3
+ os2 129 44 139 44 142 44 143 44
+ plan9 82 15 82 15 82 15 82 15
+ Porting 241 9 253 9 259 10 264 12
+ qnx 1 2 1 2 1 2 1 2
+ utils 160 9 160 9 160 9 160 9
+ vms 570 34 572 34 573 34 575 34
+ win32 577 41 585 41 585 41 587 41
+ x2p 281 19 281 19 281 19 281 19
+
+=head2 SELECTED PATCH SIZES
+
+The "diff lines kb" means that for example the patch 5.003_08, to be
+applied on top of the 5.003_07 (or whatever was before the 5.003_08)
+added lines for 110 kilobytes, it removed lines for 19 kilobytes, and
+changed lines for 424 kilobytes. Just the lines themselves are
+counted, not their context. The "+ - !" become from the diff(1)s
+context diff output format.
+
+ Pump- Release Date diff lines kB
+ king + - !
+ ===========================================================================
+
+ Chip 5.003_08 1996-Nov-19 110 19 424
+ 5.003_09 1996-Nov-26 38 9 248
+ 5.003_10 1996-Nov-29 29 2 27
+ 5.003_11 1996-Dec-06 73 12 165
+ 5.003_12 1996-Dec-19 275 6 436
+ 5.003_13 1996-Dec-20 95 1 56
+ 5.003_14 1996-Dec-23 23 7 333
+ 5.003_15 1996-Dec-23 0 0 1
+ 5.003_16 1996-Dec-24 12 3 50
+ 5.003_17 1996-Dec-27 19 1 14
+ 5.003_18 1996-Dec-31 21 1 32
+ 5.003_19 1997-Jan-04 80 3 85
+ 5.003_20 1997-Jan-07 18 1 146
+ 5.003_21 1997-Jan-15 38 10 221
+ 5.003_22 1997-Jan-16 4 0 18
+ 5.003_23 1997-Jan-25 71 15 119
+ 5.003_24 1997-Jan-29 426 1 20
+ 5.003_25 1997-Feb-04 21 8 169
+ 5.003_26 1997-Feb-10 16 1 15
+ 5.003_27 1997-Feb-18 32 10 38
+ 5.003_28 1997-Feb-21 58 4 66
+ 5.003_90 1997-Feb-25 22 2 34
+ 5.003_91 1997-Mar-01 37 1 39
+ 5.003_92 1997-Mar-06 16 3 69
+ 5.003_93 1997-Mar-10 12 3 15
+ 5.003_94 1997-Mar-22 407 7 200
+ 5.003_95 1997-Mar-25 41 1 37
+ 5.003_96 1997-Apr-01 283 5 261
+ 5.003_97 1997-Apr-03 13 2 34
+ 5.003_97a 1997-Apr-05 57 1 27
+ 5.003_97b 1997-Apr-08 14 1 20
+ 5.003_97c 1997-Apr-10 20 1 16
+ 5.003_97d 1997-Apr-13 8 0 16
+ 5.003_97e 1997-Apr-15 15 4 46
+ 5.003_97f 1997-Apr-17 7 1 33
+ 5.003_97g 1997-Apr-18 6 1 42
+ 5.003_97h 1997-Apr-24 23 3 68
+ 5.003_97i 1997-Apr-25 23 1 31
+ 5.003_97j 1997-Apr-28 36 1 49
+ 5.003_98 1997-Apr-30 171 12 539
+ 5.003_99 1997-May-01 6 0 7
+ 5.003_99a 1997-May-09 36 2 61
+ p54rc1 1997-May-12 8 1 11
+ p54rc2 1997-May-14 6 0 40
+
+ 5.004 1997-May-15 4 0 4
+
+ Tim 5.004_01 1997-Jun-13 222 14 57
+ 5.004_02 1997-Aug-07 112 16 119
+ 5.004_03 1997-Sep-05 109 0 17
+ 5.004_04 1997-Oct-15 66 8 173
+
+=head1 THE KEEPERS OF THE RECORDS
+
+Jarkko Hietaniemi <F<jhi@iki.fi>>.
+
+Thanks to the collective memory of the Perlfolk. In addition to the
+Keepers of the Pumpkin also Alan Champion, Andreas König, John
+Macdonald, Matthias Neeracher, Michael Peppler, Randal Schwartz, and
+Paul D. Smith sent corrections and additions.
+
+=cut
diff --git a/contrib/perl5/pod/perlipc.pod b/contrib/perl5/pod/perlipc.pod
new file mode 100644
index 0000000..59c5ad9
--- /dev/null
+++ b/contrib/perl5/pod/perlipc.pod
@@ -0,0 +1,1443 @@
+=head1 NAME
+
+perlipc - Perl interprocess communication (signals, fifos, pipes, safe subprocesses, sockets, and semaphores)
+
+=head1 DESCRIPTION
+
+The basic IPC facilities of Perl are built out of the good old Unix
+signals, named pipes, pipe opens, the Berkeley socket routines, and SysV
+IPC calls. Each is used in slightly different situations.
+
+=head1 Signals
+
+Perl uses a simple signal handling model: the %SIG hash contains names or
+references of user-installed signal handlers. These handlers will be called
+with an argument which is the name of the signal that triggered it. A
+signal may be generated intentionally from a particular keyboard sequence like
+control-C or control-Z, sent to you from another process, or
+triggered automatically by the kernel when special events transpire, like
+a child process exiting, your process running out of stack space, or
+hitting file size limit.
+
+For example, to trap an interrupt signal, set up a handler like this.
+Do as little as you possibly can in your handler; notice how all we do is
+set a global variable and then raise an exception. That's because on most
+systems, libraries are not re-entrant; particularly, memory allocation and
+I/O routines are not. That means that doing nearly I<anything> in your
+handler could in theory trigger a memory fault and subsequent core dump.
+
+ sub catch_zap {
+ my $signame = shift;
+ $shucks++;
+ die "Somebody sent me a SIG$signame";
+ }
+ $SIG{INT} = 'catch_zap'; # could fail in modules
+ $SIG{INT} = \&catch_zap; # best strategy
+
+The names of the signals are the ones listed out by C<kill -l> on your
+system, or you can retrieve them from the Config module. Set up an
+@signame list indexed by number to get the name and a %signo table
+indexed by name to get the number:
+
+ use Config;
+ defined $Config{sig_name} || die "No sigs?";
+ foreach $name (split(' ', $Config{sig_name})) {
+ $signo{$name} = $i;
+ $signame[$i] = $name;
+ $i++;
+ }
+
+So to check whether signal 17 and SIGALRM were the same, do just this:
+
+ print "signal #17 = $signame[17]\n";
+ if ($signo{ALRM}) {
+ print "SIGALRM is $signo{ALRM}\n";
+ }
+
+You may also choose to assign the strings C<'IGNORE'> or C<'DEFAULT'> as
+the handler, in which case Perl will try to discard the signal or do the
+default thing. Some signals can be neither trapped nor ignored, such as
+the KILL and STOP (but not the TSTP) signals. One strategy for
+temporarily ignoring signals is to use a local() statement, which will be
+automatically restored once your block is exited. (Remember that local()
+values are "inherited" by functions called from within that block.)
+
+ sub precious {
+ local $SIG{INT} = 'IGNORE';
+ &more_functions;
+ }
+ sub more_functions {
+ # interrupts still ignored, for now...
+ }
+
+Sending a signal to a negative process ID means that you send the signal
+to the entire Unix process-group. This code sends a hang-up signal to all
+processes in the current process group (and sets $SIG{HUP} to IGNORE so
+it doesn't kill itself):
+
+ {
+ local $SIG{HUP} = 'IGNORE';
+ kill HUP => -$$;
+ # snazzy writing of: kill('HUP', -$$)
+ }
+
+Another interesting signal to send is signal number zero. This doesn't
+actually affect another process, but instead checks whether it's alive
+or has changed its UID.
+
+ unless (kill 0 => $kid_pid) {
+ warn "something wicked happened to $kid_pid";
+ }
+
+You might also want to employ anonymous functions for simple signal
+handlers:
+
+ $SIG{INT} = sub { die "\nOutta here!\n" };
+
+But that will be problematic for the more complicated handlers that need
+to reinstall themselves. Because Perl's signal mechanism is currently
+based on the signal(3) function from the C library, you may sometimes be so
+misfortunate as to run on systems where that function is "broken", that
+is, it behaves in the old unreliable SysV way rather than the newer, more
+reasonable BSD and POSIX fashion. So you'll see defensive people writing
+signal handlers like this:
+
+ sub REAPER {
+ $waitedpid = wait;
+ # loathe sysV: it makes us not only reinstate
+ # the handler, but place it after the wait
+ $SIG{CHLD} = \&REAPER;
+ }
+ $SIG{CHLD} = \&REAPER;
+ # now do something that forks...
+
+or even the more elaborate:
+
+ use POSIX ":sys_wait_h";
+ sub REAPER {
+ my $child;
+ while ($child = waitpid(-1,WNOHANG)) {
+ $Kid_Status{$child} = $?;
+ }
+ $SIG{CHLD} = \&REAPER; # still loathe sysV
+ }
+ $SIG{CHLD} = \&REAPER;
+ # do something that forks...
+
+Signal handling is also used for timeouts in Unix, While safely
+protected within an C<eval{}> block, you set a signal handler to trap
+alarm signals and then schedule to have one delivered to you in some
+number of seconds. Then try your blocking operation, clearing the alarm
+when it's done but not before you've exited your C<eval{}> block. If it
+goes off, you'll use die() to jump out of the block, much as you might
+using longjmp() or throw() in other languages.
+
+Here's an example:
+
+ eval {
+ local $SIG{ALRM} = sub { die "alarm clock restart" };
+ alarm 10;
+ flock(FH, 2); # blocking write lock
+ alarm 0;
+ };
+ if ($@ and $@ !~ /alarm clock restart/) { die }
+
+For more complex signal handling, you might see the standard POSIX
+module. Lamentably, this is almost entirely undocumented, but
+the F<t/lib/posix.t> file from the Perl source distribution has some
+examples in it.
+
+=head1 Named Pipes
+
+A named pipe (often referred to as a FIFO) is an old Unix IPC
+mechanism for processes communicating on the same machine. It works
+just like a regular, connected anonymous pipes, except that the
+processes rendezvous using a filename and don't have to be related.
+
+To create a named pipe, use the Unix command mknod(1) or on some
+systems, mkfifo(1). These may not be in your normal path.
+
+ # system return val is backwards, so && not ||
+ #
+ $ENV{PATH} .= ":/etc:/usr/etc";
+ if ( system('mknod', $path, 'p')
+ && system('mkfifo', $path) )
+ {
+ die "mk{nod,fifo} $path failed";
+ }
+
+
+A fifo is convenient when you want to connect a process to an unrelated
+one. When you open a fifo, the program will block until there's something
+on the other end.
+
+For example, let's say you'd like to have your F<.signature> file be a
+named pipe that has a Perl program on the other end. Now every time any
+program (like a mailer, news reader, finger program, etc.) tries to read
+from that file, the reading program will block and your program will
+supply the new signature. We'll use the pipe-checking file test B<-p>
+to find out whether anyone (or anything) has accidentally removed our fifo.
+
+ chdir; # go home
+ $FIFO = '.signature';
+ $ENV{PATH} .= ":/etc:/usr/games";
+
+ while (1) {
+ unless (-p $FIFO) {
+ unlink $FIFO;
+ system('mknod', $FIFO, 'p')
+ && die "can't mknod $FIFO: $!";
+ }
+
+ # next line blocks until there's a reader
+ open (FIFO, "> $FIFO") || die "can't write $FIFO: $!";
+ print FIFO "John Smith (smith\@host.org)\n", `fortune -s`;
+ close FIFO;
+ sleep 2; # to avoid dup signals
+ }
+
+=head2 WARNING
+
+By installing Perl code to deal with signals, you're exposing yourself
+to danger from two things. First, few system library functions are
+re-entrant. If the signal interrupts while Perl is executing one function
+(like malloc(3) or printf(3)), and your signal handler then calls the
+same function again, you could get unpredictable behavior--often, a
+core dump. Second, Perl isn't itself re-entrant at the lowest levels.
+If the signal interrupts Perl while Perl is changing its own internal
+data structures, similarly unpredictable behaviour may result.
+
+There are two things you can do, knowing this: be paranoid or be
+pragmatic. The paranoid approach is to do as little as possible in your
+signal handler. Set an existing integer variable that already has a
+value, and return. This doesn't help you if you're in a slow system call,
+which will just restart. That means you have to C<die> to longjump(3) out
+of the handler. Even this is a little cavalier for the true paranoiac,
+who avoids C<die> in a handler because the system I<is> out to get you.
+The pragmatic approach is to say ``I know the risks, but prefer the
+convenience'', and to do anything you want in your signal handler,
+prepared to clean up core dumps now and again.
+
+To forbid signal handlers altogether would bars you from
+many interesting programs, including virtually everything in this manpage,
+since you could no longer even write SIGCHLD handlers. Their dodginess
+is expected to be addresses in the 5.005 release.
+
+
+=head1 Using open() for IPC
+
+Perl's basic open() statement can also be used for unidirectional interprocess
+communication by either appending or prepending a pipe symbol to the second
+argument to open(). Here's how to start something up in a child process you
+intend to write to:
+
+ open(SPOOLER, "| cat -v | lpr -h 2>/dev/null")
+ || die "can't fork: $!";
+ local $SIG{PIPE} = sub { die "spooler pipe broke" };
+ print SPOOLER "stuff\n";
+ close SPOOLER || die "bad spool: $! $?";
+
+And here's how to start up a child process you intend to read from:
+
+ open(STATUS, "netstat -an 2>&1 |")
+ || die "can't fork: $!";
+ while (<STATUS>) {
+ next if /^(tcp|udp)/;
+ print;
+ }
+ close STATUS || die "bad netstat: $! $?";
+
+If one can be sure that a particular program is a Perl script that is
+expecting filenames in @ARGV, the clever programmer can write something
+like this:
+
+ % program f1 "cmd1|" - f2 "cmd2|" f3 < tmpfile
+
+and irrespective of which shell it's called from, the Perl program will
+read from the file F<f1>, the process F<cmd1>, standard input (F<tmpfile>
+in this case), the F<f2> file, the F<cmd2> command, and finally the F<f3>
+file. Pretty nifty, eh?
+
+You might notice that you could use backticks for much the
+same effect as opening a pipe for reading:
+
+ print grep { !/^(tcp|udp)/ } `netstat -an 2>&1`;
+ die "bad netstat" if $?;
+
+While this is true on the surface, it's much more efficient to process the
+file one line or record at a time because then you don't have to read the
+whole thing into memory at once. It also gives you finer control of the
+whole process, letting you to kill off the child process early if you'd
+like.
+
+Be careful to check both the open() and the close() return values. If
+you're I<writing> to a pipe, you should also trap SIGPIPE. Otherwise,
+think of what happens when you start up a pipe to a command that doesn't
+exist: the open() will in all likelihood succeed (it only reflects the
+fork()'s success), but then your output will fail--spectacularly. Perl
+can't know whether the command worked because your command is actually
+running in a separate process whose exec() might have failed. Therefore,
+while readers of bogus commands return just a quick end of file, writers
+to bogus command will trigger a signal they'd better be prepared to
+handle. Consider:
+
+ open(FH, "|bogus") or die "can't fork: $!";
+ print FH "bang\n" or die "can't write: $!";
+ close FH or die "can't close: $!";
+
+That won't blow up until the close, and it will blow up with a SIGPIPE.
+To catch it, you could use this:
+
+ $SIG{PIPE} = 'IGNORE';
+ open(FH, "|bogus") or die "can't fork: $!";
+ print FH "bang\n" or die "can't write: $!";
+ close FH or die "can't close: status=$?";
+
+=head2 Filehandles
+
+Both the main process and any child processes it forks share the same
+STDIN, STDOUT, and STDERR filehandles. If both processes try to access
+them at once, strange things can happen. You'll certainly want to any
+stdio flush output buffers before forking. You may also want to close
+or reopen the filehandles for the child. You can get around this by
+opening your pipe with open(), but on some systems this means that the
+child process cannot outlive the parent.
+
+=head2 Background Processes
+
+You can run a command in the background with:
+
+ system("cmd &");
+
+The command's STDOUT and STDERR (and possibly STDIN, depending on your
+shell) will be the same as the parent's. You won't need to catch
+SIGCHLD because of the double-fork taking place (see below for more
+details).
+
+=head2 Complete Dissociation of Child from Parent
+
+In some cases (starting server processes, for instance) you'll want to
+complete dissociate the child process from the parent. The easiest
+way is to use:
+
+ use POSIX qw(setsid);
+ setsid() or die "Can't start a new session: $!";
+
+However, you may not be on POSIX. The following process is reported
+to work on most Unixish systems. Non-Unix users should check their
+Your_OS::Process module for other solutions.
+
+=over 4
+
+=item *
+
+Open /dev/tty and use the TIOCNOTTY ioctl on it. See L<tty(4)>
+for details.
+
+=item *
+
+Change directory to /
+
+=item *
+
+Reopen STDIN, STDOUT, and STDERR so they're not connected to the old
+tty.
+
+=item *
+
+Background yourself like this:
+
+ fork && exit;
+
+=item *
+
+Ignore hangup signals in case you're running on a shell that doesn't
+automatically no-hup you:
+
+ $SIG{HUP} = 'IGNORE'; # or whatever you'd like
+
+=back
+
+=head2 Safe Pipe Opens
+
+Another interesting approach to IPC is making your single program go
+multiprocess and communicate between (or even amongst) yourselves. The
+open() function will accept a file argument of either C<"-|"> or C<"|-">
+to do a very interesting thing: it forks a child connected to the
+filehandle you've opened. The child is running the same program as the
+parent. This is useful for safely opening a file when running under an
+assumed UID or GID, for example. If you open a pipe I<to> minus, you can
+write to the filehandle you opened and your kid will find it in his
+STDIN. If you open a pipe I<from> minus, you can read from the filehandle
+you opened whatever your kid writes to his STDOUT.
+
+ use English;
+ my $sleep_count = 0;
+
+ do {
+ $pid = open(KID_TO_WRITE, "|-");
+ unless (defined $pid) {
+ warn "cannot fork: $!";
+ die "bailing out" if $sleep_count++ > 6;
+ sleep 10;
+ }
+ } until defined $pid;
+
+ if ($pid) { # parent
+ print KID_TO_WRITE @some_data;
+ close(KID_TO_WRITE) || warn "kid exited $?";
+ } else { # child
+ ($EUID, $EGID) = ($UID, $GID); # suid progs only
+ open (FILE, "> /safe/file")
+ || die "can't open /safe/file: $!";
+ while (<STDIN>) {
+ print FILE; # child's STDIN is parent's KID
+ }
+ exit; # don't forget this
+ }
+
+Another common use for this construct is when you need to execute
+something without the shell's interference. With system(), it's
+straightforward, but you can't use a pipe open or backticks safely.
+That's because there's no way to stop the shell from getting its hands on
+your arguments. Instead, use lower-level control to call exec() directly.
+
+Here's a safe backtick or pipe open for read:
+
+ # add error processing as above
+ $pid = open(KID_TO_READ, "-|");
+
+ if ($pid) { # parent
+ while (<KID_TO_READ>) {
+ # do something interesting
+ }
+ close(KID_TO_READ) || warn "kid exited $?";
+
+ } else { # child
+ ($EUID, $EGID) = ($UID, $GID); # suid only
+ exec($program, @options, @args)
+ || die "can't exec program: $!";
+ # NOTREACHED
+ }
+
+
+And here's a safe pipe open for writing:
+
+ # add error processing as above
+ $pid = open(KID_TO_WRITE, "|-");
+ $SIG{ALRM} = sub { die "whoops, $program pipe broke" };
+
+ if ($pid) { # parent
+ for (@data) {
+ print KID_TO_WRITE;
+ }
+ close(KID_TO_WRITE) || warn "kid exited $?";
+
+ } else { # child
+ ($EUID, $EGID) = ($UID, $GID);
+ exec($program, @options, @args)
+ || die "can't exec program: $!";
+ # NOTREACHED
+ }
+
+Note that these operations are full Unix forks, which means they may not be
+correctly implemented on alien systems. Additionally, these are not true
+multithreading. If you'd like to learn more about threading, see the
+F<modules> file mentioned below in the SEE ALSO section.
+
+=head2 Bidirectional Communication with Another Process
+
+While this works reasonably well for unidirectional communication, what
+about bidirectional communication? The obvious thing you'd like to do
+doesn't actually work:
+
+ open(PROG_FOR_READING_AND_WRITING, "| some program |")
+
+and if you forget to use the B<-w> flag, then you'll miss out
+entirely on the diagnostic message:
+
+ Can't do bidirectional pipe at -e line 1.
+
+If you really want to, you can use the standard open2() library function
+to catch both ends. There's also an open3() for tridirectional I/O so you
+can also catch your child's STDERR, but doing so would then require an
+awkward select() loop and wouldn't allow you to use normal Perl input
+operations.
+
+If you look at its source, you'll see that open2() uses low-level
+primitives like Unix pipe() and exec() calls to create all the connections.
+While it might have been slightly more efficient by using socketpair(), it
+would have then been even less portable than it already is. The open2()
+and open3() functions are unlikely to work anywhere except on a Unix
+system or some other one purporting to be POSIX compliant.
+
+Here's an example of using open2():
+
+ use FileHandle;
+ use IPC::Open2;
+ $pid = open2(*Reader, *Writer, "cat -u -n" );
+ Writer->autoflush(); # default here, actually
+ print Writer "stuff\n";
+ $got = <Reader>;
+
+The problem with this is that Unix buffering is really going to
+ruin your day. Even though your C<Writer> filehandle is auto-flushed,
+and the process on the other end will get your data in a timely manner,
+you can't usually do anything to force it to give it back to you
+in a similarly quick fashion. In this case, we could, because we
+gave I<cat> a B<-u> flag to make it unbuffered. But very few Unix
+commands are designed to operate over pipes, so this seldom works
+unless you yourself wrote the program on the other end of the
+double-ended pipe.
+
+A solution to this is the nonstandard F<Comm.pl> library. It uses
+pseudo-ttys to make your program behave more reasonably:
+
+ require 'Comm.pl';
+ $ph = open_proc('cat -n');
+ for (1..10) {
+ print $ph "a line\n";
+ print "got back ", scalar <$ph>;
+ }
+
+This way you don't have to have control over the source code of the
+program you're using. The F<Comm> library also has expect()
+and interact() functions. Find the library (and we hope its
+successor F<IPC::Chat>) at your nearest CPAN archive as detailed
+in the SEE ALSO section below.
+
+The newer Expect.pm module from CPAN also addresses this kind of thing.
+This module requires two other modules from CPAN: IO::Pty and IO::Stty.
+It sets up a pseudo-terminal to interact with programs that insist on
+using talking to the terminal device driver. If your system is
+amongst those supported, this may be your best bet.
+
+=head2 Bidirectional Communication with Yourself
+
+If you want, you may make low-level pipe() and fork()
+to stitch this together by hand. This example only
+talks to itself, but you could reopen the appropriate
+handles to STDIN and STDOUT and call other processes.
+
+ #!/usr/bin/perl -w
+ # pipe1 - bidirectional communication using two pipe pairs
+ # designed for the socketpair-challenged
+ use IO::Handle; # thousands of lines just for autoflush :-(
+ pipe(PARENT_RDR, CHILD_WTR); # XXX: failure?
+ pipe(CHILD_RDR, PARENT_WTR); # XXX: failure?
+ CHILD_WTR->autoflush(1);
+ PARENT_WTR->autoflush(1);
+
+ if ($pid = fork) {
+ close PARENT_RDR; close PARENT_WTR;
+ print CHILD_WTR "Parent Pid $$ is sending this\n";
+ chomp($line = <CHILD_RDR>);
+ print "Parent Pid $$ just read this: `$line'\n";
+ close CHILD_RDR; close CHILD_WTR;
+ waitpid($pid,0);
+ } else {
+ die "cannot fork: $!" unless defined $pid;
+ close CHILD_RDR; close CHILD_WTR;
+ chomp($line = <PARENT_RDR>);
+ print "Child Pid $$ just read this: `$line'\n";
+ print PARENT_WTR "Child Pid $$ is sending this\n";
+ close PARENT_RDR; close PARENT_WTR;
+ exit;
+ }
+
+But you don't actually have to make two pipe calls. If you
+have the socketpair() system call, it will do this all for you.
+
+ #!/usr/bin/perl -w
+ # pipe2 - bidirectional communication using socketpair
+ # "the best ones always go both ways"
+
+ use Socket;
+ use IO::Handle; # thousands of lines just for autoflush :-(
+ # We say AF_UNIX because although *_LOCAL is the
+ # POSIX 1003.1g form of the constant, many machines
+ # still don't have it.
+ socketpair(CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
+ or die "socketpair: $!";
+
+ CHILD->autoflush(1);
+ PARENT->autoflush(1);
+
+ if ($pid = fork) {
+ close PARENT;
+ print CHILD "Parent Pid $$ is sending this\n";
+ chomp($line = <CHILD>);
+ print "Parent Pid $$ just read this: `$line'\n";
+ close CHILD;
+ waitpid($pid,0);
+ } else {
+ die "cannot fork: $!" unless defined $pid;
+ close CHILD;
+ chomp($line = <PARENT>);
+ print "Child Pid $$ just read this: `$line'\n";
+ print PARENT "Child Pid $$ is sending this\n";
+ close PARENT;
+ exit;
+ }
+
+=head1 Sockets: Client/Server Communication
+
+While not limited to Unix-derived operating systems (e.g., WinSock on PCs
+provides socket support, as do some VMS libraries), you may not have
+sockets on your system, in which case this section probably isn't going to do
+you much good. With sockets, you can do both virtual circuits (i.e., TCP
+streams) and datagrams (i.e., UDP packets). You may be able to do even more
+depending on your system.
+
+The Perl function calls for dealing with sockets have the same names as
+the corresponding system calls in C, but their arguments tend to differ
+for two reasons: first, Perl filehandles work differently than C file
+descriptors. Second, Perl already knows the length of its strings, so you
+don't need to pass that information.
+
+One of the major problems with old socket code in Perl was that it used
+hard-coded values for some of the constants, which severely hurt
+portability. If you ever see code that does anything like explicitly
+setting C<$AF_INET = 2>, you know you're in for big trouble: An
+immeasurably superior approach is to use the C<Socket> module, which more
+reliably grants access to various constants and functions you'll need.
+
+If you're not writing a server/client for an existing protocol like
+NNTP or SMTP, you should give some thought to how your server will
+know when the client has finished talking, and vice-versa. Most
+protocols are based on one-line messages and responses (so one party
+knows the other has finished when a "\n" is received) or multi-line
+messages and responses that end with a period on an empty line
+("\n.\n" terminates a message/response).
+
+=head2 Internet Line Terminators
+
+The Internet line terminator is "\015\012". Under ASCII variants of
+Unix, that could usually be written as "\r\n", but under other systems,
+"\r\n" might at times be "\015\015\012", "\012\012\015", or something
+completely different. The standards specify writing "\015\012" to be
+conformant (be strict in what you provide), but they also recommend
+accepting a lone "\012" on input (but be lenient in what you require).
+We haven't always been very good about that in the code in this manpage,
+but unless you're on a Mac, you'll probably be ok.
+
+=head2 Internet TCP Clients and Servers
+
+Use Internet-domain sockets when you want to do client-server
+communication that might extend to machines outside of your own system.
+
+Here's a sample TCP client using Internet-domain sockets:
+
+ #!/usr/bin/perl -w
+ use strict;
+ use Socket;
+ my ($remote,$port, $iaddr, $paddr, $proto, $line);
+
+ $remote = shift || 'localhost';
+ $port = shift || 2345; # random port
+ if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
+ die "No port" unless $port;
+ $iaddr = inet_aton($remote) || die "no host: $remote";
+ $paddr = sockaddr_in($port, $iaddr);
+
+ $proto = getprotobyname('tcp');
+ socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
+ connect(SOCK, $paddr) || die "connect: $!";
+ while (defined($line = <SOCK>)) {
+ print $line;
+ }
+
+ close (SOCK) || die "close: $!";
+ exit;
+
+And here's a corresponding server to go along with it. We'll
+leave the address as INADDR_ANY so that the kernel can choose
+the appropriate interface on multihomed hosts. If you want sit
+on a particular interface (like the external side of a gateway
+or firewall machine), you should fill this in with your real address
+instead.
+
+ #!/usr/bin/perl -Tw
+ use strict;
+ BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
+ use Socket;
+ use Carp;
+ $EOL = "\015\012";
+
+ sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
+
+ my $port = shift || 2345;
+ my $proto = getprotobyname('tcp');
+ $port = $1 if $port =~ /(\d+)/; # untaint port number
+
+ socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
+ setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
+ pack("l", 1)) || die "setsockopt: $!";
+ bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
+ listen(Server,SOMAXCONN) || die "listen: $!";
+
+ logmsg "server started on port $port";
+
+ my $paddr;
+
+ $SIG{CHLD} = \&REAPER;
+
+ for ( ; $paddr = accept(Client,Server); close Client) {
+ my($port,$iaddr) = sockaddr_in($paddr);
+ my $name = gethostbyaddr($iaddr,AF_INET);
+
+ logmsg "connection from $name [",
+ inet_ntoa($iaddr), "]
+ at port $port";
+
+ print Client "Hello there, $name, it's now ",
+ scalar localtime, $EOL;
+ }
+
+And here's a multithreaded version. It's multithreaded in that
+like most typical servers, it spawns (forks) a slave server to
+handle the client request so that the master server can quickly
+go back to service a new client.
+
+ #!/usr/bin/perl -Tw
+ use strict;
+ BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
+ use Socket;
+ use Carp;
+ $EOL = "\015\012";
+
+ sub spawn; # forward declaration
+ sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
+
+ my $port = shift || 2345;
+ my $proto = getprotobyname('tcp');
+ $port = $1 if $port =~ /(\d+)/; # untaint port number
+
+ socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
+ setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
+ pack("l", 1)) || die "setsockopt: $!";
+ bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
+ listen(Server,SOMAXCONN) || die "listen: $!";
+
+ logmsg "server started on port $port";
+
+ my $waitedpid = 0;
+ my $paddr;
+
+ sub REAPER {
+ $waitedpid = wait;
+ $SIG{CHLD} = \&REAPER; # loathe sysV
+ logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
+ }
+
+ $SIG{CHLD} = \&REAPER;
+
+ for ( $waitedpid = 0;
+ ($paddr = accept(Client,Server)) || $waitedpid;
+ $waitedpid = 0, close Client)
+ {
+ next if $waitedpid and not $paddr;
+ my($port,$iaddr) = sockaddr_in($paddr);
+ my $name = gethostbyaddr($iaddr,AF_INET);
+
+ logmsg "connection from $name [",
+ inet_ntoa($iaddr), "]
+ at port $port";
+
+ spawn sub {
+ print "Hello there, $name, it's now ", scalar localtime, $EOL;
+ exec '/usr/games/fortune' # XXX: `wrong' line terminators
+ or confess "can't exec fortune: $!";
+ };
+
+ }
+
+ sub spawn {
+ my $coderef = shift;
+
+ unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
+ confess "usage: spawn CODEREF";
+ }
+
+ my $pid;
+ if (!defined($pid = fork)) {
+ logmsg "cannot fork: $!";
+ return;
+ } elsif ($pid) {
+ logmsg "begat $pid";
+ return; # I'm the parent
+ }
+ # else I'm the child -- go spawn
+
+ open(STDIN, "<&Client") || die "can't dup client to stdin";
+ open(STDOUT, ">&Client") || die "can't dup client to stdout";
+ ## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
+ exit &$coderef();
+ }
+
+This server takes the trouble to clone off a child version via fork() for
+each incoming request. That way it can handle many requests at once,
+which you might not always want. Even if you don't fork(), the listen()
+will allow that many pending connections. Forking servers have to be
+particularly careful about cleaning up their dead children (called
+"zombies" in Unix parlance), because otherwise you'll quickly fill up your
+process table.
+
+We suggest that you use the B<-T> flag to use taint checking (see L<perlsec>)
+even if we aren't running setuid or setgid. This is always a good idea
+for servers and other programs run on behalf of someone else (like CGI
+scripts), because it lessens the chances that people from the outside will
+be able to compromise your system.
+
+Let's look at another TCP client. This one connects to the TCP "time"
+service on a number of different machines and shows how far their clocks
+differ from the system on which it's being run:
+
+ #!/usr/bin/perl -w
+ use strict;
+ use Socket;
+
+ my $SECS_of_70_YEARS = 2208988800;
+ sub ctime { scalar localtime(shift) }
+
+ my $iaddr = gethostbyname('localhost');
+ my $proto = getprotobyname('tcp');
+ my $port = getservbyname('time', 'tcp');
+ my $paddr = sockaddr_in(0, $iaddr);
+ my($host);
+
+ $| = 1;
+ printf "%-24s %8s %s\n", "localhost", 0, ctime(time());
+
+ foreach $host (@ARGV) {
+ printf "%-24s ", $host;
+ my $hisiaddr = inet_aton($host) || die "unknown host";
+ my $hispaddr = sockaddr_in($port, $hisiaddr);
+ socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
+ connect(SOCKET, $hispaddr) || die "bind: $!";
+ my $rtime = ' ';
+ read(SOCKET, $rtime, 4);
+ close(SOCKET);
+ my $histime = unpack("N", $rtime) - $SECS_of_70_YEARS ;
+ printf "%8d %s\n", $histime - time, ctime($histime);
+ }
+
+=head2 Unix-Domain TCP Clients and Servers
+
+That's fine for Internet-domain clients and servers, but what about local
+communications? While you can use the same setup, sometimes you don't
+want to. Unix-domain sockets are local to the current host, and are often
+used internally to implement pipes. Unlike Internet domain sockets, Unix
+domain sockets can show up in the file system with an ls(1) listing.
+
+ % ls -l /dev/log
+ srw-rw-rw- 1 root 0 Oct 31 07:23 /dev/log
+
+You can test for these with Perl's B<-S> file test:
+
+ unless ( -S '/dev/log' ) {
+ die "something's wicked with the print system";
+ }
+
+Here's a sample Unix-domain client:
+
+ #!/usr/bin/perl -w
+ use Socket;
+ use strict;
+ my ($rendezvous, $line);
+
+ $rendezvous = shift || '/tmp/catsock';
+ socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
+ connect(SOCK, sockaddr_un($rendezvous)) || die "connect: $!";
+ while (defined($line = <SOCK>)) {
+ print $line;
+ }
+ exit;
+
+And here's a corresponding server. You don't have to worry about silly
+network terminators here because Unix domain sockets are guaranteed
+to be on the localhost, and thus everything works right.
+
+ #!/usr/bin/perl -Tw
+ use strict;
+ use Socket;
+ use Carp;
+
+ BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
+ sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
+
+ my $NAME = '/tmp/catsock';
+ my $uaddr = sockaddr_un($NAME);
+ my $proto = getprotobyname('tcp');
+
+ socket(Server,PF_UNIX,SOCK_STREAM,0) || die "socket: $!";
+ unlink($NAME);
+ bind (Server, $uaddr) || die "bind: $!";
+ listen(Server,SOMAXCONN) || die "listen: $!";
+
+ logmsg "server started on $NAME";
+
+ my $waitedpid;
+
+ sub REAPER {
+ $waitedpid = wait;
+ $SIG{CHLD} = \&REAPER; # loathe sysV
+ logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
+ }
+
+ $SIG{CHLD} = \&REAPER;
+
+
+ for ( $waitedpid = 0;
+ accept(Client,Server) || $waitedpid;
+ $waitedpid = 0, close Client)
+ {
+ next if $waitedpid;
+ logmsg "connection on $NAME";
+ spawn sub {
+ print "Hello there, it's now ", scalar localtime, "\n";
+ exec '/usr/games/fortune' or die "can't exec fortune: $!";
+ };
+ }
+
+As you see, it's remarkably similar to the Internet domain TCP server, so
+much so, in fact, that we've omitted several duplicate functions--spawn(),
+logmsg(), ctime(), and REAPER()--which are exactly the same as in the
+other server.
+
+So why would you ever want to use a Unix domain socket instead of a
+simpler named pipe? Because a named pipe doesn't give you sessions. You
+can't tell one process's data from another's. With socket programming,
+you get a separate session for each client: that's why accept() takes two
+arguments.
+
+For example, let's say that you have a long running database server daemon
+that you want folks from the World Wide Web to be able to access, but only
+if they go through a CGI interface. You'd have a small, simple CGI
+program that does whatever checks and logging you feel like, and then acts
+as a Unix-domain client and connects to your private server.
+
+=head1 TCP Clients with IO::Socket
+
+For those preferring a higher-level interface to socket programming, the
+IO::Socket module provides an object-oriented approach. IO::Socket is
+included as part of the standard Perl distribution as of the 5.004
+release. If you're running an earlier version of Perl, just fetch
+IO::Socket from CPAN, where you'll also find find modules providing easy
+interfaces to the following systems: DNS, FTP, Ident (RFC 931), NIS and
+NISPlus, NNTP, Ping, POP3, SMTP, SNMP, SSLeay, Telnet, and Time--just
+to name a few.
+
+=head2 A Simple Client
+
+Here's a client that creates a TCP connection to the "daytime"
+service at port 13 of the host name "localhost" and prints out everything
+that the server there cares to provide.
+
+ #!/usr/bin/perl -w
+ use IO::Socket;
+ $remote = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => "localhost",
+ PeerPort => "daytime(13)",
+ )
+ or die "cannot connect to daytime port at localhost";
+ while ( <$remote> ) { print }
+
+When you run this program, you should get something back that
+looks like this:
+
+ Wed May 14 08:40:46 MDT 1997
+
+Here are what those parameters to the C<new> constructor mean:
+
+=over
+
+=item C<Proto>
+
+This is which protocol to use. In this case, the socket handle returned
+will be connected to a TCP socket, because we want a stream-oriented
+connection, that is, one that acts pretty much like a plain old file.
+Not all sockets are this of this type. For example, the UDP protocol
+can be used to make a datagram socket, used for message-passing.
+
+=item C<PeerAddr>
+
+This is the name or Internet address of the remote host the server is
+running on. We could have specified a longer name like C<"www.perl.com">,
+or an address like C<"204.148.40.9">. For demonstration purposes, we've
+used the special hostname C<"localhost">, which should always mean the
+current machine you're running on. The corresponding Internet address
+for localhost is C<"127.1">, if you'd rather use that.
+
+=item C<PeerPort>
+
+This is the service name or port number we'd like to connect to.
+We could have gotten away with using just C<"daytime"> on systems with a
+well-configured system services file,[FOOTNOTE: The system services file
+is in I</etc/services> under Unix] but just in case, we've specified the
+port number (13) in parentheses. Using just the number would also have
+worked, but constant numbers make careful programmers nervous.
+
+=back
+
+Notice how the return value from the C<new> constructor is used as
+a filehandle in the C<while> loop? That's what's called an indirect
+filehandle, a scalar variable containing a filehandle. You can use
+it the same way you would a normal filehandle. For example, you
+can read one line from it this way:
+
+ $line = <$handle>;
+
+all remaining lines from is this way:
+
+ @lines = <$handle>;
+
+and send a line of data to it this way:
+
+ print $handle "some data\n";
+
+=head2 A Webget Client
+
+Here's a simple client that takes a remote host to fetch a document
+from, and then a list of documents to get from that host. This is a
+more interesting client than the previous one because it first sends
+something to the server before fetching the server's response.
+
+ #!/usr/bin/perl -w
+ use IO::Socket;
+ unless (@ARGV > 1) { die "usage: $0 host document ..." }
+ $host = shift(@ARGV);
+ $EOL = "\015\012";
+ $BLANK = $EOL x 2;
+ foreach $document ( @ARGV ) {
+ $remote = IO::Socket::INET->new( Proto => "tcp",
+ PeerAddr => $host,
+ PeerPort => "http(80)",
+ );
+ unless ($remote) { die "cannot connect to http daemon on $host" }
+ $remote->autoflush(1);
+ print $remote "GET $document HTTP/1.0" . $BLANK;
+ while ( <$remote> ) { print }
+ close $remote;
+ }
+
+The web server handing the "http" service, which is assumed to be at
+its standard port, number 80. If your the web server you're trying to
+connect to is at a different port (like 1080 or 8080), you should specify
+as the named-parameter pair, C<PeerPort =E<gt> 8080>. The C<autoflush>
+method is used on the socket because otherwise the system would buffer
+up the output we sent it. (If you're on a Mac, you'll also need to
+change every C<"\n"> in your code that sends data over the network to
+be a C<"\015\012"> instead.)
+
+Connecting to the server is only the first part of the process: once you
+have the connection, you have to use the server's language. Each server
+on the network has its own little command language that it expects as
+input. The string that we send to the server starting with "GET" is in
+HTTP syntax. In this case, we simply request each specified document.
+Yes, we really are making a new connection for each document, even though
+it's the same host. That's the way you always used to have to speak HTTP.
+Recent versions of web browsers may request that the remote server leave
+the connection open a little while, but the server doesn't have to honor
+such a request.
+
+Here's an example of running that program, which we'll call I<webget>:
+
+ % webget www.perl.com /guanaco.html
+ HTTP/1.1 404 File Not Found
+ Date: Thu, 08 May 1997 18:02:32 GMT
+ Server: Apache/1.2b6
+ Connection: close
+ Content-type: text/html
+
+ <HEAD><TITLE>404 File Not Found</TITLE></HEAD>
+ <BODY><H1>File Not Found</H1>
+ The requested URL /guanaco.html was not found on this server.<P>
+ </BODY>
+
+Ok, so that's not very interesting, because it didn't find that
+particular document. But a long response wouldn't have fit on this page.
+
+For a more fully-featured version of this program, you should look to
+the I<lwp-request> program included with the LWP modules from CPAN.
+
+=head2 Interactive Client with IO::Socket
+
+Well, that's all fine if you want to send one command and get one answer,
+but what about setting up something fully interactive, somewhat like
+the way I<telnet> works? That way you can type a line, get the answer,
+type a line, get the answer, etc.
+
+This client is more complicated than the two we've done so far, but if
+you're on a system that supports the powerful C<fork> call, the solution
+isn't that rough. Once you've made the connection to whatever service
+you'd like to chat with, call C<fork> to clone your process. Each of
+these two identical process has a very simple job to do: the parent
+copies everything from the socket to standard output, while the child
+simultaneously copies everything from standard input to the socket.
+To accomplish the same thing using just one process would be I<much>
+harder, because it's easier to code two processes to do one thing than it
+is to code one process to do two things. (This keep-it-simple principle
+a cornerstones of the Unix philosophy, and good software engineering as
+well, which is probably why it's spread to other systems.)
+
+Here's the code:
+
+ #!/usr/bin/perl -w
+ use strict;
+ use IO::Socket;
+ my ($host, $port, $kidpid, $handle, $line);
+
+ unless (@ARGV == 2) { die "usage: $0 host port" }
+ ($host, $port) = @ARGV;
+
+ # create a tcp connection to the specified host and port
+ $handle = IO::Socket::INET->new(Proto => "tcp",
+ PeerAddr => $host,
+ PeerPort => $port)
+ or die "can't connect to port $port on $host: $!";
+
+ $handle->autoflush(1); # so output gets there right away
+ print STDERR "[Connected to $host:$port]\n";
+
+ # split the program into two processes, identical twins
+ die "can't fork: $!" unless defined($kidpid = fork());
+
+ # the if{} block runs only in the parent process
+ if ($kidpid) {
+ # copy the socket to standard output
+ while (defined ($line = <$handle>)) {
+ print STDOUT $line;
+ }
+ kill("TERM", $kidpid); # send SIGTERM to child
+ }
+ # the else{} block runs only in the child process
+ else {
+ # copy standard input to the socket
+ while (defined ($line = <STDIN>)) {
+ print $handle $line;
+ }
+ }
+
+The C<kill> function in the parent's C<if> block is there to send a
+signal to our child process (current running in the C<else> block)
+as soon as the remote server has closed its end of the connection.
+
+If the remote server sends data a byte at time, and you need that
+data immediately without waiting for a newline (which might not happen),
+you may wish to replace the C<while> loop in the parent with the
+following:
+
+ my $byte;
+ while (sysread($handle, $byte, 1) == 1) {
+ print STDOUT $byte;
+ }
+
+Making a system call for each byte you want to read is not very efficient
+(to put it mildly) but is the simplest to explain and works reasonably
+well.
+
+=head1 TCP Servers with IO::Socket
+
+As always, setting up a server is little bit more involved than running a client.
+The model is that the server creates a special kind of socket that
+does nothing but listen on a particular port for incoming connections.
+It does this by calling the C<IO::Socket::INET-E<gt>new()> method with
+slightly different arguments than the client did.
+
+=over
+
+=item Proto
+
+This is which protocol to use. Like our clients, we'll
+still specify C<"tcp"> here.
+
+=item LocalPort
+
+We specify a local
+port in the C<LocalPort> argument, which we didn't do for the client.
+This is service name or port number for which you want to be the
+server. (Under Unix, ports under 1024 are restricted to the
+superuser.) In our sample, we'll use port 9000, but you can use
+any port that's not currently in use on your system. If you try
+to use one already in used, you'll get an "Address already in use"
+message. Under Unix, the C<netstat -a> command will show
+which services current have servers.
+
+=item Listen
+
+The C<Listen> parameter is set to the maximum number of
+pending connections we can accept until we turn away incoming clients.
+Think of it as a call-waiting queue for your telephone.
+The low-level Socket module has a special symbol for the system maximum, which
+is SOMAXCONN.
+
+=item Reuse
+
+The C<Reuse> parameter is needed so that we restart our server
+manually without waiting a few minutes to allow system buffers to
+clear out.
+
+=back
+
+Once the generic server socket has been created using the parameters
+listed above, the server then waits for a new client to connect
+to it. The server blocks in the C<accept> method, which eventually an
+bidirectional connection to the remote client. (Make sure to autoflush
+this handle to circumvent buffering.)
+
+To add to user-friendliness, our server prompts the user for commands.
+Most servers don't do this. Because of the prompt without a newline,
+you'll have to use the C<sysread> variant of the interactive client above.
+
+This server accepts one of five different commands, sending output
+back to the client. Note that unlike most network servers, this one
+only handles one incoming client at a time. Multithreaded servers are
+covered in Chapter 6 of the Camel as well as later in this manpage.
+
+Here's the code. We'll
+
+ #!/usr/bin/perl -w
+ use IO::Socket;
+ use Net::hostent; # for OO version of gethostbyaddr
+
+ $PORT = 9000; # pick something not in use
+
+ $server = IO::Socket::INET->new( Proto => 'tcp',
+ LocalPort => $PORT,
+ Listen => SOMAXCONN,
+ Reuse => 1);
+
+ die "can't setup server" unless $server;
+ print "[Server $0 accepting clients]\n";
+
+ while ($client = $server->accept()) {
+ $client->autoflush(1);
+ print $client "Welcome to $0; type help for command list.\n";
+ $hostinfo = gethostbyaddr($client->peeraddr);
+ printf "[Connect from %s]\n", $hostinfo->name || $client->peerhost;
+ print $client "Command? ";
+ while ( <$client>) {
+ next unless /\S/; # blank line
+ if (/quit|exit/i) { last; }
+ elsif (/date|time/i) { printf $client "%s\n", scalar localtime; }
+ elsif (/who/i ) { print $client `who 2>&1`; }
+ elsif (/cookie/i ) { print $client `/usr/games/fortune 2>&1`; }
+ elsif (/motd/i ) { print $client `cat /etc/motd 2>&1`; }
+ else {
+ print $client "Commands: quit date who cookie motd\n";
+ }
+ } continue {
+ print $client "Command? ";
+ }
+ close $client;
+ }
+
+=head1 UDP: Message Passing
+
+Another kind of client-server setup is one that uses not connections, but
+messages. UDP communications involve much lower overhead but also provide
+less reliability, as there are no promises that messages will arrive at
+all, let alone in order and unmangled. Still, UDP offers some advantages
+over TCP, including being able to "broadcast" or "multicast" to a whole
+bunch of destination hosts at once (usually on your local subnet). If you
+find yourself overly concerned about reliability and start building checks
+into your message system, then you probably should use just TCP to start
+with.
+
+Here's a UDP program similar to the sample Internet TCP client given
+earlier. However, instead of checking one host at a time, the UDP version
+will check many of them asynchronously by simulating a multicast and then
+using select() to do a timed-out wait for I/O. To do something similar
+with TCP, you'd have to use a different socket handle for each host.
+
+ #!/usr/bin/perl -w
+ use strict;
+ use Socket;
+ use Sys::Hostname;
+
+ my ( $count, $hisiaddr, $hispaddr, $histime,
+ $host, $iaddr, $paddr, $port, $proto,
+ $rin, $rout, $rtime, $SECS_of_70_YEARS);
+
+ $SECS_of_70_YEARS = 2208988800;
+
+ $iaddr = gethostbyname(hostname());
+ $proto = getprotobyname('udp');
+ $port = getservbyname('time', 'udp');
+ $paddr = sockaddr_in(0, $iaddr); # 0 means let kernel pick
+
+ socket(SOCKET, PF_INET, SOCK_DGRAM, $proto) || die "socket: $!";
+ bind(SOCKET, $paddr) || die "bind: $!";
+
+ $| = 1;
+ printf "%-12s %8s %s\n", "localhost", 0, scalar localtime time;
+ $count = 0;
+ for $host (@ARGV) {
+ $count++;
+ $hisiaddr = inet_aton($host) || die "unknown host";
+ $hispaddr = sockaddr_in($port, $hisiaddr);
+ defined(send(SOCKET, 0, 0, $hispaddr)) || die "send $host: $!";
+ }
+
+ $rin = '';
+ vec($rin, fileno(SOCKET), 1) = 1;
+
+ # timeout after 10.0 seconds
+ while ($count && select($rout = $rin, undef, undef, 10.0)) {
+ $rtime = '';
+ ($hispaddr = recv(SOCKET, $rtime, 4, 0)) || die "recv: $!";
+ ($port, $hisiaddr) = sockaddr_in($hispaddr);
+ $host = gethostbyaddr($hisiaddr, AF_INET);
+ $histime = unpack("N", $rtime) - $SECS_of_70_YEARS ;
+ printf "%-12s ", $host;
+ printf "%8d %s\n", $histime - time, scalar localtime($histime);
+ $count--;
+ }
+
+=head1 SysV IPC
+
+While System V IPC isn't so widely used as sockets, it still has some
+interesting uses. You can't, however, effectively use SysV IPC or
+Berkeley mmap() to have shared memory so as to share a variable amongst
+several processes. That's because Perl would reallocate your string when
+you weren't wanting it to.
+
+Here's a small example showing shared memory usage.
+
+ use IPC::SysV qw(IPC_PRIVATE IPC_RMID S_IRWXU S_IRWXG S_IRWXO);
+
+ $size = 2000;
+ $key = shmget(IPC_PRIVATE, $size, S_IRWXU|S_IRWXG|S_IRWXO) || die "$!";
+ print "shm key $key\n";
+
+ $message = "Message #1";
+ shmwrite($key, $message, 0, 60) || die "$!";
+ print "wrote: '$message'\n";
+ shmread($key, $buff, 0, 60) || die "$!";
+ print "read : '$buff'\n";
+
+ # the buffer of shmread is zero-character end-padded.
+ substr($buff, index($buff, "\0")) = '';
+ print "un" unless $buff eq $message;
+ print "swell\n";
+
+ print "deleting shm $key\n";
+ shmctl($key, IPC_RMID, 0) || die "$!";
+
+Here's an example of a semaphore:
+
+ use IPC::SysV qw(IPC_CREAT);
+
+ $IPC_KEY = 1234;
+ $key = semget($IPC_KEY, 10, 0666 | IPC_CREAT ) || die "$!";
+ print "shm key $key\n";
+
+Put this code in a separate file to be run in more than one process.
+Call the file F<take>:
+
+ # create a semaphore
+
+ $IPC_KEY = 1234;
+ $key = semget($IPC_KEY, 0 , 0 );
+ die if !defined($key);
+
+ $semnum = 0;
+ $semflag = 0;
+
+ # 'take' semaphore
+ # wait for semaphore to be zero
+ $semop = 0;
+ $opstring1 = pack("sss", $semnum, $semop, $semflag);
+
+ # Increment the semaphore count
+ $semop = 1;
+ $opstring2 = pack("sss", $semnum, $semop, $semflag);
+ $opstring = $opstring1 . $opstring2;
+
+ semop($key,$opstring) || die "$!";
+
+Put this code in a separate file to be run in more than one process.
+Call this file F<give>:
+
+ # 'give' the semaphore
+ # run this in the original process and you will see
+ # that the second process continues
+
+ $IPC_KEY = 1234;
+ $key = semget($IPC_KEY, 0, 0);
+ die if !defined($key);
+
+ $semnum = 0;
+ $semflag = 0;
+
+ # Decrement the semaphore count
+ $semop = -1;
+ $opstring = pack("sss", $semnum, $semop, $semflag);
+
+ semop($key,$opstring) || die "$!";
+
+The SysV IPC code above was written long ago, and it's definitely
+clunky looking. For a more modern look, see the IPC::SysV module
+which is included with Perl starting from Perl 5.005.
+
+=head1 NOTES
+
+Most of these routines quietly but politely return C<undef> when they
+fail instead of causing your program to die right then and there due to
+an uncaught exception. (Actually, some of the new I<Socket> conversion
+functions croak() on bad arguments.) It is therefore essential to
+check return values from these functions. Always begin your socket
+programs this way for optimal success, and don't forget to add B<-T>
+taint checking flag to the #! line for servers:
+
+ #!/usr/bin/perl -Tw
+ use strict;
+ use sigtrap;
+ use Socket;
+
+=head1 BUGS
+
+All these routines create system-specific portability problems. As noted
+elsewhere, Perl is at the mercy of your C libraries for much of its system
+behaviour. It's probably safest to assume broken SysV semantics for
+signals and to stick with simple TCP and UDP socket operations; e.g., don't
+try to pass open file descriptors over a local UDP datagram socket if you
+want your code to stand a chance of being portable.
+
+As mentioned in the signals section, because few vendors provide C
+libraries that are safely re-entrant, the prudent programmer will do
+little else within a handler beyond setting a numeric variable that
+already exists; or, if locked into a slow (restarting) system call,
+using die() to raise an exception and longjmp(3) out. In fact, even
+these may in some cases cause a core dump. It's probably best to avoid
+signals except where they are absolutely inevitable. This
+will be addressed in a future release of Perl.
+
+=head1 AUTHOR
+
+Tom Christiansen, with occasional vestiges of Larry Wall's original
+version and suggestions from the Perl Porters.
+
+=head1 SEE ALSO
+
+There's a lot more to networking than this, but this should get you
+started.
+
+For intrepid programmers, the indispensable textbook is I<Unix Network
+Programming> by W. Richard Stevens (published by Addison-Wesley). Note
+that most books on networking address networking from the perspective of
+a C programmer; translation to Perl is left as an exercise for the reader.
+
+The IO::Socket(3) manpage describes the object library, and the Socket(3)
+manpage describes the low-level interface to sockets. Besides the obvious
+functions in L<perlfunc>, you should also check out the F<modules> file
+at your nearest CPAN site. (See L<perlmodlib> or best yet, the F<Perl
+FAQ> for a description of what CPAN is and where to get it.)
+
+Section 5 of the F<modules> file is devoted to "Networking, Device Control
+(modems), and Interprocess Communication", and contains numerous unbundled
+modules numerous networking modules, Chat and Expect operations, CGI
+programming, DCE, FTP, IPC, NNTP, Proxy, Ptty, RPC, SNMP, SMTP, Telnet,
+Threads, and ToolTalk--just to name a few.
diff --git a/contrib/perl5/pod/perllocale.pod b/contrib/perl5/pod/perllocale.pod
new file mode 100644
index 0000000..4401be2
--- /dev/null
+++ b/contrib/perl5/pod/perllocale.pod
@@ -0,0 +1,976 @@
+=head1 NAME
+
+perllocale - Perl locale handling (internationalization and localization)
+
+=head1 DESCRIPTION
+
+Perl supports language-specific notions of data such as "is this
+a letter", "what is the uppercase equivalent of this letter", and
+"which of these letters comes first". These are important issues,
+especially for languages other than English--but also for English: it
+would be naE<iuml>ve to imagine that C<A-Za-z> defines all the "letters"
+needed to write in English. Perl is also aware that some character other
+than '.' may be preferred as a decimal point, and that output date
+representations may be language-specific. The process of making an
+application take account of its users' preferences in such matters is
+called B<internationalization> (often abbreviated as B<i18n>); telling
+such an application about a particular set of preferences is known as
+B<localization> (B<l10n>).
+
+Perl can understand language-specific data via the standardized (ISO C,
+XPG4, POSIX 1.c) method called "the locale system". The locale system is
+controlled per application using one pragma, one function call, and
+several environment variables.
+
+B<NOTE>: This feature is new in Perl 5.004, and does not apply unless an
+application specifically requests it--see L<Backward compatibility>.
+The one exception is that write() now B<always> uses the current locale
+- see L<"NOTES">.
+
+=head1 PREPARING TO USE LOCALES
+
+If Perl applications are to understand and present your data
+correctly according a locale of your choice, B<all> of the following
+must be true:
+
+=over 4
+
+=item *
+
+B<Your operating system must support the locale system>. If it does,
+you should find that the setlocale() function is a documented part of
+its C library.
+
+=item *
+
+B<Definitions for locales that you use must be installed>. You, or
+your system administrator, must make sure that this is the case. The
+available locales, the location in which they are kept, and the manner
+in which they are installed all vary from system to system. Some systems
+provide only a few, hard-wired locales and do not allow more to be
+added. Others allow you to add "canned" locales provided by the system
+supplier. Still others allow you or the system administrator to define
+and add arbitrary locales. (You may have to ask your supplier to
+provide canned locales that are not delivered with your operating
+system.) Read your system documentation for further illumination.
+
+=item *
+
+B<Perl must believe that the locale system is supported>. If it does,
+C<perl -V:d_setlocale> will say that the value for C<d_setlocale> is
+C<define>.
+
+=back
+
+If you want a Perl application to process and present your data
+according to a particular locale, the application code should include
+the S<C<use locale>> pragma (see L<The use locale pragma>) where
+appropriate, and B<at least one> of the following must be true:
+
+=over 4
+
+=item *
+
+B<The locale-determining environment variables (see L<"ENVIRONMENT">)
+must be correctly set up> at the time the application is started, either
+by yourself or by whoever set up your system account.
+
+=item *
+
+B<The application must set its own locale> using the method described in
+L<The setlocale function>.
+
+=back
+
+=head1 USING LOCALES
+
+=head2 The use locale pragma
+
+By default, Perl ignores the current locale. The S<C<use locale>>
+pragma tells Perl to use the current locale for some operations:
+
+=over 4
+
+=item *
+
+B<The comparison operators> (C<lt>, C<le>, C<cmp>, C<ge>, and C<gt>) and
+the POSIX string collation functions strcoll() and strxfrm() use
+C<LC_COLLATE>. sort() is also affected if used without an
+explicit comparison function, because it uses C<cmp> by default.
+
+B<Note:> C<eq> and C<ne> are unaffected by locale: they always
+perform a byte-by-byte comparison of their scalar operands. What's
+more, if C<cmp> finds that its operands are equal according to the
+collation sequence specified by the current locale, it goes on to
+perform a byte-by-byte comparison, and only returns I<0> (equal) if the
+operands are bit-for-bit identical. If you really want to know whether
+two strings--which C<eq> and C<cmp> may consider different--are equal
+as far as collation in the locale is concerned, see the discussion in
+L<Category LC_COLLATE: Collation>.
+
+=item *
+
+B<Regular expressions and case-modification functions> (uc(), lc(),
+ucfirst(), and lcfirst()) use C<LC_CTYPE>
+
+=item *
+
+B<The formatting functions> (printf(), sprintf() and write()) use
+C<LC_NUMERIC>
+
+=item *
+
+B<The POSIX date formatting function> (strftime()) uses C<LC_TIME>.
+
+=back
+
+C<LC_COLLATE>, C<LC_CTYPE>, and so on, are discussed further in L<LOCALE
+CATEGORIES>.
+
+The default behavior is restored with the S<C<no locale>> pragma, or
+upon reaching the end of block enclosing C<use locale>.
+
+The string result of any operation that uses locale
+information is tainted, as it is possible for a locale to be
+untrustworthy. See L<"SECURITY">.
+
+=head2 The setlocale function
+
+You can switch locales as often as you wish at run time with the
+POSIX::setlocale() function:
+
+ # This functionality not usable prior to Perl 5.004
+ require 5.004;
+
+ # Import locale-handling tool set from POSIX module.
+ # This example uses: setlocale -- the function call
+ # LC_CTYPE -- explained below
+ use POSIX qw(locale_h);
+
+ # query and save the old locale
+ $old_locale = setlocale(LC_CTYPE);
+
+ setlocale(LC_CTYPE, "fr_CA.ISO8859-1");
+ # LC_CTYPE now in locale "French, Canada, codeset ISO 8859-1"
+
+ setlocale(LC_CTYPE, "");
+ # LC_CTYPE now reset to default defined by LC_ALL/LC_CTYPE/LANG
+ # environment variables. See below for documentation.
+
+ # restore the old locale
+ setlocale(LC_CTYPE, $old_locale);
+
+The first argument of setlocale() gives the B<category>, the second the
+B<locale>. The category tells in what aspect of data processing you
+want to apply locale-specific rules. Category names are discussed in
+L<LOCALE CATEGORIES> and L<"ENVIRONMENT">. The locale is the name of a
+collection of customization information corresponding to a particular
+combination of language, country or territory, and codeset. Read on for
+hints on the naming of locales: not all systems name locales as in the
+example.
+
+If no second argument is provided and the category is something else
+than LC_ALL, the function returns a string naming the current locale
+for the category. You can use this value as the second argument in a
+subsequent call to setlocale().
+
+If no second argument is provided and the category is LC_ALL, the
+result is implementation-dependent. It may be a string of
+concatenated locales names (separator also implementation-dependent)
+or a single locale name. Please consult your L<setlocale(3)> for
+details.
+
+If a second argument is given and it corresponds to a valid locale,
+the locale for the category is set to that value, and the function
+returns the now-current locale value. You can then use this in yet
+another call to setlocale(). (In some implementations, the return
+value may sometimes differ from the value you gave as the second
+argument--think of it as an alias for the value you gave.)
+
+As the example shows, if the second argument is an empty string, the
+category's locale is returned to the default specified by the
+corresponding environment variables. Generally, this results in a
+return to the default that was in force when Perl started up: changes
+to the environment made by the application after startup may or may not
+be noticed, depending on your system's C library.
+
+If the second argument does not correspond to a valid locale, the locale
+for the category is not changed, and the function returns I<undef>.
+
+For further information about the categories, consult L<setlocale(3)>.
+
+=head2 Finding locales
+
+For locales available in your system, consult also L<setlocale(3)> to
+see whether it leads to the list of available locales (search for the
+I<SEE ALSO> section). If that fails, try the following command lines:
+
+ locale -a
+
+ nlsinfo
+
+ ls /usr/lib/nls/loc
+
+ ls /usr/lib/locale
+
+ ls /usr/lib/nls
+
+and see whether they list something resembling these
+
+ en_US.ISO8859-1 de_DE.ISO8859-1 ru_RU.ISO8859-5
+ en_US.iso88591 de_DE.iso88591 ru_RU.iso88595
+ en_US de_DE ru_RU
+ en de ru
+ english german russian
+ english.iso88591 german.iso88591 russian.iso88595
+ english.roman8 russian.koi8r
+
+Sadly, even though the calling interface for setlocale() has
+been standardized, names of locales and the directories where the
+configuration resides have not been. The basic form of the name is
+I<language_country/territory>B<.>I<codeset>, but the latter parts after
+I<language> are not always present. The I<language> and I<country> are
+usually from the standards B<ISO 3166> and B<ISO 639>, the two-letter
+abbreviations for the countries and the languages of the world,
+respectively. The I<codeset> part often mentions some B<ISO 8859>
+character set, the Latin codesets. For example, C<ISO 8859-1> is the
+so-called "Western codeset" that can be used to encode most Western
+European languages. Again, there are several ways to write even the
+name of that one standard. Lamentably.
+
+Two special locales are worth particular mention: "C" and "POSIX".
+Currently these are effectively the same locale: the difference is
+mainly that the first one is defined by the C standard, the second by
+the POSIX standard. They define the B<default locale> in which
+every program starts in the absence of locale information in its
+environment. (The I<default> default locale, if you will.) Its language
+is (American) English and its character codeset ASCII.
+
+B<NOTE>: Not all systems have the "POSIX" locale (not all systems are
+POSIX-conformant), so use "C" when you need explicitly to specify this
+default locale.
+
+=head2 LOCALE PROBLEMS
+
+You may encounter the following warning message at Perl startup:
+
+ perl: warning: Setting locale failed.
+ perl: warning: Please check that your locale settings:
+ LC_ALL = "En_US",
+ LANG = (unset)
+ are supported and installed on your system.
+ perl: warning: Falling back to the standard locale ("C").
+
+This means that your locale settings had LC_ALL set to "En_US" and
+LANG exists but has no value. Perl tried to believe you but could not.
+Instead, Perl gave up and fell back to the "C" locale, the default locale
+that is supposed to work no matter what. This usually means your locale
+settings were wrong, they mention locales your system has never heard
+of, or the locale installation in your system has problems (for example,
+some system files are broken or missing). There are quick and temporary
+fixes to these problems, as well as more thorough and lasting fixes.
+
+=head2 Temporarily fixing locale problems
+
+The two quickest fixes are either to render Perl silent about any
+locale inconsistencies or to run Perl under the default locale "C".
+
+Perl's moaning about locale problems can be silenced by setting the
+environment variable PERL_BADLANG to a non-zero value, for example
+"1". This method really just sweeps the problem under the carpet: you
+tell Perl to shut up even when Perl sees that something is wrong. Do
+not be surprised if later something locale-dependent misbehaves.
+
+Perl can be run under the "C" locale by setting the environment
+variable LC_ALL to "C". This method is perhaps a bit more civilized
+than the PERL_BADLANG approach, but setting LC_ALL (or
+other locale variables) may affect other programs as well, not just
+Perl. In particular, external programs run from within Perl will see
+these changes. If you make the new settings permanent (read on), all
+programs you run see the changes. See L<ENVIRONMENT> for for
+the full list of relevant environment variables and L<USING LOCALES>
+for their effects in Perl. Effects in other programs are
+easily deducible. For example, the variable LC_COLLATE may well affect
+your B<sort> program (or whatever the program that arranges `records'
+alphabetically in your system is called).
+
+You can test out changing these variables temporarily, and if the
+new settings seem to help, put those settings into your shell startup
+files. Consult your local documentation for the exact details. For in
+Bourne-like shells (B<sh>, B<ksh>, B<bash>, B<zsh>):
+
+ LC_ALL=en_US.ISO8859-1
+ export LC_ALL
+
+This assumes that we saw the locale "en_US.ISO8859-1" using the commands
+discussed above. We decided to try that instead of the above faulty
+locale "En_US"--and in Cshish shells (B<csh>, B<tcsh>)
+
+ setenv LC_ALL en_US.ISO8859-1
+
+If you do not know what shell you have, consult your local
+helpdesk or the equivalent.
+
+=head2 Permanently fixing locale problems
+
+The slower but superior fixes are when you may be able to yourself
+fix the misconfiguration of your own environment variables. The
+mis(sing)configuration of the whole system's locales usually requires
+the help of your friendly system administrator.
+
+First, see earlier in this document about L<Finding locales>. That tells
+how to find which locales are really supported--and more importantly,
+installed--on your system. In our example error message, environment
+variables affecting the locale are listed in the order of decreasing
+importance (and unset variables do not matter). Therefore, having
+LC_ALL set to "En_US" must have been the bad choice, as shown by the
+error message. First try fixing locale settings listed first.
+
+Second, if using the listed commands you see something B<exactly>
+(prefix matches do not count and case usually counts) like "En_US"
+without the quotes, then you should be okay because you are using a
+locale name that should be installed and available in your system.
+In this case, see L<Fixing system locale configuration>.
+
+=head2 Permanently fixing your locale configuration
+
+This is when you see something like:
+
+ perl: warning: Please check that your locale settings:
+ LC_ALL = "En_US",
+ LANG = (unset)
+ are supported and installed on your system.
+
+but then cannot see that "En_US" listed by the above-mentioned
+commands. You may see things like "en_US.ISO8859-1", but that isn't
+the same. In this case, try running under a locale
+that you can list and which somehow matches what you tried. The
+rules for matching locale names are a bit vague because
+standardization is weak in this area. See again the L<Finding
+locales> about general rules.
+
+=head2 Permanently fixing system locale configuration
+
+Contact a system administrator (preferably your own) and report the exact
+error message you get, and ask them to read this same documentation you
+are now reading. They should be able to check whether there is something
+wrong with the locale configuration of the system. The L<Finding locales>
+section is unfortunately a bit vague about the exact commands and places
+because these things are not that standardized.
+
+=head2 The localeconv function
+
+The POSIX::localeconv() function allows you to get particulars of the
+locale-dependent numeric formatting information specified by the current
+C<LC_NUMERIC> and C<LC_MONETARY> locales. (If you just want the name of
+the current locale for a particular category, use POSIX::setlocale()
+with a single parameter--see L<The setlocale function>.)
+
+ use POSIX qw(locale_h);
+
+ # Get a reference to a hash of locale-dependent info
+ $locale_values = localeconv();
+
+ # Output sorted list of the values
+ for (sort keys %$locale_values) {
+ printf "%-20s = %s\n", $_, $locale_values->{$_}
+ }
+
+localeconv() takes no arguments, and returns B<a reference to> a hash.
+The keys of this hash are variable names for formatting, such as
+C<decimal_point> and C<thousands_sep>. The values are the
+corresponding, er, values. See L<POSIX (3)/localeconv> for a longer
+example listing the categories an implementation might be expected to
+provide; some provide more and others fewer. You don't need an
+explicit C<use locale>, because localeconv() always observes the
+current locale.
+
+Here's a simple-minded example program that rewrites its command-line
+parameters as integers correctly formatted in the current locale:
+
+ # See comments in previous example
+ require 5.004;
+ use POSIX qw(locale_h);
+
+ # Get some of locale's numeric formatting parameters
+ my ($thousands_sep, $grouping) =
+ @{localeconv()}{'thousands_sep', 'grouping'};
+
+ # Apply defaults if values are missing
+ $thousands_sep = ',' unless $thousands_sep;
+
+ # grouping and mon_grouping are packed lists
+ # of small integers (characters) telling the
+ # grouping (thousand_seps and mon_thousand_seps
+ # being the group dividers) of numbers and
+ # monetary quantities. The integers' meanings:
+ # 255 means no more grouping, 0 means repeat
+ # the previous grouping, 1-254 means use that
+ # as the current grouping. Grouping goes from
+ # right to left (low to high digits). In the
+ # below we cheat slightly by never using anything
+ # else than the first grouping (whatever that is).
+ if ($grouping) {
+ @grouping = unpack("C*", $grouping);
+ } else {
+ @grouping = (3);
+ }
+
+ # Format command line params for current locale
+ for (@ARGV) {
+ $_ = int; # Chop non-integer part
+ 1 while
+ s/(\d)(\d{$grouping[0]}($|$thousands_sep))/$1$thousands_sep$2/;
+ print "$_";
+ }
+ print "\n";
+
+=head1 LOCALE CATEGORIES
+
+The following subsections describe basic locale categories. Beyond these,
+some combination categories allow manipulation of more than one
+basic category at a time. See L<"ENVIRONMENT"> for a discussion of these.
+
+=head2 Category LC_COLLATE: Collation
+
+In the scope of S<C<use locale>>, Perl looks to the C<LC_COLLATE>
+environment variable to determine the application's notions on collation
+(ordering) of characters. For example, 'b' follows 'a' in Latin
+alphabets, but where do 'E<aacute>' and 'E<aring>' belong? And while
+'color' follows 'chocolate' in English, what about in Spanish?
+
+The following collations all make sense and you may meet any of them
+if you "use locale".
+
+ A B C D E a b c d e
+ A a B b C c D d D e
+ a A b B c C d D e E
+ a b c d e A B C D E
+
+Here is a code snippet to tell what alphanumeric
+characters are in the current locale, in that locale's order:
+
+ use locale;
+ print +(sort grep /\w/, map { chr() } 0..255), "\n";
+
+Compare this with the characters that you see and their order if you
+state explicitly that the locale should be ignored:
+
+ no locale;
+ print +(sort grep /\w/, map { chr() } 0..255), "\n";
+
+This machine-native collation (which is what you get unless S<C<use
+locale>> has appeared earlier in the same block) must be used for
+sorting raw binary data, whereas the locale-dependent collation of the
+first example is useful for natural text.
+
+As noted in L<USING LOCALES>, C<cmp> compares according to the current
+collation locale when C<use locale> is in effect, but falls back to a
+byte-by-byte comparison for strings that the locale says are equal. You
+can use POSIX::strcoll() if you don't want this fall-back:
+
+ use POSIX qw(strcoll);
+ $equal_in_locale =
+ !strcoll("space and case ignored", "SpaceAndCaseIgnored");
+
+$equal_in_locale will be true if the collation locale specifies a
+dictionary-like ordering that ignores space characters completely and
+which folds case.
+
+If you have a single string that you want to check for "equality in
+locale" against several others, you might think you could gain a little
+efficiency by using POSIX::strxfrm() in conjunction with C<eq>:
+
+ use POSIX qw(strxfrm);
+ $xfrm_string = strxfrm("Mixed-case string");
+ print "locale collation ignores spaces\n"
+ if $xfrm_string eq strxfrm("Mixed-casestring");
+ print "locale collation ignores hyphens\n"
+ if $xfrm_string eq strxfrm("Mixedcase string");
+ print "locale collation ignores case\n"
+ if $xfrm_string eq strxfrm("mixed-case string");
+
+strxfrm() takes a string and maps it into a transformed string for use
+in byte-by-byte comparisons against other transformed strings during
+collation. "Under the hood", locale-affected Perl comparison operators
+call strxfrm() for both operands, then do a byte-by-byte
+comparison of the transformed strings. By calling strxfrm() explicitly
+and using a non locale-affected comparison, the example attempts to save
+a couple of transformations. But in fact, it doesn't save anything: Perl
+magic (see L<perlguts/Magic Variables>) creates the transformed version of a
+string the first time it's needed in a comparison, then keeps this version around
+in case it's needed again. An example rewritten the easy way with
+C<cmp> runs just about as fast. It also copes with null characters
+embedded in strings; if you call strxfrm() directly, it treats the first
+null it finds as a terminator. don't expect the transformed strings
+it produces to be portable across systems--or even from one revision
+of your operating system to the next. In short, don't call strxfrm()
+directly: let Perl do it for you.
+
+Note: C<use locale> isn't shown in some of these examples because it isn't
+needed: strcoll() and strxfrm() exist only to generate locale-dependent
+results, and so always obey the current C<LC_COLLATE> locale.
+
+=head2 Category LC_CTYPE: Character Types
+
+In the scope of S<C<use locale>>, Perl obeys the C<LC_CTYPE> locale
+setting. This controls the application's notion of which characters are
+alphabetic. This affects Perl's C<\w> regular expression metanotation,
+which stands for alphanumeric characters--that is, alphabetic and
+numeric characters. (Consult L<perlre> for more information about
+regular expressions.) Thanks to C<LC_CTYPE>, depending on your locale
+setting, characters like 'E<aelig>', 'E<eth>', 'E<szlig>', and
+'E<oslash>' may be understood as C<\w> characters.
+
+The C<LC_CTYPE> locale also provides the map used in transliterating
+characters between lower and uppercase. This affects the case-mapping
+functions--lc(), lcfirst, uc(), and ucfirst(); case-mapping
+interpolation with C<\l>, C<\L>, C<\u>, or C<\U> in double-quoted strings
+and C<s///> substitutions; and case-independent regular expression
+pattern matching using the C<i> modifier.
+
+Finally, C<LC_CTYPE> affects the POSIX character-class test
+functions--isalpha(), islower(), and so on. For example, if you move
+from the "C" locale to a 7-bit Scandinavian one, you may find--possibly
+to your surprise--that "|" moves from the ispunct() class to isalpha().
+
+B<Note:> A broken or malicious C<LC_CTYPE> locale definition may result
+in clearly ineligible characters being considered to be alphanumeric by
+your application. For strict matching of (mundane) letters and
+digits--for example, in command strings--locale-aware applications
+should use C<\w> inside a C<no locale> block. See L<"SECURITY">.
+
+=head2 Category LC_NUMERIC: Numeric Formatting
+
+In the scope of S<C<use locale>>, Perl obeys the C<LC_NUMERIC> locale
+information, which controls an application's idea of how numbers should
+be formatted for human readability by the printf(), sprintf(), and
+write() functions. String-to-numeric conversion by the POSIX::strtod()
+function is also affected. In most implementations the only effect is to
+change the character used for the decimal point--perhaps from '.' to ','.
+These functions aren't aware of such niceties as thousands separation and
+so on. (See L<The localeconv function> if you care about these things.)
+
+Output produced by print() is B<never> affected by the
+current locale: it is independent of whether C<use locale> or C<no
+locale> is in effect, and corresponds to what you'd get from printf()
+in the "C" locale. The same is true for Perl's internal conversions
+between numeric and string formats:
+
+ use POSIX qw(strtod);
+ use locale;
+
+ $n = 5/2; # Assign numeric 2.5 to $n
+
+ $a = " $n"; # Locale-independent conversion to string
+
+ print "half five is $n\n"; # Locale-independent output
+
+ printf "half five is %g\n", $n; # Locale-dependent output
+
+ print "DECIMAL POINT IS COMMA\n"
+ if $n == (strtod("2,5"))[0]; # Locale-dependent conversion
+
+=head2 Category LC_MONETARY: Formatting of monetary amounts
+
+The C standard defines the C<LC_MONETARY> category, but no function
+that is affected by its contents. (Those with experience of standards
+committees will recognize that the working group decided to punt on the
+issue.) Consequently, Perl takes no notice of it. If you really want
+to use C<LC_MONETARY>, you can query its contents--see L<The localeconv
+function>--and use the information that it returns in your application's
+own formatting of currency amounts. However, you may well find that
+the information, voluminous and complex though it may be, still does not
+quite meet your requirements: currency formatting is a hard nut to crack.
+
+=head2 LC_TIME
+
+Output produced by POSIX::strftime(), which builds a formatted
+human-readable date/time string, is affected by the current C<LC_TIME>
+locale. Thus, in a French locale, the output produced by the C<%B>
+format element (full month name) for the first month of the year would
+be "janvier". Here's how to get a list of long month names in the
+current locale:
+
+ use POSIX qw(strftime);
+ for (0..11) {
+ $long_month_name[$_] =
+ strftime("%B", 0, 0, 0, 1, $_, 96);
+ }
+
+Note: C<use locale> isn't needed in this example: as a function that
+exists only to generate locale-dependent results, strftime() always
+obeys the current C<LC_TIME> locale.
+
+=head2 Other categories
+
+The remaining locale category, C<LC_MESSAGES> (possibly supplemented
+by others in particular implementations) is not currently used by
+Perl--except possibly to affect the behavior of library functions called
+by extensions outside the standard Perl distribution.
+
+=head1 SECURITY
+
+Although the main discussion of Perl security issues can be found in
+L<perlsec>, a discussion of Perl's locale handling would be incomplete
+if it did not draw your attention to locale-dependent security issues.
+Locales--particularly on systems that allow unprivileged users to
+build their own locales--are untrustworthy. A malicious (or just plain
+broken) locale can make a locale-aware application give unexpected
+results. Here are a few possibilities:
+
+=over 4
+
+=item *
+
+Regular expression checks for safe file names or mail addresses using
+C<\w> may be spoofed by an C<LC_CTYPE> locale that claims that
+characters such as "E<gt>" and "|" are alphanumeric.
+
+=item *
+
+String interpolation with case-mapping, as in, say, C<$dest =
+"C:\U$name.$ext">, may produce dangerous results if a bogus LC_CTYPE
+case-mapping table is in effect.
+
+=item *
+
+If the decimal point character in the C<LC_NUMERIC> locale is
+surreptitiously changed from a dot to a comma, C<sprintf("%g",
+0.123456e3)> produces a string result of "123,456". Many people would
+interpret this as one hundred and twenty-three thousand, four hundred
+and fifty-six.
+
+=item *
+
+A sneaky C<LC_COLLATE> locale could result in the names of students with
+"D" grades appearing ahead of those with "A"s.
+
+=item *
+
+An application that takes the trouble to use information in
+C<LC_MONETARY> may format debits as if they were credits and vice versa
+if that locale has been subverted. Or it might make payments in US
+dollars instead of Hong Kong dollars.
+
+=item *
+
+The date and day names in dates formatted by strftime() could be
+manipulated to advantage by a malicious user able to subvert the
+C<LC_DATE> locale. ("Look--it says I wasn't in the building on
+Sunday.")
+
+=back
+
+Such dangers are not peculiar to the locale system: any aspect of an
+application's environment which may be modified maliciously presents
+similar challenges. Similarly, they are not specific to Perl: any
+programming language that allows you to write programs that take
+account of their environment exposes you to these issues.
+
+Perl cannot protect you from all possibilities shown in the
+examples--there is no substitute for your own vigilance--but, when
+C<use locale> is in effect, Perl uses the tainting mechanism (see
+L<perlsec>) to mark string results that become locale-dependent, and
+which may be untrustworthy in consequence. Here is a summary of the
+tainting behavior of operators and functions that may be affected by
+the locale:
+
+=over 4
+
+=item B<Comparison operators> (C<lt>, C<le>, C<ge>, C<gt> and C<cmp>):
+
+Scalar true/false (or less/equal/greater) result is never tainted.
+
+=item B<Case-mapping interpolation> (with C<\l>, C<\L>, C<\u> or C<\U>)
+
+Result string containing interpolated material is tainted if
+C<use locale> is in effect.
+
+=item B<Matching operator> (C<m//>):
+
+Scalar true/false result never tainted.
+
+Subpatterns, either delivered as a list-context result or as $1 etc.
+are tainted if C<use locale> is in effect, and the subpattern regular
+expression contains C<\w> (to match an alphanumeric character), C<\W>
+(non-alphanumeric character), C<\s> (white-space character), or C<\S>
+(non white-space character). The matched-pattern variable, $&, $`
+(pre-match), $' (post-match), and $+ (last match) are also tainted if
+C<use locale> is in effect and the regular expression contains C<\w>,
+C<\W>, C<\s>, or C<\S>.
+
+=item B<Substitution operator> (C<s///>):
+
+Has the same behavior as the match operator. Also, the left
+operand of C<=~> becomes tainted when C<use locale> in effect
+if modified as a result of a substitution based on a regular
+expression match involving C<\w>, C<\W>, C<\s>, or C<\S>; or of
+case-mapping with C<\l>, C<\L>,C<\u> or C<\U>.
+
+=item B<In-memory formatting function> (sprintf()):
+
+Result is tainted if "use locale" is in effect.
+
+=item B<Output formatting functions> (printf() and write()):
+
+Success/failure result is never tainted.
+
+=item B<Case-mapping functions> (lc(), lcfirst(), uc(), ucfirst()):
+
+Results are tainted if C<use locale> is in effect.
+
+=item B<POSIX locale-dependent functions> (localeconv(), strcoll(),
+strftime(), strxfrm()):
+
+Results are never tainted.
+
+=item B<POSIX character class tests> (isalnum(), isalpha(), isdigit(),
+isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(),
+isxdigit()):
+
+True/false results are never tainted.
+
+=back
+
+Three examples illustrate locale-dependent tainting.
+The first program, which ignores its locale, won't run: a value taken
+directly from the command line may not be used to name an output file
+when taint checks are enabled.
+
+ #/usr/local/bin/perl -T
+ # Run with taint checking
+
+ # Command line sanity check omitted...
+ $tainted_output_file = shift;
+
+ open(F, ">$tainted_output_file")
+ or warn "Open of $untainted_output_file failed: $!\n";
+
+The program can be made to run by "laundering" the tainted value through
+a regular expression: the second example--which still ignores locale
+information--runs, creating the file named on its command line
+if it can.
+
+ #/usr/local/bin/perl -T
+
+ $tainted_output_file = shift;
+ $tainted_output_file =~ m%[\w/]+%;
+ $untainted_output_file = $&;
+
+ open(F, ">$untainted_output_file")
+ or warn "Open of $untainted_output_file failed: $!\n";
+
+Compare this with a similar but locale-aware program:
+
+ #/usr/local/bin/perl -T
+
+ $tainted_output_file = shift;
+ use locale;
+ $tainted_output_file =~ m%[\w/]+%;
+ $localized_output_file = $&;
+
+ open(F, ">$localized_output_file")
+ or warn "Open of $localized_output_file failed: $!\n";
+
+This third program fails to run because $& is tainted: it is the result
+of a match involving C<\w> while C<use locale> is in effect.
+
+=head1 ENVIRONMENT
+
+=over 12
+
+=item PERL_BADLANG
+
+A string that can suppress Perl's warning about failed locale settings
+at startup. Failure can occur if the locale support in the operating
+system is lacking (broken) in some way--or if you mistyped the name of
+a locale when you set up your environment. If this environment variable
+is absent, or has a value that does not evaluate to integer zero--that
+is, "0" or ""--Perl will complain about locale setting failures.
+
+B<NOTE>: PERL_BADLANG only gives you a way to hide the warning message.
+The message tells about some problem in your system's locale support,
+and you should investigate what the problem is.
+
+=back
+
+The following environment variables are not specific to Perl: They are
+part of the standardized (ISO C, XPG4, POSIX 1.c) setlocale() method
+for controlling an application's opinion on data.
+
+=over 12
+
+=item LC_ALL
+
+C<LC_ALL> is the "override-all" locale environment variable. If
+set, it overrides all the rest of the locale environment variables.
+
+=item LC_CTYPE
+
+In the absence of C<LC_ALL>, C<LC_CTYPE> chooses the character type
+locale. In the absence of both C<LC_ALL> and C<LC_CTYPE>, C<LANG>
+chooses the character type locale.
+
+=item LC_COLLATE
+
+In the absence of C<LC_ALL>, C<LC_COLLATE> chooses the collation
+(sorting) locale. In the absence of both C<LC_ALL> and C<LC_COLLATE>,
+C<LANG> chooses the collation locale.
+
+=item LC_MONETARY
+
+In the absence of C<LC_ALL>, C<LC_MONETARY> chooses the monetary
+formatting locale. In the absence of both C<LC_ALL> and C<LC_MONETARY>,
+C<LANG> chooses the monetary formatting locale.
+
+=item LC_NUMERIC
+
+In the absence of C<LC_ALL>, C<LC_NUMERIC> chooses the numeric format
+locale. In the absence of both C<LC_ALL> and C<LC_NUMERIC>, C<LANG>
+chooses the numeric format.
+
+=item LC_TIME
+
+In the absence of C<LC_ALL>, C<LC_TIME> chooses the date and time
+formatting locale. In the absence of both C<LC_ALL> and C<LC_TIME>,
+C<LANG> chooses the date and time formatting locale.
+
+=item LANG
+
+C<LANG> is the "catch-all" locale environment variable. If it is set, it
+is used as the last resort after the overall C<LC_ALL> and the
+category-specific C<LC_...>.
+
+=back
+
+=head1 NOTES
+
+=head2 Backward compatibility
+
+Versions of Perl prior to 5.004 B<mostly> ignored locale information,
+generally behaving as if something similar to the C<"C"> locale were
+always in force, even if the program environment suggested otherwise
+(see L<The setlocale function>). By default, Perl still behaves this
+way for backward compatibility. If you want a Perl application to pay
+attention to locale information, you B<must> use the S<C<use locale>>
+pragma (see L<The use locale Pragma>) to instruct it to do so.
+
+Versions of Perl from 5.002 to 5.003 did use the C<LC_CTYPE>
+information if available; that is, C<\w> did understand what
+were the letters according to the locale environment variables.
+The problem was that the user had no control over the feature:
+if the C library supported locales, Perl used them.
+
+=head2 I18N:Collate obsolete
+
+In versions of Perl prior to 5.004, per-locale collation was possible
+using the C<I18N::Collate> library module. This module is now mildly
+obsolete and should be avoided in new applications. The C<LC_COLLATE>
+functionality is now integrated into the Perl core language: One can
+use locale-specific scalar data completely normally with C<use locale>,
+so there is no longer any need to juggle with the scalar references of
+C<I18N::Collate>.
+
+=head2 Sort speed and memory use impacts
+
+Comparing and sorting by locale is usually slower than the default
+sorting; slow-downs of two to four times have been observed. It will
+also consume more memory: once a Perl scalar variable has participated
+in any string comparison or sorting operation obeying the locale
+collation rules, it will take 3-15 times more memory than before. (The
+exact multiplier depends on the string's contents, the operating system
+and the locale.) These downsides are dictated more by the operating
+system's implementation of the locale system than by Perl.
+
+=head2 write() and LC_NUMERIC
+
+Formats are the only part of Perl that unconditionally use information
+from a program's locale; if a program's environment specifies an
+LC_NUMERIC locale, it is always used to specify the decimal point
+character in formatted output. Formatted output cannot be controlled by
+C<use locale> because the pragma is tied to the block structure of the
+program, and, for historical reasons, formats exist outside that block
+structure.
+
+=head2 Freely available locale definitions
+
+There is a large collection of locale definitions at
+C<ftp://dkuug.dk/i18n/WG15-collection>. You should be aware that it is
+unsupported, and is not claimed to be fit for any purpose. If your
+system allows installation of arbitrary locales, you may find the
+definitions useful as they are, or as a basis for the development of
+your own locales.
+
+=head2 I18n and l10n
+
+"Internationalization" is often abbreviated as B<i18n> because its first
+and last letters are separated by eighteen others. (You may guess why
+the internalin ... internaliti ... i18n tends to get abbreviated.) In
+the same way, "localization" is often abbreviated to B<l10n>.
+
+=head2 An imperfect standard
+
+Internationalization, as defined in the C and POSIX standards, can be
+criticized as incomplete, ungainly, and having too large a granularity.
+(Locales apply to a whole process, when it would arguably be more useful
+to have them apply to a single thread, window group, or whatever.) They
+also have a tendency, like standards groups, to divide the world into
+nations, when we all know that the world can equally well be divided
+into bankers, bikers, gamers, and so on. But, for now, it's the only
+standard we've got. This may be construed as a bug.
+
+=head1 BUGS
+
+=head2 Broken systems
+
+In certain systems, the operating system's locale support
+is broken and cannot be fixed or used by Perl. Such deficiencies can
+and will result in mysterious hangs and/or Perl core dumps when the
+C<use locale> is in effect. When confronted with such a system,
+please report in excruciating detail to <F<perlbug@perl.com>>, and
+complain to your vendor: bug fixes may exist for these problems
+in your operating system. Sometimes such bug fixes are called an
+operating system upgrade.
+
+=head1 SEE ALSO
+
+L<POSIX (3)/isalnum>
+
+L<POSIX (3)/isalpha>
+
+L<POSIX (3)/isdigit>
+
+L<POSIX (3)/isgraph>
+
+L<POSIX (3)/islower>
+
+L<POSIX (3)/isprint>,
+
+L<POSIX (3)/ispunct>
+
+L<POSIX (3)/isspace>
+
+L<POSIX (3)/isupper>,
+
+L<POSIX (3)/isxdigit>
+
+L<POSIX (3)/localeconv>
+
+L<POSIX (3)/setlocale>,
+
+L<POSIX (3)/strcoll>
+
+L<POSIX (3)/strftime>
+
+L<POSIX (3)/strtod>,
+
+L<POSIX (3)/strxfrm>
+
+=head1 HISTORY
+
+Jarkko Hietaniemi's original F<perli18n.pod> heavily hacked by Dominic
+Dunlop, assisted by the perl5-porters. Prose worked over a bit by
+Tom Christiansen.
+
+Last update: Thu Jun 11 08:44:13 MDT 1998
diff --git a/contrib/perl5/pod/perllol.pod b/contrib/perl5/pod/perllol.pod
new file mode 100644
index 0000000..0e6796b
--- /dev/null
+++ b/contrib/perl5/pod/perllol.pod
@@ -0,0 +1,303 @@
+=head1 NAME
+
+perlLoL - Manipulating Lists of Lists in Perl
+
+=head1 DESCRIPTION
+
+=head1 Declaration and Access of Lists of Lists
+
+The simplest thing to build is a list of lists (sometimes called an array
+of arrays). It's reasonably easy to understand, and almost everything
+that applies here will also be applicable later on with the fancier data
+structures.
+
+A list of lists, or an array of an array if you would, is just a regular
+old array @LoL that you can get at with two subscripts, like C<$LoL[3][2]>. Here's
+a declaration of the array:
+
+ # assign to our array a list of list references
+ @LoL = (
+ [ "fred", "barney" ],
+ [ "george", "jane", "elroy" ],
+ [ "homer", "marge", "bart" ],
+ );
+
+ print $LoL[2][2];
+ bart
+
+Now you should be very careful that the outer bracket type
+is a round one, that is, a parenthesis. That's because you're assigning to
+an @list, so you need parentheses. If you wanted there I<not> to be an @LoL,
+but rather just a reference to it, you could do something more like this:
+
+ # assign a reference to list of list references
+ $ref_to_LoL = [
+ [ "fred", "barney", "pebbles", "bambam", "dino", ],
+ [ "homer", "bart", "marge", "maggie", ],
+ [ "george", "jane", "alroy", "judy", ],
+ ];
+
+ print $ref_to_LoL->[2][2];
+
+Notice that the outer bracket type has changed, and so our access syntax
+has also changed. That's because unlike C, in perl you can't freely
+interchange arrays and references thereto. $ref_to_LoL is a reference to an
+array, whereas @LoL is an array proper. Likewise, C<$LoL[2]> is not an
+array, but an array ref. So how come you can write these:
+
+ $LoL[2][2]
+ $ref_to_LoL->[2][2]
+
+instead of having to write these:
+
+ $LoL[2]->[2]
+ $ref_to_LoL->[2]->[2]
+
+Well, that's because the rule is that on adjacent brackets only (whether
+square or curly), you are free to omit the pointer dereferencing arrow.
+But you cannot do so for the very first one if it's a scalar containing
+a reference, which means that $ref_to_LoL always needs it.
+
+=head1 Growing Your Own
+
+That's all well and good for declaration of a fixed data structure,
+but what if you wanted to add new elements on the fly, or build
+it up entirely from scratch?
+
+First, let's look at reading it in from a file. This is something like
+adding a row at a time. We'll assume that there's a flat file in which
+each line is a row and each word an element. If you're trying to develop an
+@LoL list containing all these, here's the right way to do that:
+
+ while (<>) {
+ @tmp = split;
+ push @LoL, [ @tmp ];
+ }
+
+You might also have loaded that from a function:
+
+ for $i ( 1 .. 10 ) {
+ $LoL[$i] = [ somefunc($i) ];
+ }
+
+Or you might have had a temporary variable sitting around with the
+list in it.
+
+ for $i ( 1 .. 10 ) {
+ @tmp = somefunc($i);
+ $LoL[$i] = [ @tmp ];
+ }
+
+It's very important that you make sure to use the C<[]> list reference
+constructor. That's because this will be very wrong:
+
+ $LoL[$i] = @tmp;
+
+You see, assigning a named list like that to a scalar just counts the
+number of elements in @tmp, which probably isn't what you want.
+
+If you are running under C<use strict>, you'll have to add some
+declarations to make it happy:
+
+ use strict;
+ my(@LoL, @tmp);
+ while (<>) {
+ @tmp = split;
+ push @LoL, [ @tmp ];
+ }
+
+Of course, you don't need the temporary array to have a name at all:
+
+ while (<>) {
+ push @LoL, [ split ];
+ }
+
+You also don't have to use push(). You could just make a direct assignment
+if you knew where you wanted to put it:
+
+ my (@LoL, $i, $line);
+ for $i ( 0 .. 10 ) {
+ $line = <>;
+ $LoL[$i] = [ split ' ', $line ];
+ }
+
+or even just
+
+ my (@LoL, $i);
+ for $i ( 0 .. 10 ) {
+ $LoL[$i] = [ split ' ', <> ];
+ }
+
+You should in general be leery of using potential list functions
+in a scalar context without explicitly stating such.
+This would be clearer to the casual reader:
+
+ my (@LoL, $i);
+ for $i ( 0 .. 10 ) {
+ $LoL[$i] = [ split ' ', scalar(<>) ];
+ }
+
+If you wanted to have a $ref_to_LoL variable as a reference to an array,
+you'd have to do something like this:
+
+ while (<>) {
+ push @$ref_to_LoL, [ split ];
+ }
+
+Now you can add new rows. What about adding new columns? If you're
+dealing with just matrices, it's often easiest to use simple assignment:
+
+ for $x (1 .. 10) {
+ for $y (1 .. 10) {
+ $LoL[$x][$y] = func($x, $y);
+ }
+ }
+
+ for $x ( 3, 7, 9 ) {
+ $LoL[$x][20] += func2($x);
+ }
+
+It doesn't matter whether those elements are already
+there or not: it'll gladly create them for you, setting
+intervening elements to C<undef> as need be.
+
+If you wanted just to append to a row, you'd have
+to do something a bit funnier looking:
+
+ # add new columns to an existing row
+ push @{ $LoL[0] }, "wilma", "betty";
+
+Notice that I I<couldn't> say just:
+
+ push $LoL[0], "wilma", "betty"; # WRONG!
+
+In fact, that wouldn't even compile. How come? Because the argument
+to push() must be a real array, not just a reference to such.
+
+=head1 Access and Printing
+
+Now it's time to print your data structure out. How
+are you going to do that? Well, if you want only one
+of the elements, it's trivial:
+
+ print $LoL[0][0];
+
+If you want to print the whole thing, though, you can't
+say
+
+ print @LoL; # WRONG
+
+because you'll get just references listed, and perl will never
+automatically dereference things for you. Instead, you have to
+roll yourself a loop or two. This prints the whole structure,
+using the shell-style for() construct to loop across the outer
+set of subscripts.
+
+ for $aref ( @LoL ) {
+ print "\t [ @$aref ],\n";
+ }
+
+If you wanted to keep track of subscripts, you might do this:
+
+ for $i ( 0 .. $#LoL ) {
+ print "\t elt $i is [ @{$LoL[$i]} ],\n";
+ }
+
+or maybe even this. Notice the inner loop.
+
+ for $i ( 0 .. $#LoL ) {
+ for $j ( 0 .. $#{$LoL[$i]} ) {
+ print "elt $i $j is $LoL[$i][$j]\n";
+ }
+ }
+
+As you can see, it's getting a bit complicated. That's why
+sometimes is easier to take a temporary on your way through:
+
+ for $i ( 0 .. $#LoL ) {
+ $aref = $LoL[$i];
+ for $j ( 0 .. $#{$aref} ) {
+ print "elt $i $j is $LoL[$i][$j]\n";
+ }
+ }
+
+Hmm... that's still a bit ugly. How about this:
+
+ for $i ( 0 .. $#LoL ) {
+ $aref = $LoL[$i];
+ $n = @$aref - 1;
+ for $j ( 0 .. $n ) {
+ print "elt $i $j is $LoL[$i][$j]\n";
+ }
+ }
+
+=head1 Slices
+
+If you want to get at a slice (part of a row) in a multidimensional
+array, you're going to have to do some fancy subscripting. That's
+because while we have a nice synonym for single elements via the
+pointer arrow for dereferencing, no such convenience exists for slices.
+(Remember, of course, that you can always write a loop to do a slice
+operation.)
+
+Here's how to do one operation using a loop. We'll assume an @LoL
+variable as before.
+
+ @part = ();
+ $x = 4;
+ for ($y = 7; $y < 13; $y++) {
+ push @part, $LoL[$x][$y];
+ }
+
+That same loop could be replaced with a slice operation:
+
+ @part = @{ $LoL[4] } [ 7..12 ];
+
+but as you might well imagine, this is pretty rough on the reader.
+
+Ah, but what if you wanted a I<two-dimensional slice>, such as having
+$x run from 4..8 and $y run from 7 to 12? Hmm... here's the simple way:
+
+ @newLoL = ();
+ for ($startx = $x = 4; $x <= 8; $x++) {
+ for ($starty = $y = 7; $y <= 12; $y++) {
+ $newLoL[$x - $startx][$y - $starty] = $LoL[$x][$y];
+ }
+ }
+
+We can reduce some of the looping through slices
+
+ for ($x = 4; $x <= 8; $x++) {
+ push @newLoL, [ @{ $LoL[$x] } [ 7..12 ] ];
+ }
+
+If you were into Schwartzian Transforms, you would probably
+have selected map for that
+
+ @newLoL = map { [ @{ $LoL[$_] } [ 7..12 ] ] } 4 .. 8;
+
+Although if your manager accused of seeking job security (or rapid
+insecurity) through inscrutable code, it would be hard to argue. :-)
+If I were you, I'd put that in a function:
+
+ @newLoL = splice_2D( \@LoL, 4 => 8, 7 => 12 );
+ sub splice_2D {
+ my $lrr = shift; # ref to list of list refs!
+ my ($x_lo, $x_hi,
+ $y_lo, $y_hi) = @_;
+
+ return map {
+ [ @{ $lrr->[$_] } [ $y_lo .. $y_hi ] ]
+ } $x_lo .. $x_hi;
+ }
+
+
+=head1 SEE ALSO
+
+perldata(1), perlref(1), perldsc(1)
+
+=head1 AUTHOR
+
+Tom Christiansen <F<tchrist@perl.com>>
+
+Last update: Thu Jun 4 16:16:23 MDT 1998
diff --git a/contrib/perl5/pod/perlmod.pod b/contrib/perl5/pod/perlmod.pod
new file mode 100644
index 0000000..6da31de
--- /dev/null
+++ b/contrib/perl5/pod/perlmod.pod
@@ -0,0 +1,375 @@
+=head1 NAME
+
+perlmod - Perl modules (packages and symbol tables)
+
+=head1 DESCRIPTION
+
+=head2 Packages
+
+Perl provides a mechanism for alternative namespaces to protect packages
+from stomping on each other's variables. In fact, there's really no such
+thing as a global variable in Perl (although some identifiers default
+to the main package instead of the current one). The package statement
+declares the compilation unit as
+being in the given namespace. The scope of the package declaration
+is from the declaration itself through the end of the enclosing block,
+C<eval>, C<sub>, or end of file, whichever comes first (the same scope
+as the my() and local() operators). All further unqualified dynamic
+identifiers will be in this namespace. A package statement only affects
+dynamic variables--including those you've used local() on--but
+I<not> lexical variables created with my(). Typically it would be
+the first declaration in a file to be included by the C<require> or
+C<use> operator. You can switch into a package in more than one place;
+it merely influences which symbol table is used by the compiler for the
+rest of that block. You can refer to variables and filehandles in other
+packages by prefixing the identifier with the package name and a double
+colon: C<$Package::Variable>. If the package name is null, the C<main>
+package is assumed. That is, C<$::sail> is equivalent to C<$main::sail>.
+
+The old package delimiter was a single quote, but double colon is now the
+preferred delimiter, in part because it's more readable to humans, and
+in part because it's more readable to B<emacs> macros. It also makes C++
+programmers feel like they know what's going on--as opposed to using the
+single quote as separator, which was there to make Ada programmers feel
+like they knew what's going on. Because the old-fashioned syntax is still
+supported for backwards compatibility, if you try to use a string like
+C<"This is $owner's house">, you'll be accessing C<$owner::s>; that is,
+the $s variable in package C<owner>, which is probably not what you meant.
+Use braces to disambiguate, as in C<"This is ${owner}'s house">.
+
+Packages may be nested inside other packages: C<$OUTER::INNER::var>. This
+implies nothing about the order of name lookups, however. All symbols
+are either local to the current package, or must be fully qualified
+from the outer package name down. For instance, there is nowhere
+within package C<OUTER> that C<$INNER::var> refers to C<$OUTER::INNER::var>.
+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, when
+unqualified, the 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 builtin 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 because it will be interpreted instead as a pattern match,
+a substitution, or a transliteration.
+
+(Variables beginning with underscore used to be forced into package
+main, but we decided it was more useful for package writers to be able
+to use leading underscore to indicate private variables and method names.
+$_ is still global though.)
+
+Eval()ed strings are compiled in the package in which the eval() was
+compiled. (Assignments to C<$SIG{}>, however, assume the signal
+handler specified is in the C<main> package. Qualify the signal handler
+name if you wish to have a signal handler in a package.) For an
+example, examine F<perldb.pl> in the Perl library. It initially switches
+to the C<DB> package so that the debugger doesn't interfere with variables
+in the script you are trying to debug. At various points, however, it
+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>.
+
+The special symbol C<__PACKAGE__> contains the current package, but cannot
+(easily) be used to construct variables.
+
+See L<perlsub> for other scoping issues related to my() and local(),
+and L<perlref> regarding closures.
+
+=head2 Symbol Tables
+
+The symbol table for a package happens to be stored in the hash of that
+name with two colons appended. The main symbol table's name is thus
+C<%main::>, or C<%::> for short. Likewise symbol table for the nested
+package mentioned earlier is named C<%OUTER::INNER::>.
+
+The value in each entry of the hash is what you are referring to when you
+use the C<*name> typeglob notation. In fact, the following have the same
+effect, though the first is more efficient because it does the symbol
+table lookups at compile time:
+
+ local *main::foo = *main::bar;
+ local $main::{foo} = $main::{bar};
+
+You can use this to print out all the variables in a package, for
+instance. The standard F<dumpvar.pl> library and the CPAN module
+Devel::Symdump make use of this.
+
+Assignment to a typeglob performs an aliasing operation, i.e.,
+
+ *dick = *richard;
+
+causes variables, subroutines, formats, and file and directory handles
+accessible via the identifier C<richard> also to be accessible via the
+identifier C<dick>. If you want to alias only a particular variable or
+subroutine, you can assign a reference instead:
+
+ *dick = \$richard;
+
+Which makes $richard and $dick the same variable, but leaves
+@richard and @dick as separate arrays. Tricky, eh?
+
+This mechanism may be used to pass and return cheap references
+into or from subroutines if you won't want to copy the whole
+thing. It only works when assigning to dynamic variables, not
+lexicals.
+
+ %some_hash = (); # can't be my()
+ *some_hash = fn( \%another_hash );
+ sub fn {
+ local *hashsym = shift;
+ # now use %hashsym normally, and you
+ # will affect the caller's %another_hash
+ my %nhash = (); # do what you want
+ return \%nhash;
+ }
+
+On return, the reference will overwrite the hash slot in the
+symbol table specified by the *some_hash typeglob. This
+is a somewhat tricky way of passing around references cheaply
+when you won't want to have to remember to dereference variables
+explicitly.
+
+Another use of symbol tables is for making "constant" scalars.
+
+ *PI = \3.14159265358979;
+
+Now you cannot alter $PI, which is probably a good thing all in all.
+This isn't the same as a constant subroutine, which is subject to
+optimization at compile-time. This isn't. A constant subroutine is one
+prototyped to take no arguments and to return a constant expression.
+See L<perlsub> for details on these. The C<use constant> pragma is a
+convenient shorthand for these.
+
+You can say C<*foo{PACKAGE}> and C<*foo{NAME}> to find out what name and
+package the *foo symbol table entry comes from. This may be useful
+in a subroutine that gets passed typeglobs as arguments:
+
+ sub identify_typeglob {
+ my $glob = shift;
+ print 'You gave me ', *{$glob}{PACKAGE}, '::', *{$glob}{NAME}, "\n";
+ }
+ identify_typeglob *foo;
+ identify_typeglob *bar::baz;
+
+This prints
+
+ You gave me main::foo
+ You gave me bar::baz
+
+The *foo{THING} notation can also be used to obtain references to the
+individual elements of *foo, see L<perlref>.
+
+=head2 Package Constructors and Destructors
+
+There are two special subroutine definitions that function as package
+constructors and destructors. These are the C<BEGIN> and C<END>
+routines. The C<sub> is optional for these routines.
+
+A C<BEGIN> subroutine is executed as soon as possible, that is, the moment
+it is completely defined, even before the rest of the containing file
+is parsed. You may have multiple C<BEGIN> blocks within a file--they
+will execute in order of definition. Because a C<BEGIN> block executes
+immediately, it can pull in definitions of subroutines and such from other
+files in time to be visible to the rest of the file. Once a C<BEGIN>
+has run, it is immediately undefined and any code it used is returned to
+Perl's memory pool. This means you can't ever explicitly call a C<BEGIN>.
+
+An C<END> subroutine is executed as late as possible, that is, when
+the interpreter is being exited, even if it is exiting as a result of
+a die() function. (But not if it's polymorphing into another program
+via C<exec>, or being blown out of the water by a signal--you have to
+trap that yourself (if you can).) You may have multiple C<END> blocks
+within a file--they will execute in reverse order of definition; that is:
+last in, first out (LIFO).
+
+Inside an C<END> subroutine, C<$?> contains the value that the script is
+going to pass to C<exit()>. You can modify C<$?> to change the exit
+value of the script. Beware of changing C<$?> by accident (e.g. by
+running something via C<system>).
+
+Note that when you use the B<-n> and B<-p> switches to Perl, C<BEGIN> and
+C<END> work just as they do in B<awk>, as a degenerate case. As currently
+implemented (and subject to change, since its inconvenient at best),
+both C<BEGIN> I<and> C<END> blocks are run when you use the B<-c> switch
+for a compile-only syntax check, although your main code is not.
+
+=head2 Perl Classes
+
+There is no special class syntax in Perl, but a package may function
+as a class if it provides subroutines to act as methods. Such a
+package may also derive some of its methods from another class (package)
+by listing the other package name in its global @ISA array (which
+must be a package global, not a lexical).
+
+For more on this, see L<perltoot> and L<perlobj>.
+
+=head2 Perl Modules
+
+A module is just a package that is defined in a library file of
+the same name, and is designed to be reusable. It may do this by
+providing a mechanism for exporting some of its symbols into the symbol
+table of any package using it. Or it may function as a class
+definition and make its semantics available implicitly through method
+calls on the class and its objects, without explicit exportation of any
+symbols. Or it can do a little of both.
+
+For example, to start a normal module called Some::Module, create
+a file called Some/Module.pm and start with this template:
+
+ package Some::Module; # assumes Some/Module.pm
+
+ use strict;
+
+ BEGIN {
+ use Exporter ();
+ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+ # set the version for version checking
+ $VERSION = 1.00;
+ # if using RCS/CVS, this may be preferred
+ $VERSION = do { my @r = (q$Revision: 2.21 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
+
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&func1 &func2 &func4);
+ %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+
+ # your exported package globals go here,
+ # as well as any optionally exported functions
+ @EXPORT_OK = qw($Var1 %Hashit &func3);
+ }
+ use vars @EXPORT_OK;
+
+ # non-exported package globals go here
+ use vars qw(@more $stuff);
+
+ # initalize package globals, first exported ones
+ $Var1 = '';
+ %Hashit = ();
+
+ # then the others (which are still accessible as $Some::Module::stuff)
+ $stuff = '';
+ @more = ();
+
+ # all file-scoped lexicals must be created before
+ # the functions below that use them.
+
+ # file-private lexicals go here
+ my $priv_var = '';
+ my %secret_hash = ();
+
+ # here's a file-private function as a closure,
+ # callable as &$priv_func; it cannot be prototyped.
+ my $priv_func = sub {
+ # stuff goes here.
+ };
+
+ # make all your functions, whether exported or not;
+ # remember to put something interesting in the {} stubs
+ sub func1 {} # no prototype
+ sub func2() {} # proto'd void
+ sub func3($$) {} # proto'd to 2 scalars
+
+ # this one isn't exported, but could be called!
+ sub func4(\%) {} # proto'd to 1 hash ref
+
+ END { } # module clean-up code here (global destructor)
+
+Then go on to declare and use your variables in functions
+without any qualifications.
+See L<Exporter> and the L<perlmodlib> for details on
+mechanics and style issues in module creation.
+
+Perl modules are included into your program by saying
+
+ use Module;
+
+or
+
+ use Module LIST;
+
+This is exactly equivalent to
+
+ BEGIN { require Module; import Module; }
+
+or
+
+ BEGIN { require Module; import Module LIST; }
+
+As a special case
+
+ use Module ();
+
+is exactly equivalent to
+
+ BEGIN { require Module; }
+
+All Perl module files have the extension F<.pm>. C<use> assumes this so
+that you don't have to spell out "F<Module.pm>" in quotes. This also
+helps to differentiate new modules from old F<.pl> and F<.ph> files.
+Module names are also capitalized unless they're functioning as pragmas,
+"Pragmas" are in effect compiler directives, and are sometimes called
+"pragmatic modules" (or even "pragmata" if you're a classicist).
+
+The two statements:
+
+ require SomeModule;
+ require "SomeModule.pm";
+
+differ from each other in two ways. In the first case, any double
+colons in the module name, such as C<Some::Module>, are translated
+into your system's directory separator, usually "/". The second
+case does not, and would have to be specified literally. The other difference
+is that seeing the first C<require> clues in the compiler that uses of
+indirect object notation involving "SomeModule", as in C<$ob = purge SomeModule>,
+are method calls, not function calls. (Yes, this really can make a difference.)
+
+Because the C<use> statement implies a C<BEGIN> block, the importation
+of semantics happens at the moment the C<use> statement is compiled,
+before the rest of the file is compiled. This is how it is able
+to function as a pragma mechanism, and also how modules are able to
+declare subroutines that are then visible as list operators for
+the rest of the current file. This will not work if you use C<require>
+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::
+ $here = getcwd();
+
+ require Cwd; # make Cwd:: accessible
+ $here = getcwd(); # oops! no main::getcwd()
+
+In general, C<use Module ()> is recommended over C<require Module>,
+because it determines module availability at compile time, not in the
+middle of your program's execution. An exception would be if two modules
+each tried to C<use> each other, and each also called a function from
+that other module. In that case, it's easy to use C<require>s instead.
+
+Perl packages may be nested inside other package names, so we can have
+package names containing C<::>. But if we used that package name
+directly as a filename it would makes for unwieldy or impossible
+filenames on some systems. Therefore, if a module's name is, say,
+C<Text::Soundex>, then its definition is actually found in the library
+file F<Text/Soundex.pm>.
+
+Perl modules always have a F<.pm> file, but there may also be dynamically
+linked executables or autoloaded subroutine definitions associated with
+the module. If so, these will be entirely transparent to the user of
+the module. It is the responsibility of the F<.pm> file to load (or
+arrange to autoload) any additional functionality. The POSIX module
+happens to do both dynamic loading and autoloading, but the user can
+say just C<use POSIX> to get it all.
+
+For more information on writing extension modules, see L<perlxstut>
+and L<perlguts>.
+
+=head1 SEE ALSO
+
+See L<perlmodlib> for general style issues related to building Perl
+modules and classes as well as descriptions of the standard library and
+CPAN, L<Exporter> for how Perl's standard import/export mechanism works,
+L<perltoot> for an in-depth tutorial on creating classes, L<perlobj>
+for a hard-core reference document on objects, and L<perlsub> for an
+explanation of functions and scoping.
diff --git a/contrib/perl5/pod/perlmodinstall.pod b/contrib/perl5/pod/perlmodinstall.pod
new file mode 100644
index 0000000..1c65f1c
--- /dev/null
+++ b/contrib/perl5/pod/perlmodinstall.pod
@@ -0,0 +1,410 @@
+=head1 NAME
+
+perlmodinstall - Installing CPAN Modules
+
+=head1 DESCRIPTION
+
+You can think of a module as the fundamental unit of reusable Perl
+code; see L<perlmod> for details. Whenever anyone creates a chunk of
+Perl code that they think will be useful to the world, they register
+as a Perl developer at http://www.perl.com/CPAN/modules/04pause.html
+so that they can then upload their code to the CPAN. The CPAN is the
+Comprehensive Perl Archive Network and can be accessed at
+http://www.perl.com/CPAN/.
+
+This documentation is for people who want to download CPAN modules
+and install them on their own computer.
+
+=head2 PREAMBLE
+
+You have a file ending in .tar.gz (or, less often, .zip). You know
+there's a tasty module inside. There are four steps you must now
+take:
+
+=over 5
+
+=item B<DECOMPRESS> the file
+
+=item B<UNPACK> the file into a directory
+
+=item B<BUILD> the module (sometimes unnecessary)
+
+=item B<INSTALL> the module.
+
+=back
+
+Here's how to perform each step for each operating system. This is
+I<not> a substitute for reading the README and INSTALL files that
+might have come with your module!
+
+Also note that these instructions are tailored for installing the
+module into your system's repository of Perl modules. But you can
+install modules into any directory you wish. For instance, where I
+say C<perl Makefile.PL>, you can substitute C<perl
+Makefile.PL PREFIX=/my/perl_directory> to install the modules
+into C</my/perl_directory>. Then you can use the modules
+from your Perl programs with C<use lib
+"/my/perl_directory/lib/site_perl";> or sometimes just C<use
+"/my/perl_directory";>.
+
+=over 4
+
+=item *
+
+B<If you're on Unix,>
+
+You can use Andreas Koenig's CPAN module
+( http://www.perl.com/CPAN/modules/by-module/CPAN )
+to automate the following steps, from DECOMPRESS through INSTALL.
+
+A. DECOMPRESS
+
+Decompress the file with C<gzip -d yourmodule.tar.gz>
+
+You can get gzip from ftp://prep.ai.mit.edu/pub/gnu.
+
+Or, you can combine this step with the next to save disk space:
+
+ gzip -dc yourmodule.tar.gz | tar -xof -
+
+B. UNPACK
+
+Unpack the result with C<tar -xof yourmodule.tar>
+
+C. BUILD
+
+Go into the newly-created directory and type:
+
+ perl Makefile.PL
+ make
+ make test
+
+D. INSTALL
+
+While still in that directory, type:
+
+ make install
+
+Make sure you have the appropriate permissions to install the module
+in your Perl 5 library directory. Often, you'll need to be root.
+
+That's all you need to do on Unix systems with dynamic linking.
+Most Unix systems have dynamic linking -- if yours doesn't, or if for
+another reason you have a statically-linked perl, B<and> the
+module requires compilation, you'll need to build a new Perl binary
+that includes the module. Again, you'll probably need to be root.
+
+=item *
+
+B<If you're running Windows 95 or NT with the ActiveState port of Perl>
+
+ A. DECOMPRESS
+
+You can use the shareware Winzip ( http://www.winzip.com ) to
+decompress and unpack modules.
+
+ B. UNPACK
+
+If you used WinZip, this was already done for you.
+
+ C. BUILD
+
+Does the module require compilation (i.e. does it have files
+that end in .xs, .c, .h, .y, .cc, .cxx, or .C)? If it does, you're on
+your own. You can try compiling it yourself if you have a C compiler.
+If you're successful, consider uploading the resulting binary to the
+CPAN for others to use. If it doesn't, go to INSTALL.
+
+ D. INSTALL
+
+Copy the module into your Perl's I<lib> directory. That'll be one
+of the directories you see when you type
+
+ perl -e 'print "@INC"'
+
+=item *
+
+B<If you're running Windows 95 or NT with the core Windows distribution of Perl,>
+
+ A. DECOMPRESS
+
+When you download the module, make sure it ends in either
+C<.tar.gz> or C<.zip>. Windows browsers sometimes
+download C<.tar.gz> files as C<_tar.tar>, because
+early versions of Windows prohibited more than one dot in a filename.
+
+You can use the shareware WinZip ( http://www.winzip.com ) to
+decompress and unpack modules.
+
+Or, you can use InfoZip's C<unzip> utility (
+http://www.cdrom.com/pub/infozip/Info-Zip.html ) to uncompress
+C<.zip> files; type C<unzip yourmodule.zip> in
+your shell.
+
+Or, if you have a working C<tar> and C<gzip>, you can
+type
+
+ gzip -cd yourmodule.tar.gz | tar xvf -
+
+in the shell to decompress C<yourmodule.tar.gz>. This will
+UNPACK your module as well.
+
+ B. UNPACK
+
+All of the methods in DECOMPRESS will have done this for you.
+
+ C. BUILD
+
+Go into the newly-created directory and type:
+
+ perl Makefile.PL
+ dmake
+ dmake test
+
+Depending on your perl configuration, C<dmake> might not be
+available. You might have to substitute whatever C<perl
+-V:make> says. (Usually, that will be C<nmake> or
+C<make>.)
+
+ D. INSTALL
+
+While still in that directory, type:
+
+ dmake install
+
+=item *
+
+B<If you're using a Macintosh,>
+
+A. DECOMPRESS
+
+You can either use StuffIt Expander ( http://www.aladdinsys.com/ ) in
+combination with I<DropStuff with Expander Enhancer>
+(shareware), or the freeware MacGzip (
+http://persephone.cps.unizar.es/general/gente/spd/gzip/gzip.html ).
+
+B. UNPACK
+
+If you're using DropStuff or Stuffit, you can just extract the tar
+archive. Otherwise, you can use the freeware I<suntar> (
+http://www.cirfid.unibo.it/~speranza ).
+
+C. BUILD
+
+Does the module require compilation?
+
+1. If it does,
+
+Overview: You need MPW and a combination of new and old CodeWarrior
+compilers for MPW and libraries. Makefiles created for building under
+MPW use the Metrowerks compilers. It's most likely possible to build
+without other compilers, but it has not been done successfully, to our
+knowledge. Read the documentation in MacPerl: Power and Ease (
+http://www.ptf.com/macperl/ ) on porting/building extensions, or find
+an existing precompiled binary, or hire someone to build it for you.
+
+Or, ask someone on the mac-perl mailing list (mac-perl@iis.ee.ethz.ch)
+to build it for you. To subscribe to the mac-perl mailing list, send
+mail to mac-perl-request@iis.ee.ethz.ch.
+
+2. If the module doesn't require compilation, go to INSTALL.
+
+D. INSTALL
+
+Make sure the newlines for the modules are in Mac format, not Unix format.
+Move the files manually into the correct folders.
+
+Move the files to their final destination: This will
+most likely be in C<$ENV{MACPERL}site_lib:> (i.e.,
+C<HD:MacPerl folder:site_lib:>). You can add new paths to
+the default C<@INC> in the Preferences menu item in the
+MacPerl application (C<$ENV{MACPERL}site_lib:> is added
+automagically). Create whatever directory structures are required
+(i.e., for C<Some::Module>, create
+C<$ENV{MACPERL}site_lib:Some:> and put
+C<Module.pm> in that directory).
+
+Run the following script (or something like it):
+
+ #!perl -w
+ use AutoSplit;
+ my $dir = "${MACPERL}site_perl";
+ autosplit("$dir:Some:Module.pm", "$dir:auto", 0, 1, 1);
+
+Eventually there should be a way to automate the installation process; some
+solutions exist, but none are ready for the general public yet.
+
+=item *
+
+B<If you're on the DJGPP port of DOS,>
+
+ A. DECOMPRESS
+
+djtarx ( ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/ )
+will both uncompress and unpack.
+
+ B. UNPACK
+
+See above.
+
+ C. BUILD
+
+Go into the newly-created directory and type:
+
+ perl Makefile.PL
+ make
+ make test
+
+You will need the packages mentioned in C<Readme.dos>
+in the Perl distribution.
+
+ D. INSTALL
+
+While still in that directory, type:
+
+ make install
+
+You will need the packages mentioned in Readme.dos in the Perl distribution.
+
+=item *
+
+B<If you're on OS/2,>
+
+Get the EMX development suite and gzip/tar, from either Hobbes (
+http://hobbes.nmsu.edu ) or Leo ( http://www.leo.org ), and then follow
+the instructions for Unix.
+
+=item *
+
+B<If you're on VMS,>
+
+When downloading from CPAN, save your file with a C<.tgz>
+extension instead of C<.tar.gz>. All other periods in the
+filename should be replaced with underscores. For example,
+C<Your-Module-1.33.tar.gz> should be downloaded as
+C<Your-Module-1_33.tgz>.
+
+A. DECOMPRESS
+
+Type
+
+ gzip -d Your-Module.tgz
+
+or, for zipped modules, type
+
+ unzip Your-Module.zip
+
+Executables for gzip, zip, and VMStar ( Alphas:
+http://www.openvms.digital.com/cd/000TOOLS/ALPHA/ and Vaxen:
+http://www.openvms.digital.com/cd/000TOOLS/VAX/ ).
+
+gzip and tar
+are also available at ftp://ftp.digital.com/pub/VMS.
+
+Note that GNU's gzip/gunzip is not the same as Info-ZIP's zip/unzip
+package. The former is a simple compression tool; the latter permits
+creation of multi-file archives.
+
+B. UNPACK
+
+If you're using VMStar:
+
+ VMStar xf Your-Module.tar
+
+Or, if you're fond of VMS command syntax:
+
+ tar/extract/verbose Your_Module.tar
+
+C. BUILD
+
+Make sure you have MMS (from Digital) or the freeware MMK ( available from MadGoat at http://www.madgoat.com ). Then type this to create the
+DESCRIP.MMS for the module:
+
+ perl Makefile.PL
+
+Now you're ready to build:
+
+ mms
+ mms test
+
+Substitute C<mmk> for C<mms> above if you're using MMK.
+
+D. INSTALL
+
+Type
+
+ mms install
+
+Substitute C<mmk> for C<mms> above if you're using MMK.
+
+=item *
+
+B<If you're on MVS>,
+
+Introduce the .tar.gz file into an HFS as binary; don't translate from
+ASCII to EBCDIC.
+
+A. DECOMPRESS
+
+ Decompress the file with C<gzip -d yourmodule.tar.gz>
+
+ You can get gzip from
+ http://www.s390.ibm.com/products/oe/bpxqp1.html.
+
+B. UNPACK
+
+Unpack the result with
+
+ pax -o to=IBM-1047,from=ISO8859-1 -r < yourmodule.tar
+
+The BUILD and INSTALL steps are identical to those for Unix. Some
+modules generate Makefiles that work better with GNU make, which is
+available from http://www.mks.com/s390/gnu/index.htm.
+
+=back
+
+=head1 HEY
+
+If you have any suggested changes for this page, let me know. Please
+don't send me mail asking for help on how to install your modules.
+There are too many modules, and too few Orwants, for me to be able to
+answer or even acknowledge all your questions. Contact the module
+author instead, or post to comp.lang.perl.modules, or ask someone
+familiar with Perl on your operating system.
+
+=head1 AUTHOR
+
+Jon Orwant
+
+orwant@tpj.com
+
+The Perl Journal, http://tpj.com
+
+with invaluable help from Brandon Allbery, Charles Bailey, Graham
+Barr, Dominic Dunlop, Jarkko Hietaniemi, Ben Holzman, Tom Horsley,
+Nick Ing-Simmons, Tuomas J. Lukka, Laszlo Molnar, Chris Nandor, Alan
+Olsen, Peter Prymmer, Gurusamy Sarathy, Christoph Spalinger, Dan
+Sugalski, Larry Virden, and Ilya Zakharevich.
+
+July 22, 1998
+
+=head1 COPYRIGHT
+
+Copyright (C) 1998 Jon Orwant. All Rights Reserved.
+
+Permission is granted to make and distribute verbatim copies of this
+documentation provided the copyright notice and this permission notice are
+preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+documentation under the conditions for verbatim copying, provided also
+that they are marked clearly as modified versions, that the authors'
+names and title are unchanged (though subtitles and additional
+authors' names may be added), and that the entire resulting derived
+work is distributed under the terms of a permission notice identical
+to this one.
+
+Permission is granted to copy and distribute translations of this
+documentation into another language, under the above conditions for
+modified versions.
+
diff --git a/contrib/perl5/pod/perlmodlib.pod b/contrib/perl5/pod/perlmodlib.pod
new file mode 100644
index 0000000..5d0e5b0
--- /dev/null
+++ b/contrib/perl5/pod/perlmodlib.pod
@@ -0,0 +1,1102 @@
+=head1 NAME
+
+perlmodlib - constructing new Perl modules and finding existing ones
+
+=head1 DESCRIPTION
+
+=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
+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 and therefore far from
+bulletproof.
+
+=head2 Pragmatic Modules
+
+They work somewhat like pragmas in that they tend to affect the compilation of
+your program, and thus will usually work well only when used within a
+C<use>, or C<no>. Most of these are locally scoped, so an inner BLOCK
+may countermand any of these by saying:
+
+ no integer;
+ no strict 'refs';
+
+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 predeclare a variables or subroutines within a particular
+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>.
+
+The following pragmas are defined (and have their own documentation).
+
+=over 12
+
+=item use autouse MODULE => qw(sub1 sub2 sub3)
+
+Defers C<require MODULE> until someone calls one of the specified
+subroutines (which must be exported by MODULE). This pragma should be
+used with caution, and only when necessary.
+
+=item blib
+
+manipulate @INC at compile time to use MakeMaker's uninstalled version
+of a package
+
+=item diagnostics
+
+force verbose warning diagnostics
+
+=item integer
+
+compute arithmetic in integer instead of double
+
+=item less
+
+request less of something from the compiler
+
+=item lib
+
+manipulate @INC at compile time
+
+=item locale
+
+use or ignore current locale for builtin operations (see L<perllocale>)
+
+=item ops
+
+restrict named opcodes when compiling or running Perl code
+
+=item overload
+
+overload basic Perl operations
+
+=item re
+
+alter behaviour of regular expressions
+
+=item sigtrap
+
+enable simple signal handling
+
+=item strict
+
+restrict unsafe constructs
+
+=item subs
+
+predeclare sub names
+
+=item vmsish
+
+adopt certain VMS-specific behaviors
+
+=item vars
+
+predeclare global variable names
+
+=back
+
+=head2 Standard Modules
+
+Standard, bundled modules are all expected to behave in a well-defined
+manner with respect to namespace pollution because they use the
+Exporter module. See their own documentation for details.
+
+=over 12
+
+=item AnyDBM_File
+
+provide framework for multiple DBMs
+
+=item AutoLoader
+
+load functions only on demand
+
+=item AutoSplit
+
+split a package for autoloading
+
+=item Benchmark
+
+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::Struct
+
+declare struct-like datatypes
+
+=item Config
+
+access Perl configuration information
+
+=item Cwd
+
+get pathname of current working directory
+
+=item DB_File
+
+access to Berkeley DB
+
+=item Devel::SelfStubber
+
+generate stubs for a SelfLoading module
+
+=item DirHandle
+
+supply object methods for directory handles
+
+=item DynaLoader
+
+dynamically load C libraries into Perl code
+
+=item English
+
+use nice English (or awk) names for ugly punctuation variables
+
+=item Env
+
+import environment variables
+
+=item Exporter
+
+implements default import method for modules
+
+=item ExtUtils::Embed
+
+utilities for embedding Perl in C/C++ applications
+
+=item ExtUtils::Install
+
+install files from here to there
+
+=item ExtUtils::Liblist
+
+determine libraries to use and how to use them
+
+=item ExtUtils::MM_OS2
+
+methods to override Unix behaviour in ExtUtils::MakeMaker
+
+=item ExtUtils::MM_Unix
+
+methods used by ExtUtils::MakeMaker
+
+=item ExtUtils::MM_VMS
+
+methods to override Unix behaviour in ExtUtils::MakeMaker
+
+=item ExtUtils::MakeMaker
+
+create an extension Makefile
+
+=item ExtUtils::Manifest
+
+utilities to write and check a MANIFEST file
+
+=item ExtUtils::Mkbootstrap
+
+make a bootstrap file for use by DynaLoader
+
+=item ExtUtils::Mksymlists
+
+write linker options files for dynamic extension
+
+=item ExtUtils::testlib
+
+add blib/* directories to @INC
+
+=item Fatal
+
+make errors in builtins or Perl functions fatal
+
+=item Fcntl
+
+load the C Fcntl.h defines
+
+=item File::Basename
+
+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
+
+=item File::Find
+
+traverse a file tree
+
+=item File::Path
+
+create or remove a series of directories
+
+=item File::stat
+
+by-name interface to Perl's builtin 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
+
+=item Getopt::Long
+
+extended processing of command line options
+
+=item Getopt::Std
+
+process single-character switches with switch clustering
+
+=item I18N::Collate
+
+compare 8-bit scalar data according to the current locale
+
+=item IO
+
+load various IO modules
+
+=item IO::File
+
+supply object methods for filehandles
+
+=item IO::Handle
+
+supply object methods for I/O handles
+
+=item IO::Pipe
+
+supply object methods for pipes
+
+=item IO::Seekable
+
+supply seek based methods for I/O objects
+
+=item IO::Select
+
+OO interface to the select system call
+
+=item IO::Socket
+
+object interface to socket communications
+
+=item IPC::Open2
+
+open a process for both reading and writing
+
+=item IPC::Open3
+
+open a process for reading, writing, and error handling
+
+=item Math::BigFloat
+
+arbitrary length float math package
+
+=item Math::BigInt
+
+arbitrary size integer math package
+
+=item Math::Complex
+
+complex numbers and associated mathematical functions
+
+=item Math::Trig
+
+simple interface to parts of Math::Complex for those who
+need trigonometric functions only for real numbers
+
+=item NDBM_File
+
+tied access to ndbm files
+
+=item Net::Ping
+
+Hello, anybody home?
+
+=item Net::hostent
+
+by-name interface to Perl's builtin gethost*() functions
+
+=item Net::netent
+
+by-name interface to Perl's builtin getnet*() functions
+
+=item Net::protoent
+
+by-name interface to Perl's builtin getproto*() functions
+
+=item Net::servent
+
+by-name interface to Perl's builtin getserv*() functions
+
+=item Opcode
+
+disable named opcodes when compiling or running Perl code
+
+=item Pod::Text
+
+convert POD data to formatted ASCII text
+
+=item POSIX
+
+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
+
+=item SelectSaver
+
+save and restore selected file handle
+
+=item SelfLoader
+
+load functions only on demand
+
+=item Shell
+
+run shell commands transparently within Perl
+
+=item Socket
+
+load the C socket.h defines and structure manipulators
+
+=item Symbol
+
+manipulate Perl symbols and their names
+
+=item Sys::Hostname
+
+try every conceivable way to get hostname
+
+=item Sys::Syslog
+
+interface to the Unix syslog(3) calls
+
+=item Term::Cap
+
+termcap interface
+
+=item Term::Complete
+
+word completion module
+
+=item Term::ReadLine
+
+interface to various C<readline> packages
+
+=item Test::Harness
+
+run Perl standard test scripts with statistics
+
+=item Text::Abbrev
+
+create an abbreviation table from a list
+
+=item Text::ParseWords
+
+parse text into an array of tokens
+
+=item Text::Soundex
+
+implementation of the Soundex Algorithm as described by Knuth
+
+=item Text::Tabs
+
+expand and unexpand tabs per the Unix expand(1) and unexpand(1)
+
+=item Text::Wrap
+
+line wrapping to form simple paragraphs
+
+=item Tie::Hash
+
+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
+
+=item Tie::SubstrHash
+
+fixed-table-size, fixed-key-length hashing
+
+=item Time::Local
+
+efficiently compute time from local and GMT time
+
+=item Time::gmtime
+
+by-name interface to Perl's builtin gmtime() function
+
+=item Time::localtime
+
+by-name interface to Perl's builtin 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 builtin getgr*() functions
+
+=item User::pwent
+
+by-name interface to Perl's builtin getpw*() functions
+
+=back
+
+To find out I<all> the modules installed on your system, including
+those without documentation or outside the standard release, do this:
+
+ % find `perl -e 'print "@INC"'` -name '*.pm' -print
+
+They should all have their own documentation installed and accessible via
+your system man(1) command. If that fails, try the I<perldoc> program.
+
+=head2 Extension Modules
+
+Extension modules are written in C (or a mix of Perl and C) and may be
+statically linked or in general are
+dynamically loaded into Perl if and when you need them. Supported
+extension modules include the Socket, Fcntl, and POSIX modules.
+
+Many popular C extension modules do not come bundled (at least, not
+completely) due to their sizes, volatility, or simply lack of time for
+adequate testing and configuration across the multitude of platforms on
+which Perl was beta-tested. You are encouraged to look for them in
+archie(1L), the Perl FAQ or Meta-FAQ, the WWW page, and even with their
+authors before randomly posting asking for their present condition and
+disposition.
+
+=head1 CPAN
+
+CPAN stands for the Comprehensive Perl Archive Network. This is a globally
+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
+
+=item *
+Development Support
+
+=item *
+Operating System Interfaces
+
+=item *
+Networking, Device Control (modems) and InterProcess Communication
+
+=item *
+Data Types and Data Type Utilities
+
+=item *
+Database Interfaces
+
+=item *
+User Interfaces
+
+=item *
+Interfaces to / Emulations of Other Programming Languages
+
+=item *
+File Names, File Systems and File Locking (see also File Handles)
+
+=item *
+String Processing, Language Text Processing, Parsing, and Searching
+
+=item *
+Option, Argument, Parameter, and Configuration File Processing
+
+=item *
+Internationalization and Locale
+
+=item *
+Authentication, Security, and Encryption
+
+=item *
+World Wide Web, HTML, HTTP, CGI, MIME
+
+=item *
+Server and Daemon Utilities
+
+=item *
+Archiving and Compression
+
+=item *
+Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
+
+=item *
+Mail and Usenet News
+
+=item *
+Control Flow Utilities (callbacks and exceptions etc)
+
+=item *
+File Handle and Input/Output Stream Utilities
+
+=item *
+Miscellaneous Modules
+
+=back
+
+The registered CPAN sites as of this writing include the following.
+You should try to choose one close to you:
+
+=over
+
+=item *
+Africa
+
+ South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
+
+=item *
+Asia
+
+ Hong Kong ftp://ftp.hkstar.com/pub/CPAN/
+ Japan ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
+ ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
+ South Korea ftp://ftp.nuri.net/pub/CPAN/
+ Taiwan ftp://dongpo.math.ncu.edu.tw/perl/CPAN/
+ ftp://ftp.wownet.net/pub2/PERL/
+
+=item *
+Australasia
+
+ Australia ftp://ftp.netinfo.com.au/pub/perl/CPAN/
+ New Zealand ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/
+
+=item *
+Europe
+
+ Austria ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
+ Belgium ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
+ Czech Republic ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/
+ Denmark ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
+ Finland ftp://ftp.funet.fi/pub/languages/perl/CPAN/
+ France ftp://ftp.ibp.fr/pub/perl/CPAN/
+ ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/
+ Germany ftp://ftp.gmd.de/packages/CPAN/
+ ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/
+ ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
+ ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
+ ftp://ftp.uni-erlangen.de/pub/source/Perl/CPAN/
+ ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
+ Greece ftp://ftp.ntua.gr/pub/lang/perl/
+ Hungary ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
+ Italy ftp://cis.utovrm.it/CPAN/
+ the Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
+ ftp://ftp.EU.net/packages/cpan/
+ Norway ftp://ftp.uit.no/pub/languages/perl/cpan/
+ Poland ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
+ ftp://sunsite.icm.edu.pl/pub/CPAN/
+ Portugal ftp://ftp.ci.uminho.pt/pub/lang/perl/
+ ftp://ftp.telepac.pt/pub/CPAN/
+ Russia ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
+ Slovenia ftp://ftp.arnes.si/software/perl/CPAN/
+ Spain ftp://ftp.etse.urv.es/pub/mirror/perl/
+ ftp://ftp.rediris.es/mirror/CPAN/
+ Sweden ftp://ftp.sunet.se/pub/lang/perl/CPAN/
+ UK ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
+ ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
+ ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/
+
+=item *
+North America
+
+ Ontario ftp://ftp.utilis.com/public/CPAN/
+ ftp://enterprise.ic.gc.ca/pub/perl/CPAN/
+ Manitoba ftp://theory.uwinnipeg.ca/pub/CPAN/
+ California ftp://ftp.digital.com/pub/plan/perl/CPAN/
+ ftp://ftp.cdrom.com/pub/perl/CPAN/
+ Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
+ Florida ftp://ftp.cis.ufl.edu/pub/perl/CPAN/
+ Illinois ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/
+ Massachusetts ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
+ New York ftp://ftp.rge.com/pub/languages/perl/
+ North Carolina ftp://ftp.duke.edu/pub/perl/
+ Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/
+ Oregon http://www.perl.org/CPAN/
+ ftp://ftp.orst.edu/pub/packages/CPAN/
+ Pennsylvania ftp://ftp.epix.net/pub/languages/perl/
+ Texas ftp://ftp.sedl.org/pub/mirrors/CPAN/
+ ftp://ftp.metronet.com/pub/perl/
+
+=item *
+South America
+
+ Chile ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/
+
+=back
+
+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
+
+(The following section is borrowed directly from Tim Bunce's modules
+file, available at your nearest CPAN site.)
+
+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
+first argument, either the name of a package (for "static" methods),
+or a reference to something (for "virtual" methods).
+
+A module is a file that (by convention) provides a class of the same
+name (sans the .pm), plus an import method in that class that can be
+called to fetch exported symbols. This module may implement some of
+its methods by loading dynamic C or C++ objects, but that should be
+totally transparent to the user of the module. Likewise, the module
+might set up an AUTOLOAD function to slurp in subroutine definitions on
+demand, but this is also transparent. Only the F<.pm> file is required to
+exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about
+the AUTOLOAD mechanism.
+
+=head2 Guidelines for Module Creation
+
+=over 4
+
+=item Do similar modules already exist in some form?
+
+If so, please try to reuse the existing modules either in whole or
+by inheriting useful features into a new class. If this is not
+practical try to get together with the module authors to work on
+extending or enhancing the functionality of the existing modules.
+A perfect example is the plethora of packages in perl4 for dealing
+with command line options.
+
+If you are writing a module to expand an already existing set of
+modules, please coordinate with the author of the package. It
+helps if you follow the same naming scheme and module interaction
+scheme as the original author.
+
+=item Try to design the new module to be easy to extend and reuse.
+
+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 {
+ my $class = shift;
+ return bless {}, $class;
+ }
+
+or even this if you'd like it to be used as either a static
+or a virtual method.
+
+ sub new {
+ my $self = shift;
+ my $class = ref($self) || $self;
+ return bless {}, $class;
+ }
+
+Pass arrays as references so more parameters can be added later
+(it's also faster). Convert functions into methods where
+appropriate. Split large methods into smaller more flexible ones.
+Inherit methods from other modules if appropriate.
+
+Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
+Generally you can delete the "C<eq 'FOO'>" part with no harm at all.
+Let the objects look after themselves! Generally, avoid hard-wired
+class names as far as possible.
+
+Avoid C<$r-E<gt>Class::func()> where using C<@ISA=qw(... Class ...)> and
+C<$r-E<gt>func()> would work (see L<perlbot> for more details).
+
+Use autosplit so little used or newly added functions won't be a
+burden to programs that don't use them. Add test functions to
+the module after __END__ either using AutoSplit or by saying:
+
+ eval join('',<main::DATA>) || die $@ unless caller();
+
+Does your module pass the 'empty subclass' test? If you say
+"C<@SUBCLASS::ISA = qw(YOURCLASS);>" your applications should be able
+to use SUBCLASS in exactly the same way as YOURCLASS. For example,
+does your application still work if you change: C<$obj = new YOURCLASS;>
+into: C<$obj = new SUBCLASS;> ?
+
+Avoid keeping any state information in your packages. It makes it
+difficult for multiple other packages to use yours. Keep state
+information in objects.
+
+Always use B<-w>. Try to C<use strict;> (or C<use strict qw(...);>).
+Remember that you can add C<no strict qw(...);> to individual blocks
+of code that need less strictness. Always use B<-w>. Always use B<-w>!
+Follow the guidelines in the perlstyle(1) manual.
+
+=item Some simple style guidelines
+
+The perlstyle manual supplied with Perl has many helpful points.
+
+Coding style is a matter of personal taste. Many people evolve their
+style over several years as they learn what helps them write and
+maintain good code. Here's one set of assorted suggestions that
+seem to be widely used by experienced developers:
+
+Use underscores to separate words. It is generally easier to read
+$var_names_like_this than $VarNamesLikeThis, especially for
+non-native speakers of English. It's also a simple rule that works
+consistently with VAR_NAMES_LIKE_THIS.
+
+Package/Module names are an exception to this rule. Perl informally
+reserves lowercase module names for 'pragma' modules like integer
+and strict. Other modules normally begin with a capital letter and
+use mixed case with no underscores (need to be short and portable).
+
+You may find it helpful to use letter case to indicate the scope
+or nature of a variable. For example:
+
+ $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
+ $Some_Caps_Here package-wide global/static
+ $no_caps_here function scope my() or local() variables
+
+Function and method names seem to work best as all lowercase.
+e.g., C<$obj-E<gt>as_string()>.
+
+You can use a leading underscore to indicate that a variable or
+function should not be used outside the package that defined it.
+
+=item Select what to export.
+
+Do NOT export method names!
+
+Do NOT export anything else by default without a good reason!
+
+Exports pollute the namespace of the module user. If you must
+export try to use @EXPORT_OK in preference to @EXPORT and avoid
+short or common names to reduce the risk of name clashes.
+
+Generally anything not exported is still accessible from outside the
+module using the ModuleName::item_name (or C<$blessed_ref-E<gt>method>)
+syntax. By convention you can use a leading underscore on names to
+indicate informally that they are 'internal' and not for public use.
+
+(It is actually possible to get private functions by saying:
+C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
+directly as a method, because a method must have a name in the symbol
+table.)
+
+As a general rule, if the module is trying to be object oriented
+then export nothing. If it's just a collection of functions then
+@EXPORT_OK anything but use @EXPORT with caution.
+
+=item Select a name for the module.
+
+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
+nested module names to group informally or categorize a module.
+There should be a very good reason for a module not to have a nested name.
+Module names should begin with a capital letter.
+
+Having 57 modules all called Sort will not make life easy for anyone
+(though having 23 called Sort::Quick is only marginally better :-).
+Imagine someone trying to install your module alongside many others.
+If in any doubt ask for suggestions in comp.lang.perl.misc.
+
+If you are developing a suite of related modules/classes it's good
+practice to use nested classes with a common prefix as this will
+avoid namespace clashes. For example: Xyz::Control, Xyz::View,
+Xyz::Model etc. Use the modules in this list as a naming guide.
+
+If adding a new module to a set, follow the original author's
+standards for naming modules and the interface to methods in
+those modules.
+
+To be portable each component of a module name should be limited to
+11 characters. If it might be used on MS-DOS then try to ensure each is
+unique in the first 8 characters. Nested modules make this easier.
+
+=item Have you got it right?
+
+How do you know that you've made the right decisions? Have you
+picked an interface design that will cause problems later? Have
+you picked the most appropriate name? Do you have any questions?
+
+The best way to know for sure, and pick up many helpful suggestions,
+is to ask someone who knows. Comp.lang.perl.misc is read by just about
+all the people who develop modules and it's the best place to ask.
+
+All you need to do is post a short summary of the module, its
+purpose and interfaces. A few lines on each of the main methods is
+probably enough. (If you post the whole module it might be ignored
+by busy people - generally the very people you want to read it!)
+
+Don't worry about posting if you can't say when the module will be
+ready - just say so in the message. It might be worth inviting
+others to help you, they may be able to complete it for you!
+
+=item README and other Additional Files.
+
+It's well known that software developers usually fully document the
+software they write. If, however, the world is in urgent need of
+your software and there is not enough time to write the full
+documentation please at least provide a README file containing:
+
+=over 10
+
+=item *
+A description of the module/package/extension etc.
+
+=item *
+A copyright notice - see below.
+
+=item *
+Prerequisites - what else you may need to have.
+
+=item *
+How to build it - possible changes to Makefile.PL etc.
+
+=item *
+How to install it.
+
+=item *
+Recent changes in this release, especially incompatibilities
+
+=item *
+Changes / enhancements you plan to make in the future.
+
+=back
+
+If the README file seems to be getting too large you may wish to
+split out some of the sections into separate files: INSTALL,
+Copying, ToDo etc.
+
+=over 4
+
+=item Adding a Copyright Notice.
+
+How you choose to license your work is a personal decision.
+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 licence: The GNU
+GPL and The Artistic Licence (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
+Perl community at large is to state something simply like:
+
+ Copyright (c) 1995 Your Name. All rights reserved.
+ This program is free software; you can redistribute it and/or
+ modify it under the same terms as Perl itself.
+
+This statement should at least appear in the README file. You may
+also wish to include it in a Copying file and your source files.
+Remember to include the other words in addition to the Copyright.
+
+=item Give the module a version/issue/release number.
+
+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 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.
+
+It may be handy to add a function or method to retrieve the number.
+Use the number in announcements and archive file names when
+releasing the module (ModuleName-1.02.tar.Z).
+See perldoc ExtUtils::MakeMaker.pm for details.
+
+=item How to release and distribute a module.
+
+It's good idea to post an announcement of the availability of your
+module (or the module itself if small) to the comp.lang.perl.announce
+Usenet newsgroup. This will at least ensure very wide once-off
+distribution.
+
+If possible you should place the module into a major ftp archive and
+include details of its location in your announcement.
+
+Some notes about ftp archives: Please use a long descriptive file
+name that includes the version number. Most incoming directories
+will not be readable/listable, i.e., you won't be able to see your
+file after uploading it. Remember to send your email notification
+message as soon as possible after uploading else your file may get
+deleted automatically. Allow time for the file to be processed
+and/or check the file has been processed before announcing its
+location.
+
+FTP Archives for Perl Modules:
+
+Follow the instructions and links on
+
+ http://franz.ww.tu-berlin.de/modulelist
+
+or upload to one of these sites:
+
+ ftp://franz.ww.tu-berlin.de/incoming
+ ftp://ftp.cis.ufl.edu/incoming
+
+and notify <F<upload@franz.ww.tu-berlin.de>>.
+
+By using the WWW interface you can ask the Upload Server to mirror
+your modules from your ftp or WWW site into your own directory on
+CPAN!
+
+Please remember to send me an updated entry for the Module list!
+
+=item Take care when changing a released module.
+
+Always strive to remain compatible with previous released versions.
+Otherwise try to add a mechanism to revert to the
+old behaviour if people rely on it. Document incompatible changes.
+
+=back
+
+=back
+
+=head2 Guidelines for Converting Perl 4 Library Scripts into Modules
+
+=over 4
+
+=item There is no requirement to convert anything.
+
+If it ain't broke, don't fix it! Perl 4 library scripts should
+continue to work with no problems. You may need to make some minor
+changes (like escaping non-array @'s in double quoted strings) but
+there is no need to convert a .pl file into a Module for just that.
+
+=item Consider the implications.
+
+All Perl applications that make use of the script will need to
+be changed (slightly) if the script is converted into a module. Is
+it worth it unless you plan to make other changes at the same time?
+
+=item Make the most of the opportunity.
+
+If you are going to convert the script to a module you can use the
+opportunity to redesign the interface. The 'Guidelines for Module
+Creation' above include many of the issues you should consider.
+
+=item The pl2pm utility will get you started.
+
+This utility will read *.pl files (given as parameters) and write
+corresponding *.pm files. The pl2pm utilities does the following:
+
+=over 10
+
+=item *
+Adds the standard Module prologue lines
+
+=item *
+Converts package specifiers from ' to ::
+
+=item *
+Converts die(...) to croak(...)
+
+=item *
+Several other minor changes
+
+=back
+
+Being a mechanical process pl2pm is not bullet proof. The converted
+code will need careful checking, especially any package statements.
+Don't delete the original .pl file till the new .pm one works!
+
+=back
+
+=head2 Guidelines for Reusing Application Code
+
+=over 4
+
+=item Complete applications rarely belong in the Perl Module Library.
+
+=item Many applications contain some Perl code that could be reused.
+
+Help save the world! Share your code in a form that makes it easy
+to reuse.
+
+=item Break-out the reusable code into one or more separate module files.
+
+=item Take the opportunity to reconsider and redesign the interfaces.
+
+=item In some cases the 'application' can then be reduced to a small
+
+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
+ % perl -mModule::Name ... (in perl5.002 or higher)
+
+=back
+
+=head1 NOTE
+
+Perl does not enforce private and public parts of its modules as you may
+have been used to in other languages like C++, Ada, or Modula-17. Perl
+doesn't have an infatuation with enforced privacy. It would prefer
+that you stayed out of its living room because you weren't invited, not
+because it has a shotgun.
+
+The module and its user have a contract, part of which is common law,
+and part of which is "written". Part of the common law contract is
+that a module doesn't pollute any namespace it wasn't asked to. The
+written contract for the module (A.K.A. documentation) may make other
+provisions. But then you know when you C<use RedefineTheWorld> that
+you're redefining the world and willing to take the consequences.
diff --git a/contrib/perl5/pod/perlobj.pod b/contrib/perl5/pod/perlobj.pod
new file mode 100644
index 0000000..f10fbdf
--- /dev/null
+++ b/contrib/perl5/pod/perlobj.pod
@@ -0,0 +1,541 @@
+=head1 NAME
+
+perlobj - Perl objects
+
+=head1 DESCRIPTION
+
+First of all, you need to understand what references are in Perl.
+See L<perlref> for that. Second, if you still find the following
+reference work too complicated, a tutorial on object-oriented programming
+in Perl can be found in L<perltoot>.
+
+If you're still with us, then
+here are three very simple definitions that you should find reassuring.
+
+=over 4
+
+=item 1.
+
+An object is simply a reference that happens to know which class it
+belongs to.
+
+=item 2.
+
+A class is simply a package that happens to provide methods to deal
+with object references.
+
+=item 3.
+
+A method is simply a subroutine that expects an object reference (or
+a package name, for class methods) as the first argument.
+
+=back
+
+We'll cover these points now in more depth.
+
+=head2 An Object is Simply a Reference
+
+Unlike say C++, Perl doesn't provide any special syntax for
+constructors. A constructor is merely a subroutine that returns a
+reference to something "blessed" into a class, generally the
+class that the subroutine is defined in. Here is a typical
+constructor:
+
+ package Critter;
+ sub new { bless {} }
+
+That word C<new> isn't special. You could have written
+a construct this way, too:
+
+ package Critter;
+ sub spawn { bless {} }
+
+In fact, this might even be preferable, because the C++ programmers won't
+be tricked into thinking that C<new> works in Perl as it does in C++.
+It doesn't. We recommend that you name your constructors whatever
+makes sense in the context of the problem you're solving. For example,
+constructors in the Tk extension to Perl are named after the widgets
+they create.
+
+One thing that's different about Perl constructors compared with those in
+C++ is that in Perl, they have to allocate their own memory. (The other
+things is that they don't automatically call overridden base-class
+constructors.) The C<{}> allocates an anonymous hash containing no
+key/value pairs, and returns it The bless() takes that reference and
+tells the object it references that it's now a Critter, and returns
+the reference. This is for convenience, because the referenced object
+itself knows that it has been blessed, and the reference to it could
+have been returned directly, like this:
+
+ sub new {
+ my $self = {};
+ bless $self;
+ return $self;
+ }
+
+In fact, you often see such a thing in more complicated constructors
+that wish to call methods in the class as part of the construction:
+
+ sub new {
+ my $self = {};
+ bless $self;
+ $self->initialize();
+ return $self;
+ }
+
+If you care about inheritance (and you should; see
+L<perlmod/"Modules: Creation, Use, and Abuse">),
+then you want to use the two-arg form of bless
+so that your constructors may be inherited:
+
+ sub new {
+ my $class = shift;
+ my $self = {};
+ bless $self, $class;
+ $self->initialize();
+ return $self;
+ }
+
+Or if you expect people to call not just C<CLASS-E<gt>new()> but also
+C<$obj-E<gt>new()>, then use something like this. The initialize()
+method used will be of whatever $class we blessed the
+object into:
+
+ sub new {
+ my $this = shift;
+ my $class = ref($this) || $this;
+ my $self = {};
+ bless $self, $class;
+ $self->initialize();
+ return $self;
+ }
+
+Within the class package, the methods will typically deal with the
+reference as an ordinary reference. Outside the class package,
+the reference is generally treated as an opaque value that may
+be accessed only through the class's methods.
+
+A constructor may re-bless a referenced object currently belonging to
+another class, but then the new class is responsible for all cleanup
+later. The previous blessing is forgotten, as an object may belong
+to only one class at a time. (Although of course it's free to
+inherit methods from many classes.) If you find yourself having to
+do this, the parent class is probably misbehaving, though.
+
+A clarification: Perl objects are blessed. References are not. Objects
+know which package they belong to. References do not. The bless()
+function uses the reference to find the object. Consider
+the following example:
+
+ $a = {};
+ $b = $a;
+ bless $a, BLAH;
+ print "\$b is a ", ref($b), "\n";
+
+This reports $b as being a BLAH, so obviously bless()
+operated on the object and not on the reference.
+
+=head2 A Class is Simply a Package
+
+Unlike say C++, Perl doesn't provide any special syntax for class
+definitions. You use a package as a class by putting method
+definitions into the class.
+
+There is a special array within each package called @ISA, which says
+where else to look for a method if you can't find it in the current
+package. This is how Perl implements inheritance. Each element of the
+@ISA array is just the name of another package that happens to be a
+class package. The classes are searched (depth first) for missing
+methods in the order that they occur in @ISA. The classes accessible
+through @ISA are known as base classes of the current class.
+
+All classes implicitly inherit from class C<UNIVERSAL> as their
+last base class. Several commonly used methods are automatically
+supplied in the UNIVERSAL class; see L<"Default UNIVERSAL methods"> for
+more details.
+
+If a missing method is found in one of the base classes, it is cached
+in the current class for efficiency. Changing @ISA or defining new
+subroutines invalidates the cache and causes Perl to do the lookup again.
+
+If neither the current class, its named base classes, nor the UNIVERSAL
+class contains the requested method, these three places are searched
+all over again, this time looking for a method named AUTOLOAD(). If an
+AUTOLOAD is found, this method is called on behalf of the missing method,
+setting the package global $AUTOLOAD to be the fully qualified name of
+the method that was intended to be called.
+
+If none of that works, Perl finally gives up and complains.
+
+Perl classes do method inheritance only. Data inheritance is left up
+to the class itself. By and large, this is not a problem in Perl,
+because most classes model the attributes of their object using an
+anonymous hash, which serves as its own little namespace to be carved up
+by the various classes that might want to do something with the object.
+The only problem with this is that you can't sure that you aren't using
+a piece of the hash that isn't already used. A reasonable workaround
+is to prepend your fieldname in the hash with the package name.
+
+ sub bump {
+ my $self = shift;
+ $self->{ __PACKAGE__ . ".count"}++;
+ }
+
+=head2 A Method is Simply a Subroutine
+
+Unlike say C++, Perl doesn't provide any special syntax for method
+definition. (It does provide a little syntax for method invocation
+though. More on that later.) A method expects its first argument
+to be the object (reference) or package (string) it is being invoked on. There are just two
+types of methods, which we'll call class and instance.
+(Sometimes you'll hear these called static and virtual, in honor of
+the two C++ method types they most closely resemble.)
+
+A class method expects a class name as the first argument. It
+provides functionality for the class as a whole, not for any individual
+object belonging to the class. Constructors are typically class
+methods. Many class methods simply ignore their first argument, because
+they already know what package they're in, and don't care what package
+they were invoked via. (These aren't necessarily the same, because
+class methods follow the inheritance tree just like ordinary instance
+methods.) Another typical use for class methods is to look up an
+object by name:
+
+ sub find {
+ my ($class, $name) = @_;
+ $objtable{$name};
+ }
+
+An instance method expects an object reference as its first argument.
+Typically it shifts the first argument into a "self" or "this" variable,
+and then uses that as an ordinary reference.
+
+ sub display {
+ my $self = shift;
+ my @keys = @_ ? @_ : sort keys %$self;
+ foreach $key (@keys) {
+ print "\t$key => $self->{$key}\n";
+ }
+ }
+
+=head2 Method Invocation
+
+There are two ways to invoke a method, one of which you're already
+familiar with, and the other of which will look familiar. Perl 4
+already had an "indirect object" syntax that you use when you say
+
+ print STDERR "help!!!\n";
+
+This same syntax can be used to call either class or instance methods.
+We'll use the two methods defined above, the class method to lookup
+an object reference and the instance method to print out its attributes.
+
+ $fred = find Critter "Fred";
+ display $fred 'Height', 'Weight';
+
+These could be combined into one statement by using a BLOCK in the
+indirect object slot:
+
+ display {find Critter "Fred"} 'Height', 'Weight';
+
+For C++ fans, there's also a syntax using -E<gt> notation that does exactly
+the same thing. The parentheses are required if there are any arguments.
+
+ $fred = Critter->find("Fred");
+ $fred->display('Height', 'Weight');
+
+or in one statement,
+
+ Critter->find("Fred")->display('Height', 'Weight');
+
+There are times when one syntax is more readable, and times when the
+other syntax is more readable. The indirect object syntax is less
+cluttered, but it has the same ambiguity as ordinary list operators.
+Indirect object method calls are parsed using the same rule as list
+operators: "If it looks like a function, it is a function". (Presuming
+for the moment that you think two words in a row can look like a
+function name. C++ programmers seem to think so with some regularity,
+especially when the first word is "new".) Thus, the parentheses of
+
+ new Critter ('Barney', 1.5, 70)
+
+are assumed to surround ALL the arguments of the method call, regardless
+of what comes after. Saying
+
+ new Critter ('Bam' x 2), 1.4, 45
+
+would be equivalent to
+
+ Critter->new('Bam' x 2), 1.4, 45
+
+which is unlikely to do what you want.
+
+There are times when you wish to specify which class's method to use.
+In this case, you can call your method as an ordinary subroutine
+call, being sure to pass the requisite first argument explicitly:
+
+ $fred = MyCritter::find("Critter", "Fred");
+ MyCritter::display($fred, 'Height', 'Weight');
+
+Note however, that this does not do any inheritance. If you wish
+merely to specify that Perl should I<START> looking for a method in a
+particular package, use an ordinary method call, but qualify the method
+name with the package like this:
+
+ $fred = Critter->MyCritter::find("Fred");
+ $fred->MyCritter::display('Height', 'Weight');
+
+If you're trying to control where the method search begins I<and> you're
+executing in the class itself, then you may use the SUPER pseudo class,
+which says to start looking in your base class's @ISA list without having
+to name it explicitly:
+
+ $self->SUPER::display('Height', 'Weight');
+
+Please note that the C<SUPER::> construct is meaningful I<only> within the
+class.
+
+Sometimes you want to call a method when you don't know the method name
+ahead of time. You can use the arrow form, replacing the method name
+with a simple scalar variable containing the method name:
+
+ $method = $fast ? "findfirst" : "findbest";
+ $fred->$method(@args);
+
+=head2 Default UNIVERSAL methods
+
+The C<UNIVERSAL> package automatically contains the following methods that
+are inherited by all other classes:
+
+=over 4
+
+=item isa(CLASS)
+
+C<isa> returns I<true> if its object is blessed into a subclass of C<CLASS>
+
+C<isa> is also exportable and can be called as a sub with two arguments. This
+allows the ability to check what a reference points to. Example
+
+ use UNIVERSAL qw(isa);
+
+ if(isa($ref, 'ARRAY')) {
+ #...
+ }
+
+=item can(METHOD)
+
+C<can> checks to see if its object has a method called C<METHOD>,
+if it does then a reference to the sub is returned, if it does not then
+I<undef> is returned.
+
+=item VERSION( [NEED] )
+
+C<VERSION> returns the version number of the class (package). If the
+NEED argument is given then it will check that the current version (as
+defined by the $VERSION variable in the given package) not less than
+NEED; it will die if this is not the case. This method is normally
+called as a class method. This method is called automatically by the
+C<VERSION> form of C<use>.
+
+ use A 1.2 qw(some imported subs);
+ # implies:
+ A->VERSION(1.2);
+
+=back
+
+B<NOTE:> C<can> directly uses Perl's internal code for method lookup, and
+C<isa> uses a very similar method and cache-ing strategy. This may cause
+strange effects if the Perl code dynamically changes @ISA in any package.
+
+You may add other methods to the UNIVERSAL class via Perl or XS code.
+You do not need to C<use UNIVERSAL> in order to make these methods
+available to your program. This is necessary only if you wish to
+have C<isa> available as a plain subroutine in the current package.
+
+=head2 Destructors
+
+When the last reference to an object goes away, the object is
+automatically destroyed. (This may even be after you exit, if you've
+stored references in global variables.) If you want to capture control
+just before the object is freed, you may define a DESTROY method in
+your class. It will automatically be called at the appropriate moment,
+and you can do any extra cleanup you need to do. Perl passes a reference
+to the object under destruction as the first (and only) argument. Beware
+that the reference is a read-only value, and cannot be modified by
+manipulating C<$_[0]> within the destructor. The object itself (i.e.
+the thingy the reference points to, namely C<${$_[0]}>, C<@{$_[0]}>,
+C<%{$_[0]}> etc.) is not similarly constrained.
+
+If you arrange to re-bless the reference before the destructor returns,
+perl will again call the DESTROY method for the re-blessed object after
+the current one returns. This can be used for clean delegation of
+object destruction, or for ensuring that destructors in the base classes
+of your choosing get called. Explicitly calling DESTROY is also possible,
+but is usually never needed.
+
+Do not confuse the foregoing with how objects I<CONTAINED> in the current
+one are destroyed. Such objects will be freed and destroyed automatically
+when the current object is freed, provided no other references to them exist
+elsewhere.
+
+=head2 WARNING
+
+While indirect object syntax may well be appealing to English speakers and
+to C++ programmers, be not seduced! It suffers from two grave problems.
+
+The first problem is that an indirect object is limited to a name,
+a scalar variable, or a block, because it would have to do too much
+lookahead otherwise, just like any other postfix dereference in the
+language. (These are the same quirky rules as are used for the filehandle
+slot in functions like C<print> and C<printf>.) This can lead to horribly
+confusing precedence problems, as in these next two lines:
+
+ move $obj->{FIELD}; # probably wrong!
+ move $ary[$i]; # probably wrong!
+
+Those actually parse as the very surprising:
+
+ $obj->move->{FIELD}; # Well, lookee here
+ $ary->move->[$i]; # Didn't expect this one, eh?
+
+Rather than what you might have expected:
+
+ $obj->{FIELD}->move(); # You should be so lucky.
+ $ary[$i]->move; # Yeah, sure.
+
+The left side of ``-E<gt>'' is not so limited, because it's an infix operator,
+not a postfix operator.
+
+As if that weren't bad enough, think about this: Perl must guess I<at
+compile time> whether C<name> and C<move> above are functions or methods.
+Usually Perl gets it right, but when it doesn't it, you get a function
+call compiled as a method, or vice versa. This can introduce subtle
+bugs that are hard to unravel. For example, calling a method C<new>
+in indirect notation--as C++ programmers are so wont to do--can
+be miscompiled into a subroutine call if there's already a C<new>
+function in scope. You'd end up calling the current package's C<new>
+as a subroutine, rather than the desired class's method. The compiler
+tries to cheat by remembering bareword C<require>s, but the grief if it
+messes up just isn't worth the years of debugging it would likely take
+you to to track such subtle bugs down.
+
+The infix arrow notation using ``C<-E<gt>>'' doesn't suffer from either
+of these disturbing ambiguities, so we recommend you use it exclusively.
+
+=head2 Summary
+
+That's about all there is to it. Now you need just to go off and buy a
+book about object-oriented design methodology, and bang your forehead
+with it for the next six months or so.
+
+=head2 Two-Phased Garbage Collection
+
+For most purposes, Perl uses a fast and simple reference-based
+garbage collection system. For this reason, there's an extra
+dereference going on at some level, so if you haven't built
+your Perl executable using your C compiler's C<-O> flag, performance
+will suffer. If you I<have> built Perl with C<cc -O>, then this
+probably won't matter.
+
+A more serious concern is that unreachable memory with a non-zero
+reference count will not normally get freed. Therefore, this is a bad
+idea:
+
+ {
+ my $a;
+ $a = \$a;
+ }
+
+Even thought $a I<should> go away, it can't. When building recursive data
+structures, you'll have to break the self-reference yourself explicitly
+if you don't care to leak. For example, here's a self-referential
+node such as one might use in a sophisticated tree structure:
+
+ sub new_node {
+ my $self = shift;
+ my $class = ref($self) || $self;
+ my $node = {};
+ $node->{LEFT} = $node->{RIGHT} = $node;
+ $node->{DATA} = [ @_ ];
+ return bless $node => $class;
+ }
+
+If you create nodes like that, they (currently) won't go away unless you
+break their self reference yourself. (In other words, this is not to be
+construed as a feature, and you shouldn't depend on it.)
+
+Almost.
+
+When an interpreter thread finally shuts down (usually when your program
+exits), then a rather costly but complete mark-and-sweep style of garbage
+collection is performed, and everything allocated by that thread gets
+destroyed. This is essential to support Perl as an embedded or a
+multithreadable language. For example, this program demonstrates Perl's
+two-phased garbage collection:
+
+ #!/usr/bin/perl
+ package Subtle;
+
+ sub new {
+ my $test;
+ $test = \$test;
+ warn "CREATING " . \$test;
+ return bless \$test;
+ }
+
+ sub DESTROY {
+ my $self = shift;
+ warn "DESTROYING $self";
+ }
+
+ package main;
+
+ warn "starting program";
+ {
+ my $a = Subtle->new;
+ my $b = Subtle->new;
+ $$a = 0; # break selfref
+ warn "leaving block";
+ }
+
+ warn "just exited block";
+ warn "time to die...";
+ exit;
+
+When run as F</tmp/test>, the following output is produced:
+
+ starting program at /tmp/test line 18.
+ CREATING SCALAR(0x8e5b8) at /tmp/test line 7.
+ CREATING SCALAR(0x8e57c) at /tmp/test line 7.
+ leaving block at /tmp/test line 23.
+ DESTROYING Subtle=SCALAR(0x8e5b8) at /tmp/test line 13.
+ just exited block at /tmp/test line 26.
+ time to die... at /tmp/test line 27.
+ DESTROYING Subtle=SCALAR(0x8e57c) during global destruction.
+
+Notice that "global destruction" bit there? That's the thread
+garbage collector reaching the unreachable.
+
+Objects are always destructed, even when regular refs aren't and in fact
+are destructed in a separate pass before ordinary refs just to try to
+prevent object destructors from using refs that have been themselves
+destructed. Plain refs are only garbage-collected if the destruct level
+is greater than 0. You can test the higher levels of global destruction
+by setting the PERL_DESTRUCT_LEVEL environment variable, presuming
+C<-DDEBUGGING> was enabled during perl build time.
+
+A more complete garbage collection strategy will be implemented
+at a future date.
+
+In the meantime, the best solution is to create a non-recursive container
+class that holds a pointer to the self-referential data structure.
+Define a DESTROY method for the containing object's class that manually
+breaks the circularities in the self-referential structure.
+
+=head1 SEE ALSO
+
+A kinder, gentler tutorial on object-oriented programming in Perl can
+be found in L<perltoot>.
+You should also check out L<perlbot> for other object tricks, traps, and tips,
+as well as L<perlmodlib> for some style guides on constructing both modules
+and classes.
diff --git a/contrib/perl5/pod/perlop.pod b/contrib/perl5/pod/perlop.pod
new file mode 100644
index 0000000..c7209fa
--- /dev/null
+++ b/contrib/perl5/pod/perlop.pod
@@ -0,0 +1,1724 @@
+=head1 NAME
+
+perlop - Perl operators and precedence
+
+=head1 SYNOPSIS
+
+Perl operators have the following associativity and precedence,
+listed from highest precedence to lowest. Note that all operators
+borrowed from C keep the same precedence relationship with each other,
+even where C's precedence is slightly screwy. (This makes learning
+Perl easier for C folks.) With very few exceptions, these all
+operate on scalar values only, not array values.
+
+ left terms and list operators (leftward)
+ left ->
+ nonassoc ++ --
+ right **
+ right ! ~ \ and unary + and -
+ left =~ !~
+ left * / % x
+ left + - .
+ left << >>
+ nonassoc named unary operators
+ nonassoc < > <= >= lt gt le ge
+ nonassoc == != <=> eq ne cmp
+ left &
+ left | ^
+ left &&
+ left ||
+ nonassoc .. ...
+ right ?:
+ right = += -= *= etc.
+ left , =>
+ nonassoc list operators (rightward)
+ right not
+ left and
+ left or xor
+
+In the following sections, these operators are covered in precedence order.
+
+Many operators can be overloaded for objects. See L<overload>.
+
+=head1 DESCRIPTION
+
+=head2 Terms and List Operators (Leftward)
+
+A TERM has the highest precedence in Perl. They includes variables,
+quote and quote-like operators, any expression in parentheses,
+and any function whose arguments are parenthesized. Actually, there
+aren't really functions in this sense, just list operators and unary
+operators behaving as functions because you put parentheses around
+the arguments. These are all documented in L<perlfunc>.
+
+If any list operator (print(), etc.) or any unary operator (chdir(), etc.)
+is followed by a left parenthesis as the next token, the operator and
+arguments within parentheses are taken to be of highest precedence,
+just like a normal function call.
+
+In the absence of parentheses, the precedence of list operators such as
+C<print>, C<sort>, or C<chmod> is either very high or very low depending on
+whether you are looking at the left side or the right side of the operator.
+For example, in
+
+ @ary = (1, 3, sort 4, 2);
+ print @ary; # prints 1324
+
+the commas on the right of the sort are evaluated before the sort, but
+the commas on the left are evaluated after. In other words, list
+operators tend to gobble up all the arguments that follow them, and
+then act like a simple TERM with regard to the preceding expression.
+Note that you have to be careful with parentheses:
+
+ # These evaluate exit before doing the print:
+ print($foo, exit); # Obviously not what you want.
+ print $foo, exit; # Nor is this.
+
+ # These do the print before evaluating exit:
+ (print $foo), exit; # This is what you want.
+ print($foo), exit; # Or this.
+ print ($foo), exit; # Or even this.
+
+Also note that
+
+ print ($foo & 255) + 1, "\n";
+
+probably doesn't do what you expect at first glance. See
+L<Named Unary Operators> for more discussion of this.
+
+Also parsed as terms are the C<do {}> and C<eval {}> constructs, as
+well as subroutine and method calls, and the anonymous
+constructors C<[]> and C<{}>.
+
+See also L<Quote and Quote-like Operators> toward the end of this section,
+as well as L<"I/O Operators">.
+
+=head2 The Arrow Operator
+
+Just as in C and C++, "C<-E<gt>>" is an infix dereference operator. If the
+right side is either a C<[...]> or C<{...}> subscript, then the left side
+must be either a hard or symbolic reference to an array or hash (or
+a location capable of holding a hard reference, if it's an lvalue (assignable)).
+See L<perlref>.
+
+Otherwise, the right side is a method name or a simple scalar variable
+containing the method name, and the left side must either be an object
+(a blessed reference) or a class name (that is, a package name).
+See L<perlobj>.
+
+=head2 Auto-increment and Auto-decrement
+
+"++" and "--" work as in C. That is, if placed before a variable, they
+increment or decrement the variable before returning the value, and if
+placed after, increment or decrement the variable after returning the value.
+
+The auto-increment operator has a little extra builtin magic to it. If
+you increment a variable that is numeric, or that has ever been used in
+a numeric context, you get a normal increment. If, however, the
+variable has been used in only string contexts since it was set, and
+has a value that is not the empty string and matches the pattern
+C</^[a-zA-Z]*[0-9]*$/>, the increment is done as a string, preserving each
+character within its range, with carry:
+
+ print ++($foo = '99'); # prints '100'
+ print ++($foo = 'a0'); # prints 'a1'
+ print ++($foo = 'Az'); # prints 'Ba'
+ print ++($foo = 'zz'); # prints 'aaa'
+
+The auto-decrement operator is not magical.
+
+=head2 Exponentiation
+
+Binary "**" is the exponentiation operator. Note that it binds even more
+tightly than unary minus, so -2**4 is -(2**4), not (-2)**4. (This is
+implemented using C's pow(3) function, which actually works on doubles
+internally.)
+
+=head2 Symbolic Unary Operators
+
+Unary "!" performs logical negation, i.e., "not". See also C<not> for a lower
+precedence version of this.
+
+Unary "-" performs arithmetic negation if the operand is numeric. If
+the operand is an identifier, a string consisting of a minus sign
+concatenated with the identifier is returned. Otherwise, if the string
+starts with a plus or minus, a string starting with the opposite sign
+is returned. One effect of these rules is that C<-bareword> is equivalent
+to C<"-bareword">.
+
+Unary "~" performs bitwise negation, i.e., 1's complement. For example,
+C<0666 &~ 027> is 0640. (See also L<Integer Arithmetic> and L<Bitwise
+String Operators>.)
+
+Unary "+" has no effect whatsoever, even on strings. It is useful
+syntactically for separating a function name from a parenthesized expression
+that would otherwise be interpreted as the complete list of function
+arguments. (See examples above under L<Terms and List Operators (Leftward)>.)
+
+Unary "\" creates a reference to whatever follows it. See L<perlref>.
+Do not confuse this behavior with the behavior of backslash within a
+string, although both forms do convey the notion of protecting the next
+thing from interpretation.
+
+=head2 Binding Operators
+
+Binary "=~" binds a scalar expression to a pattern match. Certain operations
+search or modify the string $_ by default. This operator makes that kind
+of operation work on some other string. The right argument is a search
+pattern, substitution, or transliteration. The left argument is what is
+supposed to be searched, substituted, or transliterated instead of the default
+$_. The return value indicates the success of the operation. (If the
+right argument is an expression rather than a search pattern,
+substitution, or transliteration, it is interpreted as a search pattern at run
+time. This can be is less efficient than an explicit search, because the
+pattern must be compiled every time the expression is evaluated.
+
+Binary "!~" is just like "=~" except the return value is negated in
+the logical sense.
+
+=head2 Multiplicative Operators
+
+Binary "*" multiplies two numbers.
+
+Binary "/" divides two numbers.
+
+Binary "%" computes the modulus of two numbers. Given integer
+operands C<$a> and C<$b>: If C<$b> is positive, then C<$a % $b> is
+C<$a> minus the largest multiple of C<$b> that is not greater than
+C<$a>. If C<$b> is negative, then C<$a % $b> is C<$a> minus the
+smallest multiple of C<$b> that is not less than C<$a> (i.e. the
+result will be less than or equal to zero).
+Note than when C<use integer> is in scope, "%" give you direct access
+to the modulus operator as implemented by your C compiler. This
+operator is not as well defined for negative operands, but it will
+execute faster.
+
+Binary "x" is the repetition operator. In scalar context, it
+returns a string consisting of the left operand repeated the number of
+times specified by the right operand. In list context, if the left
+operand is a list in parentheses, it repeats the list.
+
+ print '-' x 80; # print row of dashes
+
+ print "\t" x ($tab/8), ' ' x ($tab%8); # tab over
+
+ @ones = (1) x 80; # a list of 80 1's
+ @ones = (5) x @ones; # set all elements to 5
+
+
+=head2 Additive Operators
+
+Binary "+" returns the sum of two numbers.
+
+Binary "-" returns the difference of two numbers.
+
+Binary "." concatenates two strings.
+
+=head2 Shift Operators
+
+Binary "<<" returns the value of its left argument shifted left by the
+number of bits specified by the right argument. Arguments should be
+integers. (See also L<Integer Arithmetic>.)
+
+Binary ">>" returns the value of its left argument shifted right by
+the number of bits specified by the right argument. Arguments should
+be integers. (See also L<Integer Arithmetic>.)
+
+=head2 Named Unary Operators
+
+The various named unary operators are treated as functions with one
+argument, with optional parentheses. These include the filetest
+operators, like C<-f>, C<-M>, etc. See L<perlfunc>.
+
+If any list operator (print(), etc.) or any unary operator (chdir(), etc.)
+is followed by a left parenthesis as the next token, the operator and
+arguments within parentheses are taken to be of highest precedence,
+just like a normal function call. Examples:
+
+ chdir $foo || die; # (chdir $foo) || die
+ chdir($foo) || die; # (chdir $foo) || die
+ chdir ($foo) || die; # (chdir $foo) || die
+ chdir +($foo) || die; # (chdir $foo) || die
+
+but, because * is higher precedence than ||:
+
+ chdir $foo * 20; # chdir ($foo * 20)
+ chdir($foo) * 20; # (chdir $foo) * 20
+ chdir ($foo) * 20; # (chdir $foo) * 20
+ chdir +($foo) * 20; # chdir ($foo * 20)
+
+ rand 10 * 20; # rand (10 * 20)
+ rand(10) * 20; # (rand 10) * 20
+ rand (10) * 20; # (rand 10) * 20
+ rand +(10) * 20; # rand (10 * 20)
+
+See also L<"Terms and List Operators (Leftward)">.
+
+=head2 Relational Operators
+
+Binary "E<lt>" returns true if the left argument is numerically less than
+the right argument.
+
+Binary "E<gt>" returns true if the left argument is numerically greater
+than the right argument.
+
+Binary "E<lt>=" returns true if the left argument is numerically less than
+or equal to the right argument.
+
+Binary "E<gt>=" returns true if the left argument is numerically greater
+than or equal to the right argument.
+
+Binary "lt" returns true if the left argument is stringwise less than
+the right argument.
+
+Binary "gt" returns true if the left argument is stringwise greater
+than the right argument.
+
+Binary "le" returns true if the left argument is stringwise less than
+or equal to the right argument.
+
+Binary "ge" returns true if the left argument is stringwise greater
+than or equal to the right argument.
+
+=head2 Equality Operators
+
+Binary "==" returns true if the left argument is numerically equal to
+the right argument.
+
+Binary "!=" returns true if the left argument is numerically not equal
+to the right argument.
+
+Binary "E<lt>=E<gt>" returns -1, 0, or 1 depending on whether the left
+argument is numerically less than, equal to, or greater than the right
+argument.
+
+Binary "eq" returns true if the left argument is stringwise equal to
+the right argument.
+
+Binary "ne" returns true if the left argument is stringwise not equal
+to the right argument.
+
+Binary "cmp" returns -1, 0, or 1 depending on whether the left argument is stringwise
+less than, equal to, or greater than the right argument.
+
+"lt", "le", "ge", "gt" and "cmp" use the collation (sort) order specified
+by the current locale if C<use locale> is in effect. See L<perllocale>.
+
+=head2 Bitwise And
+
+Binary "&" returns its operators ANDed together bit by bit.
+(See also L<Integer Arithmetic> and L<Bitwise String Operators>.)
+
+=head2 Bitwise Or and Exclusive Or
+
+Binary "|" returns its operators ORed together bit by bit.
+(See also L<Integer Arithmetic> and L<Bitwise String Operators>.)
+
+Binary "^" returns its operators XORed together bit by bit.
+(See also L<Integer Arithmetic> and L<Bitwise String Operators>.)
+
+=head2 C-style Logical And
+
+Binary "&&" performs a short-circuit logical AND operation. That is,
+if the left operand is false, the right operand is not even evaluated.
+Scalar or list context propagates down to the right operand if it
+is evaluated.
+
+=head2 C-style Logical Or
+
+Binary "||" performs a short-circuit logical OR operation. That is,
+if the left operand is true, the right operand is not even evaluated.
+Scalar or list context propagates down to the right operand if it
+is evaluated.
+
+The C<||> and C<&&> operators differ from C's in that, rather than returning
+0 or 1, they return the last value evaluated. Thus, a reasonably portable
+way to find out the home directory (assuming it's not "0") might be:
+
+ $home = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
+ (getpwuid($<))[7] || die "You're homeless!\n";
+
+In particular, this means that you shouldn't use this
+for selecting between two aggregates for assignment:
+
+ @a = @b || @c; # this is wrong
+ @a = scalar(@b) || @c; # really meant this
+ @a = @b ? @b : @c; # this works fine, though
+
+As more readable alternatives to C<&&> and C<||> when used for
+control flow, Perl provides C<and> and C<or> operators (see below).
+The short-circuit behavior is identical. The precedence of "and" and
+"or" is much lower, however, so that you can safely use them after a
+list operator without the need for parentheses:
+
+ unlink "alpha", "beta", "gamma"
+ or gripe(), next LINE;
+
+With the C-style operators that would have been written like this:
+
+ unlink("alpha", "beta", "gamma")
+ || (gripe(), next LINE);
+
+Use "or" for assignment is unlikely to do what you want; see below.
+
+=head2 Range Operators
+
+Binary ".." is the range operator, which is really two different
+operators depending on the context. In list context, it returns an
+array of values counting (by ones) from the left value to the right
+value. This is useful for writing C<foreach (1..10)> loops and for
+doing slice operations on arrays. In the current implementation, no
+temporary array is created when the range operator is used as the
+expression in C<foreach> loops, but older versions of Perl might burn
+a lot of memory when you write something like this:
+
+ for (1 .. 1_000_000) {
+ # code
+ }
+
+In scalar context, ".." returns a boolean value. The operator is
+bistable, like a flip-flop, and emulates the line-range (comma) operator
+of B<sed>, B<awk>, and various editors. Each ".." operator maintains its
+own boolean state. It is false as long as its left operand is false.
+Once the left operand is true, the range operator stays true until the
+right operand is true, I<AFTER> which the range operator becomes false
+again. (It doesn't become false till the next time the range operator is
+evaluated. It can test the right operand and become false on the same
+evaluation it became true (as in B<awk>), but it still returns true once.
+If you don't want it to test the right operand till the next evaluation
+(as in B<sed>), use three dots ("...") instead of two.) The right
+operand is not evaluated while the operator is in the "false" state, and
+the left operand is not evaluated while the operator is in the "true"
+state. The precedence is a little lower than || and &&. The value
+returned is either the empty string for false, or a sequence number
+(beginning with 1) for true. The sequence number is reset for each range
+encountered. The final sequence number in a range has the string "E0"
+appended to it, which doesn't affect its numeric value, but gives you
+something to search for if you want to exclude the endpoint. You can
+exclude the beginning point by waiting for the sequence number to be
+greater than 1. If either operand of scalar ".." is a constant expression,
+that operand is implicitly compared to the C<$.> variable, the current
+line number. Examples:
+
+As a scalar operator:
+
+ if (101 .. 200) { print; } # print 2nd hundred lines
+ next line if (1 .. /^$/); # skip header lines
+ s/^/> / if (/^$/ .. eof()); # quote body
+
+ # parse mail messages
+ while (<>) {
+ $in_header = 1 .. /^$/;
+ $in_body = /^$/ .. eof();
+ # do something based on those
+ } continue {
+ close ARGV if eof; # reset $. each file
+ }
+
+As a list operator:
+
+ for (101 .. 200) { print; } # print $_ 100 times
+ @foo = @foo[0 .. $#foo]; # an expensive no-op
+ @foo = @foo[$#foo-4 .. $#foo]; # slice last 5 items
+
+The range operator (in list context) makes use of the magical
+auto-increment algorithm if the operands are strings. You
+can say
+
+ @alphabet = ('A' .. 'Z');
+
+to get all the letters of the alphabet, or
+
+ $hexdigit = (0 .. 9, 'a' .. 'f')[$num & 15];
+
+to get a hexadecimal digit, or
+
+ @z2 = ('01' .. '31'); print $z2[$mday];
+
+to get dates with leading zeros. If the final value specified is not
+in the sequence that the magical increment would produce, the sequence
+goes until the next value would be longer than the final value
+specified.
+
+=head2 Conditional Operator
+
+Ternary "?:" is the conditional operator, just as in C. It works much
+like an if-then-else. If the argument before the ? is true, the
+argument before the : is returned, otherwise the argument after the :
+is returned. For example:
+
+ printf "I have %d dog%s.\n", $n,
+ ($n == 1) ? '' : "s";
+
+Scalar or list context propagates downward into the 2nd
+or 3rd argument, whichever is selected.
+
+ $a = $ok ? $b : $c; # get a scalar
+ @a = $ok ? @b : @c; # get an array
+ $a = $ok ? @b : @c; # oops, that's just a count!
+
+The operator may be assigned to if both the 2nd and 3rd arguments are
+legal lvalues (meaning that you can assign to them):
+
+ ($a_or_b ? $a : $b) = $c;
+
+This is not necessarily guaranteed to contribute to the readability of your program.
+
+Because this operator produces an assignable result, using assignments
+without parentheses will get you in trouble. For example, this:
+
+ $a % 2 ? $a += 10 : $a += 2
+
+Really means this:
+
+ (($a % 2) ? ($a += 10) : $a) += 2
+
+Rather than this:
+
+ ($a % 2) ? ($a += 10) : ($a += 2)
+
+=head2 Assignment Operators
+
+"=" is the ordinary assignment operator.
+
+Assignment operators work as in C. That is,
+
+ $a += 2;
+
+is equivalent to
+
+ $a = $a + 2;
+
+although without duplicating any side effects that dereferencing the lvalue
+might trigger, such as from tie(). Other assignment operators work similarly.
+The following are recognized:
+
+ **= += *= &= <<= &&=
+ -= /= |= >>= ||=
+ .= %= ^=
+ x=
+
+Note that while these are grouped by family, they all have the precedence
+of assignment.
+
+Unlike in C, the assignment operator produces a valid lvalue. Modifying
+an assignment is equivalent to doing the assignment and then modifying
+the variable that was assigned to. This is useful for modifying
+a copy of something, like this:
+
+ ($tmp = $global) =~ tr [A-Z] [a-z];
+
+Likewise,
+
+ ($a += 2) *= 3;
+
+is equivalent to
+
+ $a += 2;
+ $a *= 3;
+
+=head2 Comma Operator
+
+Binary "," is the comma operator. In scalar context it evaluates
+its left argument, throws that value away, then evaluates its right
+argument and returns that value. This is just like C's comma operator.
+
+In list context, it's just the list argument separator, and inserts
+both its arguments into the list.
+
+The =E<gt> digraph is mostly just a synonym for the comma operator. It's useful for
+documenting arguments that come in pairs. As of release 5.001, it also forces
+any word to the left of it to be interpreted as a string.
+
+=head2 List Operators (Rightward)
+
+On the right side of a list operator, it has very low precedence,
+such that it controls all comma-separated expressions found there.
+The only operators with lower precedence are the logical operators
+"and", "or", and "not", which may be used to evaluate calls to list
+operators without the need for extra parentheses:
+
+ open HANDLE, "filename"
+ or die "Can't open: $!\n";
+
+See also discussion of list operators in L<Terms and List Operators (Leftward)>.
+
+=head2 Logical Not
+
+Unary "not" returns the logical negation of the expression to its right.
+It's the equivalent of "!" except for the very low precedence.
+
+=head2 Logical And
+
+Binary "and" returns the logical conjunction of the two surrounding
+expressions. It's equivalent to && except for the very low
+precedence. This means that it short-circuits: i.e., the right
+expression is evaluated only if the left expression is true.
+
+=head2 Logical or and Exclusive Or
+
+Binary "or" returns the logical disjunction of the two surrounding
+expressions. It's equivalent to || except for the very low precedence.
+This makes it useful for control flow
+
+ print FH $data or die "Can't write to FH: $!";
+
+This means that it short-circuits: i.e., the right expression is evaluated
+only if the left expression is false. Due to its precedence, you should
+probably avoid using this for assignment, only for control flow.
+
+ $a = $b or $c; # bug: this is wrong
+ ($a = $b) or $c; # really means this
+ $a = $b || $c; # better written this way
+
+However, when it's a list context assignment and you're trying to use
+"||" for control flow, you probably need "or" so that the assignment
+takes higher precedence.
+
+ @info = stat($file) || die; # oops, scalar sense of stat!
+ @info = stat($file) or die; # better, now @info gets its due
+
+Then again, you could always use parentheses.
+
+Binary "xor" returns the exclusive-OR of the two surrounding expressions.
+It cannot short circuit, of course.
+
+=head2 C Operators Missing From Perl
+
+Here is what C has that Perl doesn't:
+
+=over 8
+
+=item unary &
+
+Address-of operator. (But see the "\" operator for taking a reference.)
+
+=item unary *
+
+Dereference-address operator. (Perl's prefix dereferencing
+operators are typed: $, @, %, and &.)
+
+=item (TYPE)
+
+Type casting operator.
+
+=back
+
+=head2 Quote and Quote-like Operators
+
+While we usually think of quotes as literal values, in Perl they
+function as operators, providing various kinds of interpolating and
+pattern matching capabilities. Perl provides customary quote characters
+for these behaviors, but also provides a way for you to choose your
+quote character for any of them. In the following table, a C<{}> represents
+any pair of delimiters you choose. Non-bracketing delimiters use
+the same character fore and aft, but the 4 sorts of brackets
+(round, angle, square, curly) will all nest.
+
+ Customary Generic Meaning Interpolates
+ '' q{} Literal no
+ "" qq{} Literal yes
+ `` qx{} Command yes (unless '' is delimiter)
+ qw{} Word list no
+ // m{} Pattern match yes
+ qr{} Pattern yes
+ s{}{} Substitution yes
+ tr{}{} Transliteration no (but see below)
+
+Note that there can be whitespace between the operator and the quoting
+characters, except when C<#> is being used as the quoting character.
+C<q#foo#> is parsed as being the string C<foo>, while C<q #foo#> is the
+operator C<q> followed by a comment. Its argument will be taken from the
+next line. This allows you to write:
+
+ s {foo} # Replace foo
+ {bar} # with bar.
+
+For constructs that do interpolation, variables beginning with "C<$>"
+or "C<@>" are interpolated, as are the following sequences. Within
+a transliteration, the first ten of these sequences may be used.
+
+ \t tab (HT, TAB)
+ \n newline (NL)
+ \r return (CR)
+ \f form feed (FF)
+ \b backspace (BS)
+ \a alarm (bell) (BEL)
+ \e escape (ESC)
+ \033 octal char
+ \x1b hex char
+ \c[ control char
+
+ \l lowercase next char
+ \u uppercase next char
+ \L lowercase till \E
+ \U uppercase till \E
+ \E end case modification
+ \Q quote non-word characters till \E
+
+If C<use locale> is in effect, the case map used by C<\l>, C<\L>, C<\u>
+and C<\U> is taken from the current locale. See L<perllocale>.
+
+All systems use the virtual C<"\n"> to represent a line terminator,
+called a "newline". There is no such thing as an unvarying, physical
+newline character. It is an illusion that the operating system,
+device drivers, C libraries, and Perl all conspire to preserve. Not all
+systems read C<"\r"> as ASCII CR and C<"\n"> as ASCII LF. For example,
+on a Mac, these are reversed, and on systems without line terminator,
+printing C<"\n"> may emit no actual data. In general, use C<"\n"> when
+you mean a "newline" for your system, but use the literal ASCII when you
+need an exact character. For example, most networking protocols expect
+and prefer a CR+LF (C<"\012\015"> or C<"\cJ\cM">) for line terminators,
+and although they often accept just C<"\012">, they seldom tolerate just
+C<"\015">. If you get in the habit of using C<"\n"> for networking,
+you may be burned some day.
+
+You cannot include a literal C<$> or C<@> within a C<\Q> sequence.
+An unescaped C<$> or C<@> interpolates the corresponding variable,
+while escaping will cause the literal string C<\$> to be inserted.
+You'll need to write something like C<m/\Quser\E\@\Qhost/>.
+
+Patterns are subject to an additional level of interpretation as a
+regular expression. This is done as a second pass, after variables are
+interpolated, so that regular expressions may be incorporated into the
+pattern from the variables. If this is not what you want, use C<\Q> to
+interpolate a variable literally.
+
+Apart from the above, there are no multiple levels of interpolation. In
+particular, contrary to the expectations of shell programmers, back-quotes
+do I<NOT> interpolate within double quotes, nor do single quotes impede
+evaluation of variables when used within double quotes.
+
+=head2 Regexp Quote-Like Operators
+
+Here are the quote-like operators that apply to pattern
+matching and related activities.
+
+Most of this section is related to use of regular expressions from Perl.
+Such a use may be considered from two points of view: Perl handles a
+a string and a "pattern" to RE (regular expression) engine to match,
+RE engine finds (or does not find) the match, and Perl uses the findings
+of RE engine for its operation, possibly asking the engine for other matches.
+
+RE engine has no idea what Perl is going to do with what it finds,
+similarly, the rest of Perl has no idea what a particular regular expression
+means to RE engine. This creates a clean separation, and in this section
+we discuss matching from Perl point of view only. The other point of
+view may be found in L<perlre>.
+
+=over 8
+
+=item ?PATTERN?
+
+This is just like the C</pattern/> search, except that it matches only
+once between calls to the reset() operator. This is a useful
+optimization when you want to see only the first occurrence of
+something in each file of a set of files, for instance. Only C<??>
+patterns local to the current package are reset.
+
+ while (<>) {
+ if (?^$?) {
+ # blank line between header and body
+ }
+ } continue {
+ reset if eof; # clear ?? status for next file
+ }
+
+This usage is vaguely deprecated, and may be removed in some future
+version of Perl.
+
+=item m/PATTERN/cgimosx
+
+=item /PATTERN/cgimosx
+
+Searches a string for a pattern match, and in scalar context returns
+true (1) or false (''). If no string is specified via the C<=~> or
+C<!~> operator, the $_ string is searched. (The string specified with
+C<=~> need not be an lvalue--it may be the result of an expression
+evaluation, but remember the C<=~> binds rather tightly.) See also
+L<perlre>.
+See L<perllocale> for discussion of additional considerations that apply
+when C<use locale> is in effect.
+
+Options are:
+
+ c Do not reset search position on a failed match when /g is in effect.
+ g Match globally, i.e., find all occurrences.
+ i Do case-insensitive pattern matching.
+ m Treat string as multiple lines.
+ o Compile pattern only once.
+ s Treat string as single line.
+ x Use extended regular expressions.
+
+If "/" is the delimiter then the initial C<m> is optional. With the C<m>
+you can use any pair of non-alphanumeric, non-whitespace characters
+as delimiters (if single quotes are used, no interpretation is done
+on the replacement string. Unlike Perl 4, Perl 5 treats backticks as normal
+delimiters; the replacement text is not evaluated as a command).
+This is particularly useful for matching Unix path names
+that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is
+the delimiter, then the match-only-once rule of C<?PATTERN?> applies.
+
+PATTERN may contain variables, which will be interpolated (and the
+pattern recompiled) every time the pattern search is evaluated. (Note
+that C<$)> and C<$|> might not be interpolated because they look like
+end-of-string tests.) If you want such a pattern to be compiled only
+once, add a C</o> after the trailing delimiter. This avoids expensive
+run-time recompilations, and is useful when the value you are
+interpolating won't change over the life of the script. However, mentioning
+C</o> constitutes a promise that you won't change the variables in the pattern.
+If you change them, Perl won't even notice.
+
+If the PATTERN evaluates to the empty string, the last
+I<successfully> matched regular expression is used instead.
+
+If the C</g> option is not used, C<m//> in a list context returns a
+list consisting of the subexpressions matched by the parentheses in the
+pattern, i.e., (C<$1>, C<$2>, C<$3>...). (Note that here C<$1> etc. are
+also set, and that this differs from Perl 4's behavior.) When there are
+no parentheses in the pattern, the return value is the list C<(1)> for
+success. With or without parentheses, an empty list is returned upon
+failure.
+
+Examples:
+
+ open(TTY, '/dev/tty');
+ <TTY> =~ /^y/i && foo(); # do foo if desired
+
+ if (/Version: *([0-9.]*)/) { $version = $1; }
+
+ next if m#^/usr/spool/uucp#;
+
+ # poor man's grep
+ $arg = shift;
+ while (<>) {
+ print if /$arg/o; # compile only once
+ }
+
+ if (($F1, $F2, $Etc) = ($foo =~ /^(\S+)\s+(\S+)\s*(.*)/))
+
+This last example splits $foo into the first two words and the
+remainder of the line, and assigns those three fields to $F1, $F2, and
+$Etc. The conditional is true if any variables were assigned, i.e., if
+the pattern matched.
+
+The C</g> modifier specifies global pattern matching--that is, matching
+as many times as possible within the string. How it behaves depends on
+the context. In list context, it returns a list of all the
+substrings matched by all the parentheses in the regular expression.
+If there are no parentheses, it returns a list of all the matched
+strings, as if there were parentheses around the whole pattern.
+
+In scalar context, each execution of C<m//g> finds the next match,
+returning TRUE if it matches, and FALSE if there is no further match.
+The position after the last match can be read or set using the pos()
+function; see L<perlfunc/pos>. A failed match normally resets the
+search position to the beginning of the string, but you can avoid that
+by adding the C</c> modifier (e.g. C<m//gc>). Modifying the target
+string also resets the search position.
+
+You can intermix C<m//g> matches with C<m/\G.../g>, where C<\G> is a
+zero-width assertion that matches the exact position where the previous
+C<m//g>, if any, left off. The C<\G> assertion is not supported without
+the C</g> modifier; currently, without C</g>, C<\G> behaves just like
+C<\A>, but that's accidental and may change in the future.
+
+Examples:
+
+ # list context
+ ($one,$five,$fifteen) = (`uptime` =~ /(\d+\.\d+)/g);
+
+ # scalar context
+ $/ = ""; $* = 1; # $* deprecated in modern perls
+ while (defined($paragraph = <>)) {
+ while ($paragraph =~ /[a-z]['")]*[.!?]+['")]*\s/g) {
+ $sentences++;
+ }
+ }
+ print "$sentences\n";
+
+ # using m//gc with \G
+ $_ = "ppooqppqq";
+ while ($i++ < 2) {
+ print "1: '";
+ print $1 while /(o)/gc; print "', pos=", pos, "\n";
+ print "2: '";
+ print $1 if /\G(q)/gc; print "', pos=", pos, "\n";
+ print "3: '";
+ print $1 while /(p)/gc; print "', pos=", pos, "\n";
+ }
+
+The last example should print:
+
+ 1: 'oo', pos=4
+ 2: 'q', pos=5
+ 3: 'pp', pos=7
+ 1: '', pos=7
+ 2: 'q', pos=8
+ 3: '', pos=8
+
+A useful idiom for C<lex>-like scanners is C</\G.../gc>. You can
+combine several regexps like this to process a string part-by-part,
+doing different actions depending on which regexp matched. Each
+regexp tries to match where the previous one leaves off.
+
+ $_ = <<'EOL';
+ $url = new URI::URL "http://www/"; die if $url eq "xXx";
+ EOL
+ LOOP:
+ {
+ print(" digits"), redo LOOP if /\G\d+\b[,.;]?\s*/gc;
+ print(" lowercase"), redo LOOP if /\G[a-z]+\b[,.;]?\s*/gc;
+ print(" UPPERCASE"), redo LOOP if /\G[A-Z]+\b[,.;]?\s*/gc;
+ print(" Capitalized"), redo LOOP if /\G[A-Z][a-z]+\b[,.;]?\s*/gc;
+ print(" MiXeD"), redo LOOP if /\G[A-Za-z]+\b[,.;]?\s*/gc;
+ print(" alphanumeric"), redo LOOP if /\G[A-Za-z0-9]+\b[,.;]?\s*/gc;
+ print(" line-noise"), redo LOOP if /\G[^A-Za-z0-9]+/gc;
+ print ". That's all!\n";
+ }
+
+Here is the output (split into several lines):
+
+ line-noise lowercase line-noise lowercase UPPERCASE line-noise
+ UPPERCASE line-noise lowercase line-noise lowercase line-noise
+ lowercase lowercase line-noise lowercase lowercase line-noise
+ MiXeD line-noise. That's all!
+
+=item q/STRING/
+
+=item C<'STRING'>
+
+A single-quoted, literal string. A backslash represents a backslash
+unless followed by the delimiter or another backslash, in which case
+the delimiter or backslash is interpolated.
+
+ $foo = q!I said, "You said, 'She said it.'"!;
+ $bar = q('This is it.');
+ $baz = '\n'; # a two-character string
+
+=item qq/STRING/
+
+=item "STRING"
+
+A double-quoted, interpolated string.
+
+ $_ .= qq
+ (*** The previous line contains the naughty word "$1".\n)
+ if /(tcl|rexx|python)/; # :-)
+ $baz = "\n"; # a one-character string
+
+=item qr/STRING/imosx
+
+A string which is (possibly) interpolated and then compiled as a
+regular expression. The result may be used as a pattern in a match
+
+ $re = qr/$pattern/;
+ $string =~ /foo${re}bar/; # can be interpolated in other patterns
+ $string =~ $re; # or used standalone
+
+Options are:
+
+ i Do case-insensitive pattern matching.
+ m Treat string as multiple lines.
+ o Compile pattern only once.
+ s Treat string as single line.
+ x Use extended regular expressions.
+
+The benefit from this is that the pattern is precompiled into an internal
+representation, and does not need to be recompiled every time a match
+is attempted. This makes it very efficient to do something like:
+
+ foreach $pattern (@pattern_list) {
+ my $re = qr/$pattern/;
+ foreach $line (@lines) {
+ if($line =~ /$re/) {
+ do_something($line);
+ }
+ }
+ }
+
+See L<perlre> for additional information on valid syntax for STRING, and
+for a detailed look at the semantics of regular expressions.
+
+=item qx/STRING/
+
+=item `STRING`
+
+A string which is (possibly) interpolated and then executed as a system
+command with C</bin/sh> or its equivalent. Shell wildcards, pipes,
+and redirections will be honored. The collected standard output of the
+command is returned; standard error is unaffected. In scalar context,
+it comes back as a single (potentially multi-line) string. In list
+context, returns a list of lines (however you've defined lines with $/
+or $INPUT_RECORD_SEPARATOR).
+
+Because backticks do not affect standard error, use shell file descriptor
+syntax (assuming the shell supports this) if you care to address this.
+To capture a command's STDERR and STDOUT together:
+
+ $output = `cmd 2>&1`;
+
+To capture a command's STDOUT but discard its STDERR:
+
+ $output = `cmd 2>/dev/null`;
+
+To capture a command's STDERR but discard its STDOUT (ordering is
+important here):
+
+ $output = `cmd 2>&1 1>/dev/null`;
+
+To exchange a command's STDOUT and STDERR in order to capture the STDERR
+but leave its STDOUT to come out the old STDERR:
+
+ $output = `cmd 3>&1 1>&2 2>&3 3>&-`;
+
+To read both a command's STDOUT and its STDERR separately, it's easiest
+and safest to redirect them separately to files, and then read from those
+files when the program is done:
+
+ system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
+
+Using single-quote as a delimiter protects the command from Perl's
+double-quote interpolation, passing it on to the shell instead:
+
+ $perl_info = qx(ps $$); # that's Perl's $$
+ $shell_info = qx'ps $$'; # that's the new shell's $$
+
+Note that how the string gets evaluated is entirely subject to the command
+interpreter on your system. On most platforms, you will have to protect
+shell metacharacters if you want them treated literally. This is in
+practice difficult to do, as it's unclear how to escape which characters.
+See L<perlsec> for a clean and safe example of a manual fork() and exec()
+to emulate backticks safely.
+
+On some platforms (notably DOS-like ones), the shell may not be
+capable of dealing with multiline commands, so putting newlines in
+the string may not get you what you want. You may be able to evaluate
+multiple commands in a single line by separating them with the command
+separator character, if your shell supports that (e.g. C<;> on many Unix
+shells; C<&> on the Windows NT C<cmd> shell).
+
+Beware that some command shells may place restrictions on the length
+of the command line. You must ensure your strings don't exceed this
+limit after any necessary interpolations. See the platform-specific
+release notes for more details about your particular environment.
+
+Using this operator can lead to programs that are difficult to port,
+because the shell commands called vary between systems, and may in
+fact not be present at all. As one example, the C<type> command under
+the POSIX shell is very different from the C<type> command under DOS.
+That doesn't mean you should go out of your way to avoid backticks
+when they're the right way to get something done. Perl was made to be
+a glue language, and one of the things it glues together is commands.
+Just understand what you're getting yourself into.
+
+See L<"I/O Operators"> for more discussion.
+
+=item qw/STRING/
+
+Returns a list of the words extracted out of STRING, using embedded
+whitespace as the word delimiters. It is exactly equivalent to
+
+ split(' ', q/STRING/);
+
+This equivalency means that if used in scalar context, you'll get split's
+(unfortunate) scalar context behavior, complete with mysterious warnings.
+
+Some frequently seen examples:
+
+ use POSIX qw( setlocale localeconv )
+ @EXPORT = qw( foo bar baz );
+
+A common mistake is to try to separate the words with comma or to put
+comments into a multi-line C<qw>-string. For this reason the C<-w>
+switch produce warnings if the STRING contains the "," or the "#"
+character.
+
+=item s/PATTERN/REPLACEMENT/egimosx
+
+Searches a string for a pattern, and if found, replaces that pattern
+with the replacement text and returns the number of substitutions
+made. Otherwise it returns false (specifically, the empty string).
+
+If no string is specified via the C<=~> or C<!~> operator, the C<$_>
+variable is searched and modified. (The string specified with C<=~> must
+be scalar variable, an array element, a hash element, or an assignment
+to one of those, i.e., an lvalue.)
+
+If the delimiter chosen is single quote, no variable interpolation is
+done on either the PATTERN or the REPLACEMENT. Otherwise, if the
+PATTERN contains a $ that looks like a variable rather than an
+end-of-string test, the variable will be interpolated into the pattern
+at run-time. If you want the pattern compiled only once the first time
+the variable is interpolated, use the C</o> option. If the pattern
+evaluates to the empty string, the last successfully executed regular
+expression is used instead. See L<perlre> for further explanation on these.
+See L<perllocale> for discussion of additional considerations that apply
+when C<use locale> is in effect.
+
+Options are:
+
+ e Evaluate the right side as an expression.
+ g Replace globally, i.e., all occurrences.
+ i Do case-insensitive pattern matching.
+ m Treat string as multiple lines.
+ o Compile pattern only once.
+ s Treat string as single line.
+ x Use extended regular expressions.
+
+Any non-alphanumeric, non-whitespace delimiter may replace the
+slashes. If single quotes are used, no interpretation is done on the
+replacement string (the C</e> modifier overrides this, however). Unlike
+Perl 4, Perl 5 treats backticks as normal delimiters; the replacement
+text is not evaluated as a command. If the
+PATTERN is delimited by bracketing quotes, the REPLACEMENT has its own
+pair of quotes, which may or may not be bracketing quotes, e.g.,
+C<s(foo)(bar)> or C<sE<lt>fooE<gt>/bar/>. A C</e> will cause the
+replacement portion to be interpreted as a full-fledged Perl expression
+and eval()ed right then and there. It is, however, syntax checked at
+compile-time.
+
+Examples:
+
+ s/\bgreen\b/mauve/g; # don't change wintergreen
+
+ $path =~ s|/usr/bin|/usr/local/bin|;
+
+ s/Login: $foo/Login: $bar/; # run-time pattern
+
+ ($foo = $bar) =~ s/this/that/; # copy first, then change
+
+ $count = ($paragraph =~ s/Mister\b/Mr./g); # get change-count
+
+ $_ = 'abc123xyz';
+ s/\d+/$&*2/e; # yields 'abc246xyz'
+ s/\d+/sprintf("%5d",$&)/e; # yields 'abc 246xyz'
+ s/\w/$& x 2/eg; # yields 'aabbcc 224466xxyyzz'
+
+ s/%(.)/$percent{$1}/g; # change percent escapes; no /e
+ s/%(.)/$percent{$1} || $&/ge; # expr now, so /e
+ s/^=(\w+)/&pod($1)/ge; # use function call
+
+ # expand variables in $_, but dynamics only, using
+ # symbolic dereferencing
+ s/\$(\w+)/${$1}/g;
+
+ # /e's can even nest; this will expand
+ # any embedded scalar variable (including lexicals) in $_
+ s/(\$\w+)/$1/eeg;
+
+ # Delete (most) C comments.
+ $program =~ s {
+ /\* # Match the opening delimiter.
+ .*? # Match a minimal number of characters.
+ \*/ # Match the closing delimiter.
+ } []gsx;
+
+ s/^\s*(.*?)\s*$/$1/; # trim white space in $_, expensively
+
+ for ($variable) { # trim white space in $variable, cheap
+ s/^\s+//;
+ s/\s+$//;
+ }
+
+ s/([^ ]*) *([^ ]*)/$2 $1/; # reverse 1st two fields
+
+Note the use of $ instead of \ in the last example. Unlike
+B<sed>, we use the \E<lt>I<digit>E<gt> form in only the left hand side.
+Anywhere else it's $E<lt>I<digit>E<gt>.
+
+Occasionally, you can't use just a C</g> to get all the changes
+to occur. Here are two common cases:
+
+ # put commas in the right places in an integer
+ 1 while s/(.*\d)(\d\d\d)/$1,$2/g; # perl4
+ 1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/g; # perl5
+
+ # expand tabs to 8-column spacing
+ 1 while s/\t+/' ' x (length($&)*8 - length($`)%8)/e;
+
+
+=item tr/SEARCHLIST/REPLACEMENTLIST/cds
+
+=item y/SEARCHLIST/REPLACEMENTLIST/cds
+
+Transliterates all occurrences of the characters found in the search list
+with the corresponding character in the replacement list. It returns
+the number of characters replaced or deleted. If no string is
+specified via the =~ or !~ operator, the $_ string is transliterated. (The
+string specified with =~ must be a scalar variable, an array element, a
+hash element, or an assignment to one of those, i.e., an lvalue.)
+A character range may be specified with a hyphen, so C<tr/A-J/0-9/>
+does the same replacement as C<tr/ACEGIBDFHJ/0246813579/>.
+For B<sed> devotees, C<y> is provided as a synonym for C<tr>. If the
+SEARCHLIST is delimited by bracketing quotes, the REPLACEMENTLIST has
+its own pair of quotes, which may or may not be bracketing quotes,
+e.g., C<tr[A-Z][a-z]> or C<tr(+\-*/)/ABCD/>.
+
+Options:
+
+ c Complement the SEARCHLIST.
+ d Delete found but unreplaced characters.
+ s Squash duplicate replaced characters.
+
+If the C</c> modifier is specified, the SEARCHLIST character set is
+complemented. If the C</d> modifier is specified, any characters specified
+by SEARCHLIST not found in REPLACEMENTLIST are deleted. (Note
+that this is slightly more flexible than the behavior of some B<tr>
+programs, which delete anything they find in the SEARCHLIST, period.)
+If the C</s> modifier is specified, sequences of characters that were
+transliterated to the same character are squashed down to a single instance of the
+character.
+
+If the C</d> modifier is used, the REPLACEMENTLIST is always interpreted
+exactly as specified. Otherwise, if the REPLACEMENTLIST is shorter
+than the SEARCHLIST, the final character is replicated till it is long
+enough. If the REPLACEMENTLIST is empty, the SEARCHLIST is replicated.
+This latter is useful for counting characters in a class or for
+squashing character sequences in a class.
+
+Examples:
+
+ $ARGV[1] =~ tr/A-Z/a-z/; # canonicalize to lower case
+
+ $cnt = tr/*/*/; # count the stars in $_
+
+ $cnt = $sky =~ tr/*/*/; # count the stars in $sky
+
+ $cnt = tr/0-9//; # count the digits in $_
+
+ tr/a-zA-Z//s; # bookkeeper -> bokeper
+
+ ($HOST = $host) =~ tr/a-z/A-Z/;
+
+ tr/a-zA-Z/ /cs; # change non-alphas to single space
+
+ tr [\200-\377]
+ [\000-\177]; # delete 8th bit
+
+If multiple transliterations are given for a character, only the first one is used:
+
+ tr/AAA/XYZ/
+
+will transliterate any A to X.
+
+Note that because the transliteration table is built at compile time, neither
+the SEARCHLIST nor the REPLACEMENTLIST are subjected to double quote
+interpolation. That means that if you want to use variables, you must use
+an eval():
+
+ eval "tr/$oldlist/$newlist/";
+ die $@ if $@;
+
+ eval "tr/$oldlist/$newlist/, 1" or die $@;
+
+=back
+
+=head2 Gory details of parsing quoted constructs
+
+When presented with something which may have several different
+interpretations, Perl uses the principle B<DWIM> (expanded to Do What I Mean
+- not what I wrote) to pick up the most probable interpretation of the
+source. This strategy is so successful that Perl users usually do not
+suspect ambivalence of what they write. However, time to time Perl's ideas
+differ from what the author meant.
+
+The target of this section is to clarify the Perl's way of interpreting
+quoted constructs. The most frequent reason one may have to want to know the
+details discussed in this section is hairy regular expressions. However, the
+first steps of parsing are the same for all Perl quoting operators, so here
+they are discussed together.
+
+Some of the passes discussed below are performed concurrently, but as
+far as results are the same, we consider them one-by-one. For different
+quoting constructs Perl performs different number of passes, from
+one to five, but they are always performed in the same order.
+
+=over
+
+=item Finding the end
+
+First pass is finding the end of the quoted construct, be it multichar ender
+C<"\nEOF\n"> of C<<<EOF> construct, C</> which terminates C<qq/> construct,
+C<]> which terminates C<qq[> construct, or C<E<gt>> which terminates a
+fileglob started with C<<>.
+
+When searching for multichar construct no skipping is performed. When
+searching for one-char non-matching delimiter, such as C</>, combinations
+C<\\> and C<\/> are skipped. When searching for one-char matching delimiter,
+such as C<]>, combinations C<\\>, C<\]> and C<\[> are skipped, and
+nested C<[>, C<]> are skipped as well.
+
+For 3-parts constructs, C<s///> etc. the search is repeated once more.
+
+During this search no attention is paid to the semantic of the construct, thus
+
+ "$hash{"$foo/$bar"}"
+
+or
+
+ m/
+ bar # This is not a comment, this slash / terminated m//!
+ /x
+
+do not form legal quoted expressions. Note that since the slash which
+terminated C<m//> was followed by a C<SPACE>, this is not C<m//x>,
+thus C<#> was interpreted as a literal C<#>.
+
+=item Removal of backslashes before delimiters
+
+During the second pass the text between the starting delimiter and
+the ending delimiter is copied to a safe location, and the C<\> is
+removed from combinations consisting of C<\> and delimiter(s) (both starting
+and ending delimiter if they differ).
+
+The removal does not happen for multi-char delimiters.
+
+Note that the combination C<\\> is left as it was!
+
+Starting from this step no information about the delimiter(s) is used in the
+parsing.
+
+=item Interpolation
+
+Next step is interpolation in the obtained delimiter-independent text.
+There are four different cases.
+
+=over
+
+=item C<<<'EOF'>, C<m''>, C<s'''>, C<tr///>, C<y///>
+
+No interpolation is performed.
+
+=item C<''>, C<q//>
+
+The only interpolation is removal of C<\> from pairs C<\\>.
+
+=item C<"">, C<``>, C<qq//>, C<qx//>, C<<file*globE<gt>>
+
+C<\Q>, C<\U>, C<\u>, C<\L>, C<\l> (possibly paired with C<\E>) are converted
+to corresponding Perl constructs, thus C<"$foo\Qbaz$bar"> is converted to
+
+ $foo . (quotemeta("baz" . $bar));
+
+Other combinations of C<\> with following chars are substituted with
+appropriate expansions.
+
+Interpolated scalars and arrays are converted to C<join> and C<.> Perl
+constructs, thus C<"'@arr'"> becomes
+
+ "'" . (join $", @arr) . "'";
+
+Since all three above steps are performed simultaneously left-to-right,
+the is no way to insert a literal C<$> or C<@> inside C<\Q\E> pair: it
+cannot be protected by C<\>, since any C<\> (except in C<\E>) is
+interpreted as a literal inside C<\Q\E>, and any C<$> is
+interpreted as starting an interpolated scalar.
+
+Note also that the interpolating code needs to make decision where the
+interpolated scalar ends, say, whether C<"a $b -E<gt> {c}"> means
+
+ "a " . $b . " -> {c}";
+
+or
+
+ "a " . $b -> {c};
+
+Most the time the decision is to take the longest possible text which does
+not include spaces between components and contains matching braces/brackets.
+
+=item C<?RE?>, C</RE/>, C<m/RE/>, C<s/RE/foo/>,
+
+Processing of C<\Q>, C<\U>, C<\u>, C<\L>, C<\l> and interpolation happens
+(almost) as with C<qq//> constructs, but I<the substitution of C<\> followed by
+other chars is not performed>! Moreover, inside C<(?{BLOCK})> no processing
+is performed at all.
+
+Interpolation has several quirks: C<$|>, C<$(> and C<$)> are not interpolated, and
+constructs C<$var[SOMETHING]> are I<voted> (by several different estimators)
+to be an array element or C<$var> followed by a RE alternative. This is
+the place where the notation C<${arr[$bar]}> comes handy: C</${arr[0-9]}/>
+is interpreted as an array element C<-9>, not as a regular expression from
+variable C<$arr> followed by a digit, which is the interpretation of
+C</$arr[0-9]/>.
+
+Note that absence of processing of C<\\> creates specific restrictions on the
+post-processed text: if the delimiter is C</>, one cannot get the combination
+C<\/> into the result of this step: C</> will finish the regular expression,
+C<\/> will be stripped to C</> on the previous step, and C<\\/> will be left
+as is. Since C</> is equivalent to C<\/> inside a regular expression, this
+does not matter unless the delimiter is special character for the RE engine, as
+in C<s*foo*bar*>, C<m[foo]>, or C<?foo?>.
+
+=back
+
+This step is the last one for all the constructs except regular expressions,
+which are processed further.
+
+=item Interpolation of regular expressions
+
+All the previous steps were performed during the compilation of Perl code,
+this one happens in run time (though it may be optimized to be calculated
+at compile time if appropriate). After all the preprocessing performed
+above (and possibly after evaluation if catenation, joining, up/down-casing
+and C<quotemeta()>ing are involved) the resulting I<string> is passed to RE
+engine for compilation.
+
+Whatever happens in the RE engine is better be discussed in L<perlre>,
+but for the sake of continuity let us do it here.
+
+This is the first step where presence of the C<//x> switch is relevant.
+The RE engine scans the string left-to-right, and converts it to a finite
+automaton.
+
+Backslashed chars are either substituted by corresponding literal
+strings, or generate special nodes of the finite automaton. Characters
+which are special to the RE engine generate corresponding nodes. C<(?#...)>
+comments are ignored. All the rest is either converted to literal strings
+to match, or is ignored (as is whitespace and C<#>-style comments if
+C<//x> is present).
+
+Note that the parsing of the construct C<[...]> is performed using
+absolutely different rules than the rest of the regular expression.
+Similarly, the C<(?{...})> is only checked for matching braces.
+
+=item Optimization of regular expressions
+
+This step is listed for completeness only. Since it does not change
+semantics, details of this step are not documented and are subject
+to change.
+
+=back
+
+=head2 I/O Operators
+
+There are several I/O operators you should know about.
+A string enclosed by backticks (grave accents) first undergoes
+variable substitution just like a double quoted string. It is then
+interpreted as a command, and the output of that command is the value
+of the pseudo-literal, like in a shell. In scalar context, a single
+string consisting of all the output is returned. In list context,
+a list of values is returned, one for each line of output. (You can
+set C<$/> to use a different line terminator.) The command is executed
+each time the pseudo-literal is evaluated. The status value of the
+command is returned in C<$?> (see L<perlvar> for the interpretation
+of C<$?>). Unlike in B<csh>, no translation is done on the return
+data--newlines remain newlines. Unlike in any of the shells, single
+quotes do not hide variable names in the command from interpretation.
+To pass a $ through to the shell you need to hide it with a backslash.
+The generalized form of backticks is C<qx//>. (Because backticks
+always undergo shell expansion as well, see L<perlsec> for
+security concerns.)
+
+Evaluating a filehandle in angle brackets yields the next line from
+that file (newline, if any, included), or C<undef> at end of file.
+Ordinarily you must assign that value to a variable, but there is one
+situation where an automatic assignment happens. I<If and ONLY if> the
+input symbol is the only thing inside the conditional of a C<while> or
+C<for(;;)> loop, the value is automatically assigned to the variable
+C<$_>. In these loop constructs, the assigned value (whether assignment
+is automatic or explicit) is then tested to see if it is defined.
+The defined test avoids problems where line has a string value
+that would be treated as false by perl e.g. "" or "0" with no trailing
+newline. (This may seem like an odd thing to you, but you'll use the
+construct in almost every Perl script you write.) Anyway, the following
+lines are equivalent to each other:
+
+ while (defined($_ = <STDIN>)) { print; }
+ while ($_ = <STDIN>) { print; }
+ while (<STDIN>) { print; }
+ for (;<STDIN>;) { print; }
+ print while defined($_ = <STDIN>);
+ print while ($_ = <STDIN>);
+ print while <STDIN>;
+
+and this also behaves similarly, but avoids the use of $_ :
+
+ while (my $line = <STDIN>) { print $line }
+
+If you really mean such values to terminate the loop they should be
+tested for explicitly:
+
+ while (($_ = <STDIN>) ne '0') { ... }
+ while (<STDIN>) { last unless $_; ... }
+
+In other boolean contexts, C<E<lt>I<filehandle>E<gt>> without explicit C<defined>
+test or comparison will solicit a warning if C<-w> is in effect.
+
+The filehandles STDIN, STDOUT, and STDERR are predefined. (The
+filehandles C<stdin>, C<stdout>, and C<stderr> will also work except in
+packages, where they would be interpreted as local identifiers rather
+than global.) Additional filehandles may be created with the open()
+function. See L<perlfunc/open()> for details on this.
+
+If a E<lt>FILEHANDLEE<gt> is used in a context that is looking for a list, a
+list consisting of all the input lines is returned, one line per list
+element. It's easy to make a I<LARGE> data space this way, so use with
+care.
+
+The null filehandle E<lt>E<gt> is special and can be used to emulate the
+behavior of B<sed> and B<awk>. Input from E<lt>E<gt> comes either from
+standard input, or from each file listed on the command line. Here's
+how it works: the first time E<lt>E<gt> is evaluated, the @ARGV array is
+checked, and if it is empty, C<$ARGV[0]> is set to "-", which when opened
+gives you standard input. The @ARGV array is then processed as a list
+of filenames. The loop
+
+ while (<>) {
+ ... # code for each line
+ }
+
+is equivalent to the following Perl-like pseudo code:
+
+ unshift(@ARGV, '-') unless @ARGV;
+ while ($ARGV = shift) {
+ open(ARGV, $ARGV);
+ while (<ARGV>) {
+ ... # code for each line
+ }
+ }
+
+except that it isn't so cumbersome to say, and will actually work. It
+really does shift array @ARGV and put the current filename into variable
+$ARGV. It also uses filehandle I<ARGV> internally--E<lt>E<gt> is just a
+synonym for E<lt>ARGVE<gt>, which is magical. (The pseudo code above
+doesn't work because it treats E<lt>ARGVE<gt> as non-magical.)
+
+You can modify @ARGV before the first E<lt>E<gt> as long as the array ends up
+containing the list of filenames you really want. Line numbers (C<$.>)
+continue as if the input were one big happy file. (But see example
+under C<eof> for how to reset line numbers on each file.)
+
+If you want to set @ARGV to your own list of files, go right ahead.
+This sets @ARGV to all plain text files if no @ARGV was given:
+
+ @ARGV = grep { -f && -T } glob('*') unless @ARGV;
+
+You can even set them to pipe commands. For example, this automatically
+filters compressed arguments through B<gzip>:
+
+ @ARGV = map { /\.(gz|Z)$/ ? "gzip -dc < $_ |" : $_ } @ARGV;
+
+If you want to pass switches into your script, you can use one of the
+Getopts modules or put a loop on the front like this:
+
+ while ($_ = $ARGV[0], /^-/) {
+ shift;
+ last if /^--$/;
+ if (/^-D(.*)/) { $debug = $1 }
+ if (/^-v/) { $verbose++ }
+ # ... # other switches
+ }
+
+ while (<>) {
+ # ... # code for each line
+ }
+
+The E<lt>E<gt> symbol will return C<undef> for end-of-file only once.
+If you call it again after this it will assume you are processing another
+@ARGV list, and if you haven't set @ARGV, will input from STDIN.
+
+If the string inside the angle brackets is a reference to a scalar
+variable (e.g., E<lt>$fooE<gt>), then that variable contains the name of the
+filehandle to input from, or its typeglob, or a reference to the same. For example:
+
+ $fh = \*STDIN;
+ $line = <$fh>;
+
+If what's within the angle brackets is neither a filehandle nor a simple
+scalar variable containing a filehandle name, typeglob, or typeglob
+reference, it is interpreted as a filename pattern to be globbed, and
+either a list of filenames or the next filename in the list is returned,
+depending on context. This distinction is determined on syntactic
+grounds alone. That means C<E<lt>$xE<gt>> is always a readline from
+an indirect handle, but C<E<lt>$hash{key}E<gt>> is always a glob.
+That's because $x is a simple scalar variable, but C<$hash{key}> is
+not--it's a hash element.
+
+One level of double-quote interpretation is done first, but you can't
+say C<E<lt>$fooE<gt>> because that's an indirect filehandle as explained
+in the previous paragraph. (In older versions of Perl, programmers
+would insert curly brackets to force interpretation as a filename glob:
+C<E<lt>${foo}E<gt>>. These days, it's considered cleaner to call the
+internal function directly as C<glob($foo)>, which is probably the right
+way to have done it in the first place.) Example:
+
+ while (<*.c>) {
+ chmod 0644, $_;
+ }
+
+is equivalent to
+
+ open(FOO, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
+ while (<FOO>) {
+ chop;
+ chmod 0644, $_;
+ }
+
+In fact, it's currently implemented that way. (Which means it will not
+work on filenames with spaces in them unless you have csh(1) on your
+machine.) Of course, the shortest way to do the above is:
+
+ chmod 0644, <*.c>;
+
+Because globbing invokes a shell, it's often faster to call readdir() yourself
+and do your own grep() on the filenames. Furthermore, due to its current
+implementation of using a shell, the glob() routine may get "Arg list too
+long" errors (unless you've installed tcsh(1L) as F</bin/csh>).
+
+A glob evaluates its (embedded) argument only when it is starting a new
+list. All values must be read before it will start over. In a list
+context this isn't important, because you automatically get them all
+anyway. In scalar context, however, the operator returns the next value
+each time it is called, or a C<undef> value if you've just run out. As
+for filehandles an automatic C<defined> is generated when the glob
+occurs in the test part of a C<while> or C<for> - because legal glob returns
+(e.g. a file called F<0>) would otherwise terminate the loop.
+Again, C<undef> is returned only once. So if you're expecting a single value
+from a glob, it is much better to say
+
+ ($file) = <blurch*>;
+
+than
+
+ $file = <blurch*>;
+
+because the latter will alternate between returning a filename and
+returning FALSE.
+
+It you're trying to do variable interpolation, it's definitely better
+to use the glob() function, because the older notation can cause people
+to become confused with the indirect filehandle notation.
+
+ @files = glob("$dir/*.[ch]");
+ @files = glob($files[$i]);
+
+=head2 Constant Folding
+
+Like C, Perl does a certain amount of expression evaluation at
+compile time, whenever it determines that all arguments to an
+operator are static and have no side effects. In particular, string
+concatenation happens at compile time between literals that don't do
+variable substitution. Backslash interpretation also happens at
+compile time. You can say
+
+ 'Now is the time for all' . "\n" .
+ 'good men to come to.'
+
+and this all reduces to one string internally. Likewise, if
+you say
+
+ foreach $file (@filenames) {
+ if (-s $file > 5 + 100 * 2**16) { }
+ }
+
+the compiler will precompute the number that
+expression represents so that the interpreter
+won't have to.
+
+=head2 Bitwise String Operators
+
+Bitstrings of any size may be manipulated by the bitwise operators
+(C<~ | & ^>).
+
+If the operands to a binary bitwise op are strings of different sizes,
+B<or> and B<xor> ops will act as if the shorter operand had additional
+zero bits on the right, while the B<and> op will act as if the longer
+operand were truncated to the length of the shorter.
+
+ # ASCII-based examples
+ print "j p \n" ^ " a h"; # prints "JAPH\n"
+ print "JA" | " ph\n"; # prints "japh\n"
+ print "japh\nJunk" & '_____'; # prints "JAPH\n";
+ print 'p N$' ^ " E<H\n"; # prints "Perl\n";
+
+If you are intending to manipulate bitstrings, you should be certain that
+you're supplying bitstrings: If an operand is a number, that will imply
+a B<numeric> bitwise operation. You may explicitly show which type of
+operation you intend by using C<""> or C<0+>, as in the examples below.
+
+ $foo = 150 | 105 ; # yields 255 (0x96 | 0x69 is 0xFF)
+ $foo = '150' | 105 ; # yields 255
+ $foo = 150 | '105'; # yields 255
+ $foo = '150' | '105'; # yields string '155' (under ASCII)
+
+ $baz = 0+$foo & 0+$bar; # both ops explicitly numeric
+ $biz = "$foo" ^ "$bar"; # both ops explicitly stringy
+
+=head2 Integer Arithmetic
+
+By default Perl assumes that it must do most of its arithmetic in
+floating point. But by saying
+
+ use integer;
+
+you may tell the compiler that it's okay to use integer operations
+from here to the end of the enclosing BLOCK. An inner BLOCK may
+countermand this by saying
+
+ no integer;
+
+which lasts until the end of that BLOCK.
+
+The bitwise operators ("&", "|", "^", "~", "<<", and ">>") always
+produce integral results. (But see also L<Bitwise String Operators>.)
+However, C<use integer> still has meaning
+for them. By default, their results are interpreted as unsigned
+integers. However, if C<use integer> is in effect, their results are
+interpreted as signed integers. For example, C<~0> usually evaluates
+to a large integral value. However, C<use integer; ~0> is -1 on twos-complement machines.
+
+=head2 Floating-point Arithmetic
+
+While C<use integer> provides integer-only arithmetic, there is no
+similar ways to provide rounding or truncation at a certain number of
+decimal places. For rounding to a certain number of digits, sprintf()
+or printf() is usually the easiest route.
+
+Floating-point numbers are only approximations to what a mathematician
+would call real numbers. There are infinitely more reals than floats,
+so some corners must be cut. For example:
+
+ printf "%.20g\n", 123456789123456789;
+ # produces 123456789123456784
+
+Testing for exact equality of floating-point equality or inequality is
+not a good idea. Here's a (relatively expensive) work-around to compare
+whether two floating-point numbers are equal to a particular number of
+decimal places. See Knuth, volume II, for a more robust treatment of
+this topic.
+
+ sub fp_equal {
+ my ($X, $Y, $POINTS) = @_;
+ my ($tX, $tY);
+ $tX = sprintf("%.${POINTS}g", $X);
+ $tY = sprintf("%.${POINTS}g", $Y);
+ return $tX eq $tY;
+ }
+
+The POSIX module (part of the standard perl distribution) implements
+ceil(), floor(), and a number of other mathematical and trigonometric
+functions. The Math::Complex module (part of the standard perl
+distribution) defines a number of mathematical functions that can also
+work on real numbers. Math::Complex not as efficient as POSIX, but
+POSIX can't work with complex numbers.
+
+Rounding in financial applications can have serious implications, and
+the rounding method used should be specified precisely. In these
+cases, it probably pays not to trust whichever system rounding is
+being used by Perl, but to instead implement the rounding function you
+need yourself.
+
+=head2 Bigger Numbers
+
+The standard Math::BigInt and Math::BigFloat modules provide
+variable precision arithmetic and overloaded operators.
+At the cost of some space and considerable speed, they
+avoid the normal pitfalls associated with limited-precision
+representations.
+
+ use Math::BigInt;
+ $x = Math::BigInt->new('123456789123456789');
+ print $x * $x;
+
+ # prints +15241578780673678515622620750190521
diff --git a/contrib/perl5/pod/perlpod.pod b/contrib/perl5/pod/perlpod.pod
new file mode 100644
index 0000000..d20d62d
--- /dev/null
+++ b/contrib/perl5/pod/perlpod.pod
@@ -0,0 +1,286 @@
+=head1 NAME
+
+perlpod - plain old documentation
+
+=head1 DESCRIPTION
+
+A pod-to-whatever translator reads a pod file paragraph by paragraph,
+and translates it to the appropriate output format. There are
+three kinds of paragraphs:
+L<verbatim|/"Verbatim Paragraph">,
+L<command|/"Command Paragraph">, and
+L<ordinary text|/"Ordinary Block of Text">.
+
+
+=head2 Verbatim Paragraph
+
+A verbatim paragraph, distinguished by being indented (that is,
+it starts with space or tab). It should be reproduced exactly,
+with tabs assumed to be on 8-column boundaries. There are no
+special formatting escapes, so you can't italicize or anything
+like that. A \ means \, and nothing else.
+
+
+=head2 Command Paragraph
+
+All command paragraphs start with "=", followed by an
+identifier, followed by arbitrary text that the command can
+use however it pleases. Currently recognized commands are
+
+ =head1 heading
+ =head2 heading
+ =item text
+ =over N
+ =back
+ =cut
+ =pod
+ =for X
+ =begin X
+ =end X
+
+=over 4
+
+=item =pod
+
+=item =cut
+
+The "=pod" directive does nothing beyond telling the compiler to lay
+off parsing code through the next "=cut". It's useful for adding
+another paragraph to the doc if you're mixing up code and pod a lot.
+
+=item =head1
+
+=item =head2
+
+Head1 and head2 produce first and second level headings, with the text in
+the same paragraph as the "=headn" directive forming the heading description.
+
+=item =over
+
+=item =back
+
+=item =item
+
+Item, over, and back require a little more explanation: "=over" starts a
+section specifically for the generation of a list using "=item" commands. At
+the end of your list, use "=back" to end it. You will probably want to give
+"4" as the number to "=over", as some formatters will use this for indentation.
+This should probably be a default. Note also that there are some basic rules
+to using =item: don't use them outside of an =over/=back block, use at least
+one inside an =over/=back block, you don't _have_ to include the =back if
+the list just runs off the document, and perhaps most importantly, keep the
+items consistent: either use "=item *" for all of them, to produce bullets,
+or use "=item 1.", "=item 2.", etc., to produce numbered lists, or use
+"=item foo", "=item bar", etc., i.e., things that looks nothing like bullets
+or numbers. If you start with bullets or numbers, stick with them, as many
+formatters use the first "=item" type to decide how to format the list.
+
+
+=item =for
+
+=item =begin
+
+=item =end
+
+For, begin, and end let you include sections that are not interpreted
+as pod text, but passed directly to particular formatters. A formatter
+that can utilize that format will use the section, otherwise it will be
+completely ignored. The directive "=for" specifies that the entire next
+paragraph is in the format indicated by the first word after
+"=for", like this:
+
+ =for html <br>
+ <p> This is a raw HTML paragraph </p>
+
+The paired commands "=begin" and "=end" work very similarly to "=for", but
+instead of only accepting a single paragraph, all text from "=begin" to a
+paragraph with a matching "=end" are treated as a particular format.
+
+Here are some examples of how to use these:
+
+ =begin html
+
+ <br>Figure 1.<IMG SRC="figure1.png"><br>
+
+ =end html
+
+ =begin text
+
+ ---------------
+ | foo |
+ | bar |
+ ---------------
+
+ ^^^^ Figure 1. ^^^^
+
+ =end text
+
+Some format names that formatters currently are known to accept include
+"roff", "man", "latex", "tex", "text", and "html". (Some formatters will
+treat some of these as synonyms.)
+
+And don't forget, when using any command, that the command lasts up until
+the end of the B<paragraph>, not the line. Hence in the examples below, you
+can see the empty lines after each command to end its paragraph.
+
+Some examples of lists include:
+
+ =over 4
+
+ =item *
+
+ First item
+
+ =item *
+
+ Second item
+
+ =back
+
+ =over 4
+
+ =item Foo()
+
+ Description of Foo function
+
+ =item Bar()
+
+ Description of Bar function
+
+ =back
+
+
+=back
+
+
+=head2 Ordinary Block of Text
+
+It will be filled, and maybe even
+justified. Certain interior sequences are recognized both
+here and in commands:
+
+ I<text> italicize text, used for emphasis or variables
+ B<text> embolden text, used for switches and programs
+ S<text> text contains non-breaking spaces
+ C<code> literal code
+ L<name> A link (cross reference) to name
+ L<name> manual page
+ L<name/ident> item in manual page
+ L<name/"sec"> section in other manual page
+ L<"sec"> section in this manual page
+ (the quotes are optional)
+ L</"sec"> ditto
+ same as above but only 'text' is used for output.
+ (Text can not contain the characters '|' or '>')
+ L<text|name>
+ L<text|name/ident>
+ L<text|name/"sec">
+ L<text|"sec">
+ L<text|/"sec">
+
+ F<file> Used for filenames
+ X<index> An index entry
+ Z<> A zero-width character
+ E<escape> A named character (very similar to HTML escapes)
+ E<lt> A literal <
+ E<gt> A literal >
+ (these are optional except in other interior
+ sequences and when preceded by a capital letter)
+ E<n> Character number n (probably in ASCII)
+ E<html> Some non-numeric HTML entity, such
+ as E<Agrave>
+
+
+=head2 The Intent
+
+That's it. The intent is simplicity, not power. I wanted paragraphs
+to look like paragraphs (block format), so that they stand out
+visually, and so that I could run them through fmt easily to reformat
+them (that's F7 in my version of B<vi>). I wanted the translator (and not
+me) to worry about whether " or ' is a left quote or a right quote
+within filled text, and I wanted it to leave the quotes alone, dammit, in
+verbatim mode, so I could slurp in a working program, shift it over 4
+spaces, and have it print out, er, verbatim. And presumably in a
+constant width font.
+
+In particular, you can leave things like this verbatim in your text:
+
+ Perl
+ FILEHANDLE
+ $variable
+ function()
+ manpage(3r)
+
+Doubtless a few other commands or sequences will need to be added along
+the way, but I've gotten along surprisingly well with just these.
+
+Note that I'm not at all claiming this to be sufficient for producing a
+book. I'm just trying to make an idiot-proof common source for nroff,
+TeX, and other markup languages, as used for online documentation.
+Translators exist for B<pod2man> (that's for nroff(1) and troff(1)),
+B<pod2text>, B<pod2html>, B<pod2latex>, and B<pod2fm>.
+
+
+=head2 Embedding Pods in Perl Modules
+
+You can embed pod documentation in your Perl scripts. Start your
+documentation with a "=head1" command at the beginning, and end it
+with a "=cut" command. Perl will ignore the pod text. See any of the
+supplied library modules for examples. If you're going to put your
+pods at the end of the file, and you're using an __END__ or __DATA__
+cut mark, make sure to put an empty line there before the first pod
+directive.
+
+ __END__
+
+
+ =head1 NAME
+
+ modern - I am a modern module
+
+If you had not had that empty line there, then the translators wouldn't
+have seen it.
+
+
+=head2 Common Pod Pitfalls
+
+=over 4
+
+=item *
+
+Pod translators usually will require paragraphs to be separated by
+completely empty lines. If you have an apparently empty line with
+some spaces on it, this can cause odd formatting.
+
+=item *
+
+Translators will mostly add wording around a LE<lt>E<gt> link, so that
+C<LE<lt>foo(1)E<gt>> becomes "the I<foo>(1) manpage", for example (see
+B<pod2man> for details). Thus, you shouldn't write things like C<the
+LE<lt>fooE<gt> manpage>, if you want the translated document to read
+sensibly.
+
+If you don need or want total control of the text used for a
+link in the output use the form LE<lt>show this text|fooE<gt>
+instead.
+
+=item *
+
+The script F<pod/checkpods.PL> in the Perl source distribution
+provides skeletal checking for lines that look empty but aren't
+B<only>, but is there as a placeholder until someone writes
+Pod::Checker. The best way to check your pod is to pass it through
+one or more translators and proofread the result, or print out the
+result and proofread that. Some of the problems found may be bugs in
+the translators, which you may or may not wish to work around.
+
+=back
+
+=head1 SEE ALSO
+
+L<pod2man> and L<perlsyn/"PODs: Embedded Documentation">
+
+=head1 AUTHOR
+
+Larry Wall
+
diff --git a/contrib/perl5/pod/perlport.pod b/contrib/perl5/pod/perlport.pod
new file mode 100644
index 0000000..79ca767
--- /dev/null
+++ b/contrib/perl5/pod/perlport.pod
@@ -0,0 +1,1461 @@
+=head1 NAME
+
+perlport - Writing portable Perl
+
+
+=head1 DESCRIPTION
+
+Perl runs on a variety of operating systems. While most of them share
+a lot in common, they also have their own very particular and unique
+features.
+
+This document is meant to help you to find out what constitutes portable
+Perl code, so that once you have made your decision to write portably,
+you know where the lines are drawn, and you can stay within them.
+
+There is a tradeoff between taking full advantage of B<a> particular type
+of computer, and taking advantage of a full B<range> of them. Naturally,
+as you make your range bigger (and thus more diverse), the common
+denominators drop, and you are left with fewer areas of common ground in
+which you can operate to accomplish a particular task. Thus, when you
+begin attacking a problem, it is important to consider which part of the
+tradeoff curve you want to operate under. Specifically, whether it is
+important to you that the task that you are coding needs the full
+generality of being portable, or if it is sufficient to just get the job
+done. This is the hardest choice to be made. The rest is easy, because
+Perl provides lots of choices, whichever way you want to approach your
+problem.
+
+Looking at it another way, writing portable code is usually about
+willfully limiting your available choices. Naturally, it takes discipline
+to do that.
+
+Be aware of two important points:
+
+=over 4
+
+=item Not all Perl programs have to be portable
+
+There is no reason why you should not use Perl as a language to glue Unix
+tools together, or to prototype a Macintosh application, or to manage the
+Windows registry. If it makes no sense to aim for portability for one
+reason or another in a given program, then don't bother.
+
+=item The vast majority of Perl B<is> portable
+
+Don't be fooled into thinking that it is hard to create portable Perl
+code. It isn't. Perl tries its level-best to bridge the gaps between
+what's available on different platforms, and all the means available to
+use those features. Thus almost all Perl code runs on any machine
+without modification. But there I<are> some significant issues in
+writing portable code, and this document is entirely about those issues.
+
+=back
+
+Here's the general rule: When you approach a task that is commonly done
+using a whole range of platforms, think in terms of writing portable
+code. That way, you don't sacrifice much by way of the implementation
+choices you can avail yourself of, and at the same time you can give
+your users lots of platform choices. On the other hand, when you have to
+take advantage of some unique feature of a particular platform, as is
+often the case with systems programming (whether for Unix, Windows,
+S<Mac OS>, VMS, etc.), consider writing platform-specific code.
+
+When the code will run on only two or three operating systems, then you
+may only need to consider the differences of those particular systems.
+The important thing is to decide where the code will run, and to be
+deliberate in your decision.
+
+The material below is separated into three main sections: main issues of
+portability (L<"ISSUES">, platform-specific issues (L<"PLATFORMS">, and
+builtin perl functions that behave differently on various ports
+(L<"FUNCTION IMPLEMENTATIONS">.
+
+This information should not be considered complete; it includes possibly
+transient information about idiosyncrasies of some of the ports, almost
+all of which are in a state of constant evolution. Thus this material
+should be considered a perpetual work in progress
+(E<lt>IMG SRC="yellow_sign.gif" ALT="Under Construction"E<gt>).
+
+
+
+
+=head1 ISSUES
+
+=head2 Newlines
+
+In most operating systems, lines in files are separated with newlines.
+Just what is used as a newline may vary from OS to OS. Unix
+traditionally uses C<\012>, one kind of Windows I/O uses C<\015\012>,
+and S<Mac OS> uses C<\015>.
+
+Perl uses C<\n> to represent the "logical" newline, where what
+is logical may depend on the platform in use. In MacPerl, C<\n>
+always means C<\015>. In DOSish perls, C<\n> usually means C<\012>, but
+when accessing a file in "text" mode, STDIO translates it to (or from)
+C<\015\012>.
+
+Due to the "text" mode translation, DOSish perls have limitations
+of using C<seek> and C<tell> when a file is being accessed in "text"
+mode. Specifically, if you stick to C<seek>-ing to locations you got
+from C<tell> (and no others), you are usually free to use C<seek> and
+C<tell> even in "text" mode. In general, using C<seek> or C<tell> or
+other file operations that count bytes instead of characters, without
+considering the length of C<\n>, may be non-portable. If you use
+C<binmode> on a file, however, you can usually use C<seek> and C<tell>
+with arbitrary values quite safely.
+
+A common misconception in socket programming is that C<\n> eq C<\012>
+everywhere. When using protocols such as common Internet protocols,
+C<\012> and C<\015> are called for specifically, and the values of
+the logical C<\n> and C<\r> (carriage return) are not reliable.
+
+ print SOCKET "Hi there, client!\r\n"; # WRONG
+ print SOCKET "Hi there, client!\015\012"; # RIGHT
+
+[NOTE: this does not necessarily apply to communications that are
+filtered by another program or module before sending to the socket; the
+the most popular EBCDIC webserver, for instance, accepts C<\r\n>,
+which translates those characters, along with all other
+characters in text streams, from EBCDIC to ASCII.]
+
+However, using C<\015\012> (or C<\cM\cJ>, or C<\x0D\x0A>) can be tedious
+and unsightly, as well as confusing to those maintaining the code. As
+such, the C<Socket> module supplies the Right Thing for those who want it.
+
+ use Socket qw(:DEFAULT :crlf);
+ print SOCKET "Hi there, client!$CRLF" # RIGHT
+
+When reading I<from> a socket, remember that the default input record
+separator (C<$/>) is C<\n>, but code like this should recognize C<$/> as
+C<\012> or C<\015\012>:
+
+ while (<SOCKET>) {
+ # ...
+ }
+
+Better:
+
+ use Socket qw(:DEFAULT :crlf);
+ local($/) = LF; # not needed if $/ is already \012
+
+ while (<SOCKET>) {
+ s/$CR?$LF/\n/; # not sure if socket uses LF or CRLF, OK
+ # s/\015?\012/\n/; # same thing
+ }
+
+And this example is actually better than the previous one even for Unix
+platforms, because now any C<\015>'s (C<\cM>'s) are stripped out
+(and there was much rejoicing).
+
+
+=head2 Numbers endianness and Width
+
+Different CPUs store integers and floating point numbers in different
+orders (called I<endianness>) and widths (32-bit and 64-bit being the
+most common). This affects your programs if they attempt to transfer
+numbers in binary format from a CPU architecture to another over some
+channel: either 'live' via network connections or storing the numbers
+to secondary storage such as a disk file.
+
+Conflicting storage orders make utter mess out of the numbers: if a
+little-endian host (Intel, Alpha) stores 0x12345678 (305419896 in
+decimal), a big-endian host (Motorola, MIPS, Sparc, PA) reads it as
+0x78563412 (2018915346 in decimal). To avoid this problem in network
+(socket) connections use the C<pack()> and C<unpack()> formats C<"n">
+and C<"N">, the "network" orders, they are guaranteed to be portable.
+
+Different widths can cause truncation even between platforms of equal
+endianness: the platform of shorter width loses the upper parts of the
+number. There is no good solution for this problem except to avoid
+transferring or storing raw binary numbers.
+
+One can circumnavigate both these problems in two ways: either
+transfer and store numbers always in text format, instead of raw
+binary, or consider using modules like C<Data::Dumper> (included in
+the standard distribution as of Perl 5.005) and C<Storable>.
+
+=head2 Files
+
+Most platforms these days structure files in a hierarchical fashion.
+So, it is reasonably safe to assume that any platform supports the
+notion of a "path" to uniquely identify a file on the system. Just
+how that path is actually written, differs.
+
+While they are similar, file path specifications differ between Unix,
+Windows, S<Mac OS>, OS/2, VMS, S<RISC OS> and probably others. Unix,
+for example, is one of the few OSes that has the idea of a single root
+directory.
+
+VMS, Windows, and OS/2 can work similarly to Unix with C</> as path
+separator, or in their own idiosyncratic ways (such as having several
+root directories and various "unrooted" device files such NIL: and
+LPT:).
+
+S<Mac OS> uses C<:> as a path separator instead of C</>.
+
+C<RISC OS> perl can emulate Unix filenames with C</> as path
+separator, or go native and use C<.> for path separator and C<:> to
+signal filing systems and disc names.
+
+As with the newline problem above, there are modules that can help. The
+C<File::Spec> modules provide methods to do the Right Thing on whatever
+platform happens to be running the program.
+
+ use File::Spec;
+ chdir(File::Spec->updir()); # go up one directory
+ $file = File::Spec->catfile(
+ File::Spec->curdir(), 'temp', 'file.txt'
+ );
+ # on Unix and Win32, './temp/file.txt'
+ # on Mac OS, ':temp:file.txt'
+
+File::Spec is available in the standard distribution, as of version
+5.004_05.
+
+In general, production code should not have file paths hardcoded; making
+them user supplied or from a configuration file is better, keeping in mind
+that file path syntax varies on different machines.
+
+This is especially noticeable in scripts like Makefiles and test suites,
+which often assume C</> as a path separator for subdirectories.
+
+Also of use is C<File::Basename>, from the standard distribution, which
+splits a pathname into pieces (base filename, full path to directory,
+and file suffix).
+
+Even when on a single platform (if you can call UNIX a single
+platform), remember not to count on the existence or the contents of
+system-specific files, like F</etc/passwd>, F</etc/sendmail.conf>, or
+F</etc/resolv.conf>. For example the F</etc/passwd> may exist but it
+may not contain the encrypted passwords because the system is using
+some form of enhanced security-- or it may not contain all the
+accounts because the system is using NIS. If code does need to rely
+on such a file, include a description of the file and its format in
+the code's documentation, and make it easy for the user to override
+the default location of the file.
+
+Do not have two files of the same name with different case, like
+F<test.pl> and <Test.pl>, as many platforms have case-insensitive
+filenames. Also, try not to have non-word characters (except for C<.>)
+in the names, and keep them to the 8.3 convention, for maximum
+portability.
+
+Likewise, if using C<AutoSplit>, try to keep the split functions to
+8.3 naming and case-insensitive conventions; or, at the very least,
+make it so the resulting files have a unique (case-insensitively)
+first 8 characters.
+
+Don't assume C<E<lt>> won't be the first character of a filename. Always
+use C<E<gt>> explicitly to open a file for reading:
+
+ open(FILE, "<$existing_file") or die $!;
+
+
+=head2 System Interaction
+
+Not all platforms provide for the notion of a command line, necessarily.
+These are usually platforms that rely on a Graphical User Interface (GUI)
+for user interaction. So a program requiring command lines might not work
+everywhere. But this is probably for the user of the program to deal
+with.
+
+Some platforms can't delete or rename files that are being held open by
+the system. Remember to C<close> files when you are done with them.
+Don't C<unlink> or C<rename> an open file. Don't C<tie> to or C<open> a
+file that is already tied to or opened; C<untie> or C<close> first.
+
+Don't open the same file more than once at a time for writing, as some
+operating systems put mandatory locks on such files.
+
+Don't count on a specific environment variable existing in C<%ENV>.
+Don't count on C<%ENV> entries being case-sensitive, or even
+case-preserving.
+
+Don't count on signals.
+
+Don't count on filename globbing. Use C<opendir>, C<readdir>, and
+C<closedir> instead.
+
+Don't count on per-program environment variables, or per-program current
+directories.
+
+
+=head2 Interprocess Communication (IPC)
+
+In general, don't directly access the system in code that is meant to be
+portable. That means, no C<system>, C<exec>, C<fork>, C<pipe>, C<``>,
+C<qx//>, C<open> with a C<|>, nor any of the other things that makes being
+a Unix perl hacker worth being.
+
+Commands that launch external processes are generally supported on
+most platforms (though many of them do not support any type of forking),
+but the problem with using them arises from what you invoke with them.
+External tools are often named differently on different platforms, often
+not available in the same location, often accept different arguments,
+often behave differently, and often represent their results in a
+platform-dependent way. Thus you should seldom depend on them to produce
+consistent results.
+
+One especially common bit of Perl code is opening a pipe to sendmail:
+
+ open(MAIL, '|/usr/lib/sendmail -t') or die $!;
+
+This is fine for systems programming when sendmail is known to be
+available. But it is not fine for many non-Unix systems, and even
+some Unix systems that may not have sendmail installed. If a portable
+solution is needed, see the C<Mail::Send> and C<Mail::Mailer> modules
+in the C<MailTools> distribution. C<Mail::Mailer> provides several
+mailing methods, including mail, sendmail, and direct SMTP
+(via C<Net::SMTP>) if a mail transfer agent is not available.
+
+The rule of thumb for portable code is: Do it all in portable Perl, or
+use a module (that may internally implement it with platform-specific
+code, but expose a common interface).
+
+The UNIX System V IPC (C<msg*(), sem*(), shm*()>) is not available
+even in all UNIX platforms.
+
+=head2 External Subroutines (XS)
+
+XS code, in general, can be made to work with any platform; but dependent
+libraries, header files, etc., might not be readily available or
+portable, or the XS code itself might be platform-specific, just as Perl
+code might be. If the libraries and headers are portable, then it is
+normally reasonable to make sure the XS code is portable, too.
+
+There is a different kind of portability issue with writing XS
+code: availability of a C compiler on the end-user's system. C brings
+with it its own portability issues, and writing XS code will expose you to
+some of those. Writing purely in perl is a comparatively easier way to
+achieve portability.
+
+
+=head2 Standard Modules
+
+In general, the standard modules work across platforms. Notable
+exceptions are C<CPAN.pm> (which currently makes connections to external
+programs that may not be available), platform-specific modules (like
+C<ExtUtils::MM_VMS>), and DBM modules.
+
+There is no one DBM module that is available on all platforms.
+C<SDBM_File> and the others are generally available on all Unix and DOSish
+ports, but not in MacPerl, where only C<NBDM_File> and C<DB_File> are
+available.
+
+The good news is that at least some DBM module should be available, and
+C<AnyDBM_File> will use whichever module it can find. Of course, then
+the code needs to be fairly strict, dropping to the lowest common
+denominator (e.g., not exceeding 1K for each record).
+
+
+=head2 Time and Date
+
+The system's notion of time of day and calendar date is controlled in
+widely different ways. Don't assume the timezone is stored in C<$ENV{TZ}>,
+and even if it is, don't assume that you can control the timezone through
+that variable.
+
+Don't assume that the epoch starts at 00:00:00, January 1, 1970,
+because that is OS-specific. Better to store a date in an unambiguous
+representation. The ISO 8601 standard defines YYYY-MM-DD as the date
+format. A text representation (like C<1 Jan 1970>) can be easily
+converted into an OS-specific value using a module like
+C<Date::Parse>. An array of values, such as those returned by
+C<localtime>, can be converted to an OS-specific representation using
+C<Time::Local>.
+
+
+=head2 Character sets and character encoding
+
+Assume very little about character sets. Do not assume anything about
+the numerical values (C<ord()>, C<chr()>) of characters. Do not
+assume that the alphabetic characters are encoded contiguously (in
+numerical sense). Do no assume anything about the ordering of the
+characters. The lowercase letters may come before or after the
+uppercase letters, the lowercase and uppercase may be interlaced so
+that both 'a' and 'A' come before the 'b', the accented and other
+international characters may be interlaced so that E<auml> comes
+before the 'b'.
+
+
+=head2 Internationalisation
+
+If you may assume POSIX (a rather large assumption, that: in practise
+that means UNIX) you may read more about the POSIX locale system from
+L<perllocale>. The locale system at least attempts to make things a
+little bit more portable or at least more convenient and
+native-friendly for non-English users. The system affects character
+sets and encoding, and date and time formatting, among other things.
+
+
+=head2 System Resources
+
+If your code is destined for systems with severely constrained (or
+missing!) virtual memory systems then you want to be I<especially> mindful
+of avoiding wasteful constructs such as:
+
+ # NOTE: this is no longer "bad" in perl5.005
+ for (0..10000000) {} # bad
+ for (my $x = 0; $x <= 10000000; ++$x) {} # good
+
+ @lines = <VERY_LARGE_FILE>; # bad
+
+ while (<FILE>) {$file .= $_} # sometimes bad
+ $file = join('', <FILE>); # better
+
+The last two may appear unintuitive to most people. The first of those
+two constructs repeatedly grows a string, while the second allocates a
+large chunk of memory in one go. On some systems, the latter is more
+efficient that the former.
+
+
+=head2 Security
+
+Most multi-user platforms provide basic levels of security that is usually
+felt at the file-system level. Other platforms usually don't
+(unfortunately). Thus the notion of user id, or "home" directory, or even
+the state of being logged-in, may be unrecognizable on many platforms. If
+you write programs that are security conscious, it is usually best to know
+what type of system you will be operating under, and write code explicitly
+for that platform (or class of platforms).
+
+
+=head2 Style
+
+For those times when it is necessary to have platform-specific code,
+consider keeping the platform-specific code in one place, making porting
+to other platforms easier. Use the C<Config> module and the special
+variable C<$^O> to differentiate platforms, as described in
+L<"PLATFORMS">.
+
+
+=head1 CPAN Testers
+
+Modules uploaded to CPAN are tested by a variety of volunteers on
+different platforms. These CPAN testers are notified by mail of each
+new upload, and reply to the list with PASS, FAIL, NA (not applicable to
+this platform), or UNKNOWN (unknown), along with any relevant notations.
+
+The purpose of the testing is twofold: one, to help developers fix any
+problems in their code that crop up because of lack of testing on other
+platforms; two, to provide users with information about whether or not
+a given module works on a given platform.
+
+=over 4
+
+=item Mailing list: cpan-testers@perl.org
+
+=item Testing results: C<http://www.connect.net/gbarr/cpan-test/>
+
+=back
+
+
+=head1 PLATFORMS
+
+As of version 5.002, Perl is built with a C<$^O> variable that
+indicates the operating system it was built on. This was implemented
+to help speed up code that would otherwise have to C<use Config;> and
+use the value of C<$Config{'osname'}>. Of course, to get
+detailed information about the system, looking into C<%Config> is
+certainly recommended.
+
+=head2 Unix
+
+Perl works on a bewildering variety of Unix and Unix-like platforms (see
+e.g. most of the files in the F<hints/> directory in the source code kit).
+On most of these systems, the value of C<$^O> (hence C<$Config{'osname'}>,
+too) is determined by lowercasing and stripping punctuation from the first
+field of the string returned by typing C<uname -a> (or a similar command)
+at the shell prompt. Here, for example, are a few of the more popular
+Unix flavors:
+
+ uname $^O $Config{'archname'}
+ -------------------------------------------
+ AIX aix aix
+ FreeBSD freebsd freebsd-i386
+ Linux linux i386-linux
+ HP-UX hpux PA-RISC1.1
+ IRIX irix irix
+ OSF1 dec_osf alpha-dec_osf
+ SunOS solaris sun4-solaris
+ SunOS solaris i86pc-solaris
+ SunOS4 sunos sun4-sunos
+
+Note that because the C<$Config{'archname'}> may depend on the hardware
+architecture it may vary quite a lot, much more than the C<$^O>.
+
+=head2 DOS and Derivatives
+
+Perl has long been ported to PC style microcomputers running under
+systems like PC-DOS, MS-DOS, OS/2, and most Windows platforms you can
+bring yourself to mention (except for Windows CE, if you count that).
+Users familiar with I<COMMAND.COM> and/or I<CMD.EXE> style shells should
+be aware that each of these file specifications may have subtle
+differences:
+
+ $filespec0 = "c:/foo/bar/file.txt";
+ $filespec1 = "c:\\foo\\bar\\file.txt";
+ $filespec2 = 'c:\foo\bar\file.txt';
+ $filespec3 = 'c:\\foo\\bar\\file.txt';
+
+System calls accept either C</> or C<\> as the path separator. However,
+many command-line utilities of DOS vintage treat C</> as the option
+prefix, so they may get confused by filenames containing C</>. Aside
+from calling any external programs, C</> will work just fine, and
+probably better, as it is more consistent with popular usage, and avoids
+the problem of remembering what to backwhack and what not to.
+
+The DOS FAT filesystem can only accommodate "8.3" style filenames. Under
+the "case insensitive, but case preserving" HPFS (OS/2) and NTFS (NT)
+filesystems you may have to be careful about case returned with functions
+like C<readdir> or used with functions like C<open> or C<opendir>.
+
+DOS also treats several filenames as special, such as AUX, PRN, NUL, CON,
+COM1, LPT1, LPT2 etc. Unfortunately these filenames won't even work
+if you include an explicit directory prefix, in some cases. It is best
+to avoid such filenames, if you want your code to be portable to DOS
+and its derivatives.
+
+Users of these operating systems may also wish to make use of
+scripts such as I<pl2bat.bat> or I<pl2cmd> as appropriate to
+put wrappers around your scripts.
+
+Newline (C<\n>) is translated as C<\015\012> by STDIO when reading from
+and writing to files. C<binmode(FILEHANDLE)> will keep C<\n> translated
+as C<\012> for that filehandle. Since it is a noop on other systems,
+C<binmode> should be used for cross-platform code that deals with binary
+data.
+
+The C<$^O> variable and the C<$Config{'archname'}> values for various
+DOSish perls are as follows:
+
+ OS $^O $Config{'archname'}
+ --------------------------------------------
+ MS-DOS dos
+ PC-DOS dos
+ OS/2 os2
+ Windows 95 MSWin32 MSWin32-x86
+ Windows NT MSWin32 MSWin32-x86
+ Windows NT MSWin32 MSWin32-alpha
+ Windows NT MSWin32 MSWin32-ppc
+
+Also see:
+
+=over 4
+
+=item The djgpp environment for DOS, C<http://www.delorie.com/djgpp/>
+
+=item The EMX environment for DOS, OS/2, etc. C<emx@iaehv.nl>,
+C<http://www.juge.com/bbs/Hobb.19.html>
+
+=item Build instructions for Win32, L<perlwin32>.
+
+=item The ActiveState Pages, C<http://www.activestate.com/>
+
+=back
+
+
+=head2 S<Mac OS>
+
+Any module requiring XS compilation is right out for most people, because
+MacPerl is built using non-free (and non-cheap!) compilers. Some XS
+modules that can work with MacPerl are built and distributed in binary
+form on CPAN. See I<MacPerl: Power and Ease> and L<"CPAN Testers">
+for more details.
+
+Directories are specified as:
+
+ volume:folder:file for absolute pathnames
+ volume:folder: for absolute pathnames
+ :folder:file for relative pathnames
+ :folder: for relative pathnames
+ :file for relative pathnames
+ file for relative pathnames
+
+Files in a directory are stored in alphabetical order. Filenames are
+limited to 31 characters, and may include any character except C<:>,
+which is reserved as a path separator.
+
+Instead of C<flock>, see C<FSpSetFLock> and C<FSpRstFLock> in the
+C<Mac::Files> module.
+
+In the MacPerl application, you can't run a program from the command line;
+programs that expect C<@ARGV> to be populated can be edited with something
+like the following, which brings up a dialog box asking for the command
+line arguments.
+
+ if (!@ARGV) {
+ @ARGV = split /\s+/, MacPerl::Ask('Arguments?');
+ }
+
+A MacPerl script saved as a droplet will populate C<@ARGV> with the full
+pathnames of the files dropped onto the script.
+
+Mac users can use programs on a kind of command line under MPW (Macintosh
+Programmer's Workshop, a free development environment from Apple).
+MacPerl was first introduced as an MPW tool, and MPW can be used like a
+shell:
+
+ perl myscript.plx some arguments
+
+ToolServer is another app from Apple that provides access to MPW tools
+from MPW and the MacPerl app, which allows MacPerl programs to use
+C<system>, backticks, and piped C<open>.
+
+"S<Mac OS>" is the proper name for the operating system, but the value
+in C<$^O> is "MacOS". To determine architecture, version, or whether
+the application or MPW tool version is running, check:
+
+ $is_app = $MacPerl::Version =~ /App/;
+ $is_tool = $MacPerl::Version =~ /MPW/;
+ ($version) = $MacPerl::Version =~ /^(\S+)/;
+ $is_ppc = $MacPerl::Architecture eq 'MacPPC';
+ $is_68k = $MacPerl::Architecture eq 'Mac68K';
+
+S<Mac OS X>, to be based on NeXT's OpenStep OS, will be able to run
+MacPerl natively (in the Blue Box, and even in the Yellow Box, once some
+changes to the toolbox calls are made), but Unix perl will also run
+natively.
+
+Also see:
+
+=over 4
+
+=item The MacPerl Pages, C<http://www.ptf.com/macperl/>.
+
+=item The MacPerl mailing list, C<mac-perl-request@iis.ee.ethz.ch>.
+
+=back
+
+
+=head2 VMS
+
+Perl on VMS is discussed in F<vms/perlvms.pod> in the perl distribution.
+Note that perl on VMS can accept either VMS- or Unix-style file
+specifications as in either of the following:
+
+ $ perl -ne "print if /perl_setup/i" SYS$LOGIN:LOGIN.COM
+ $ perl -ne "print if /perl_setup/i" /sys$login/login.com
+
+but not a mixture of both as in:
+
+ $ perl -ne "print if /perl_setup/i" sys$login:/login.com
+ Can't open sys$login:/login.com: file specification syntax error
+
+Interacting with Perl from the Digital Command Language (DCL) shell
+often requires a different set of quotation marks than Unix shells do.
+For example:
+
+ $ perl -e "print ""Hello, world.\n"""
+ Hello, world.
+
+There are a number of ways to wrap your perl scripts in DCL .COM files if
+you are so inclined. For example:
+
+ $ write sys$output "Hello from DCL!"
+ $ if p1 .eqs. ""
+ $ then perl -x 'f$environment("PROCEDURE")
+ $ else perl -x - 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8
+ $ deck/dollars="__END__"
+ #!/usr/bin/perl
+
+ print "Hello from Perl!\n";
+
+ __END__
+ $ endif
+
+Do take care with C<$ ASSIGN/nolog/user SYS$COMMAND: SYS$INPUT> if your
+perl-in-DCL script expects to do things like C<$read = E<lt>STDINE<gt>;>.
+
+Filenames are in the format "name.extension;version". The maximum
+length for filenames is 39 characters, and the maximum length for
+extensions is also 39 characters. Version is a number from 1 to
+32767. Valid characters are C</[A-Z0-9$_-]/>.
+
+VMS' RMS filesystem is case insensitive and does not preserve case.
+C<readdir> returns lowercased filenames, but specifying a file for
+opening remains case insensitive. Files without extensions have a
+trailing period on them, so doing a C<readdir> with a file named F<A.;5>
+will return F<a.> (though that file could be opened with
+C<open(FH, 'A')>).
+
+RMS had an eight level limit on directory depths from any rooted logical
+(allowing 16 levels overall) prior to VMS 7.2. Hence
+C<PERL_ROOT:[LIB.2.3.4.5.6.7.8]> is a valid directory specification but
+C<PERL_ROOT:[LIB.2.3.4.5.6.7.8.9]> is not. F<Makefile.PL> authors might
+have to take this into account, but at least they can refer to the former
+as C</PERL_ROOT/lib/2/3/4/5/6/7/8/>.
+
+The C<VMS::Filespec> module, which gets installed as part of the build
+process on VMS, is a pure Perl module that can easily be installed on
+non-VMS platforms and can be helpful for conversions to and from RMS
+native formats.
+
+What C<\n> represents depends on the type of file that is open. It could
+be C<\015>, C<\012>, C<\015\012>, or nothing. Reading from a file
+translates newlines to C<\012>, unless C<binmode> was executed on that
+handle, just like DOSish perls.
+
+TCP/IP stacks are optional on VMS, so socket routines might not be
+implemented. UDP sockets may not be supported.
+
+The value of C<$^O> on OpenVMS is "VMS". To determine the architecture
+that you are running on without resorting to loading all of C<%Config>
+you can examine the content of the C<@INC> array like so:
+
+ if (grep(/VMS_AXP/, @INC)) {
+ print "I'm on Alpha!\n";
+ } elsif (grep(/VMS_VAX/, @INC)) {
+ print "I'm on VAX!\n";
+ } else {
+ print "I'm not so sure about where $^O is...\n";
+ }
+
+Also see:
+
+=over 4
+
+=item L<perlvms.pod>
+
+=item vmsperl list, C<vmsperl-request@newman.upenn.edu>
+
+Put words C<SUBSCRIBE VMSPERL> in message body.
+
+=item vmsperl on the web, C<http://www.sidhe.org/vmsperl/index.html>
+
+=back
+
+
+=head2 EBCDIC Platforms
+
+Recent versions of Perl have been ported to platforms such as OS/400 on
+AS/400 minicomputers as well as OS/390 for IBM Mainframes. Such computers
+use EBCDIC character sets internally (usually Character Code Set ID 00819
+for OS/400 and IBM-1047 for OS/390). Note that on the mainframe perl
+currently works under the "Unix system services for OS/390" (formerly
+known as OpenEdition).
+
+As of R2.5 of USS for OS/390 that Unix sub-system did not support the
+C<#!> shebang trick for script invocation. Hence, on OS/390 perl scripts
+can executed with a header similar to the following simple script:
+
+ : # use perl
+ eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
+ if 0;
+ #!/usr/local/bin/perl # just a comment really
+
+ print "Hello from perl!\n";
+
+On these platforms, bear in mind that the EBCDIC character set may have
+an effect on what happens with some perl functions (such as C<chr>,
+C<pack>, C<print>, C<printf>, C<ord>, C<sort>, C<sprintf>, C<unpack>), as
+well as bit-fiddling with ASCII constants using operators like C<^>, C<&>
+and C<|>, not to mention dealing with socket interfaces to ASCII computers
+(see L<"NEWLINES">).
+
+Fortunately, most web servers for the mainframe will correctly translate
+the C<\n> in the following statement to its ASCII equivalent (note that
+C<\r> is the same under both Unix and OS/390):
+
+ print "Content-type: text/html\r\n\r\n";
+
+The value of C<$^O> on OS/390 is "os390".
+
+Some simple tricks for determining if you are running on an EBCDIC
+platform could include any of the following (perhaps all):
+
+ if ("\t" eq "\05") { print "EBCDIC may be spoken here!\n"; }
+
+ if (ord('A') == 193) { print "EBCDIC may be spoken here!\n"; }
+
+ if (chr(169) eq 'z') { print "EBCDIC may be spoken here!\n"; }
+
+Note that one thing you may not want to rely on is the EBCDIC encoding
+of punctuation characters since these may differ from code page to code
+page (and once your module or script is rumoured to work with EBCDIC,
+folks will want it to work with all EBCDIC character sets).
+
+Also see:
+
+=over 4
+
+=item perl-mvs list
+
+The perl-mvs@perl.org list is for discussion of porting issues as well as
+general usage issues for all EBCDIC Perls. Send a message body of
+"subscribe perl-mvs" to majordomo@perl.org.
+
+=item AS/400 Perl information at C<http://as400.rochester.ibm.com/>
+
+=back
+
+
+=head2 Acorn RISC OS
+
+As Acorns use ASCII with newlines (C<\n>) in text files as C<\012> like
+Unix and Unix filename emulation is turned on by default, it is quite
+likely that most simple scripts will work "out of the box". The native
+filing system is modular, and individual filing systems are free to be
+case-sensitive or insensitive, and are usually case-preserving. Some
+native filing systems have name length limits which file and directory
+names are silently truncated to fit - scripts should be aware that the
+standard disc filing system currently has a name length limit of B<10>
+characters, with up to 77 items in a directory, but other filing systems
+may not impose such limitations.
+
+Native filenames are of the form
+
+ Filesystem#Special_Field::DiscName.$.Directory.Directory.File
+
+where
+
+ Special_Field is not usually present, but may contain . and $ .
+ Filesystem =~ m|[A-Za-z0-9_]|
+ DsicName =~ m|[A-Za-z0-9_/]|
+ $ represents the root directory
+ . is the path separator
+ @ is the current directory (per filesystem but machine global)
+ ^ is the parent directory
+ Directory and File =~ m|[^\0- "\.\$\%\&:\@\\^\|\177]+|
+
+The default filename translation is roughly C<tr|/.|./|;>
+
+Note that C<"ADFS::HardDisc.$.File" ne 'ADFS::HardDisc.$.File'> and that
+the second stage of C<$> interpolation in regular expressions will fall
+foul of the C<$.> if scripts are not careful.
+
+Logical paths specified by system variables containing comma-separated
+search lists are also allowed, hence C<System:Modules> is a valid
+filename, and the filesystem will prefix C<Modules> with each section of
+C<System$Path> until a name is made that points to an object on disc.
+Writing to a new file C<System:Modules> would only be allowed if
+C<System$Path> contains a single item list. The filesystem will also
+expand system variables in filenames if enclosed in angle brackets, so
+C<E<lt>System$DirE<gt>.Modules> would look for the file
+S<C<$ENV{'System$Dir'} . 'Modules'>>. The obvious implication of this is
+that B<fully qualified filenames can start with C<E<lt>E<gt>> and should
+be protected when C<open> is used for input.
+
+Because C<.> was in use as a directory separator and filenames could not
+be assumed to be unique after 10 characters, Acorn implemented the C
+compiler to strip the trailing C<.c> C<.h> C<.s> and C<.o> suffix from
+filenames specified in source code and store the respective files in
+subdirectories named after the suffix. Hence files are translated:
+
+ foo.h h.foo
+ C:foo.h C:h.foo (logical path variable)
+ sys/os.h sys.h.os (C compiler groks Unix-speak)
+ 10charname.c c.10charname
+ 10charname.o o.10charname
+ 11charname_.c c.11charname (assuming filesystem truncates at 10)
+
+The Unix emulation library's translation of filenames to native assumes
+that this sort of translation is required, and allows a user defined list
+of known suffixes which it will transpose in this fashion. This may
+appear transparent, but consider that with these rules C<foo/bar/baz.h>
+and C<foo/bar/h/baz> both map to C<foo.bar.h.baz>, and that C<readdir> and
+C<glob> cannot and do not attempt to emulate the reverse mapping. Other
+C<.>s in filenames are translated to C</>.
+
+As implied above the environment accessed through C<%ENV> is global, and
+the convention is that program specific environment variables are of the
+form C<Program$Name>. Each filing system maintains a current directory,
+and the current filing system's current directory is the B<global> current
+directory. Consequently, sociable scripts don't change the current
+directory but rely on full pathnames, and scripts (and Makefiles) cannot
+assume that they can spawn a child process which can change the current
+directory without affecting its parent (and everyone else for that
+matter).
+
+As native operating system filehandles are global and currently are
+allocated down from 255, with 0 being a reserved value the Unix emulation
+library emulates Unix filehandles. Consequently, you can't rely on
+passing C<STDIN>, C<STDOUT>, or C<STDERR> to your children.
+
+The desire of users to express filenames of the form
+C<E<lt>Foo$DirE<gt>.Bar> on the command line unquoted causes problems,
+too: C<``> command output capture has to perform a guessing game. It
+assumes that a string C<E<lt>[^E<lt>E<gt>]+\$[^E<lt>E<gt>]E<gt>> is a
+reference to an environment variable, whereas anything else involving
+C<E<lt>> or C<E<gt>> is redirection, and generally manages to be 99%
+right. Of course, the problem remains that scripts cannot rely on any
+Unix tools being available, or that any tools found have Unix-like command
+line arguments.
+
+Extensions and XS are, in theory, buildable by anyone using free tools.
+In practice, many don't, as users of the Acorn platform are used to binary
+distribution. MakeMaker does run, but no available make currently copes
+with MakeMaker's makefiles; even if/when this is fixed, the lack of a
+Unix-like shell can cause problems with makefile rules, especially lines
+of the form C<cd sdbm && make all>, and anything using quoting.
+
+"S<RISC OS>" is the proper name for the operating system, but the value
+in C<$^O> is "riscos" (because we don't like shouting).
+
+Also see:
+
+=over 4
+
+=item perl list
+
+=back
+
+
+=head2 Other perls
+
+Perl has been ported to a variety of platforms that do not fit into any of
+the above categories. Some, such as AmigaOS, BeOS, QNX, and Plan 9, have
+been well-integrated into the standard Perl source code kit. You may need
+to see the F<ports/> directory on CPAN for information, and possibly
+binaries, for the likes of: aos, atari, lynxos, riscos, Tandem Guardian,
+vos, I<etc.> (yes we know that some of these OSes may fall under the Unix
+category, but we are not a standards body.)
+
+See also:
+
+=over 4
+
+=item Atari, Guido Flohr's page C<http://stud.uni-sb.de/~gufl0000/>
+
+=item HP 300 MPE/iX C<http://www.cccd.edu/~markb/perlix.html>
+
+=item Novell Netware
+
+A free perl5-based PERL.NLM for Novell Netware is available from
+C<http://www.novell.com/>
+
+=back
+
+
+=head1 FUNCTION IMPLEMENTATIONS
+
+Listed below are functions unimplemented or implemented differently on
+various platforms. Following each description will be, in parentheses, a
+list of platforms that the description applies to.
+
+The list may very well be incomplete, or wrong in some places. When in
+doubt, consult the platform-specific README files in the Perl source
+distribution, and other documentation resources for a given port.
+
+Be aware, moreover, that even among Unix-ish systems there are variations.
+
+For many functions, you can also query C<%Config>, exported by default
+from C<Config.pm>. For example, to check if the platform has the C<lstat>
+call, check C<$Config{'d_lstat'}>. See L<Config.pm> for a full
+description of available variables.
+
+
+=head2 Alphabetical Listing of Perl Functions
+
+=over 8
+
+=item -X FILEHANDLE
+
+=item -X EXPR
+
+=item -X
+
+C<-r>, C<-w>, and C<-x> have only a very limited meaning; directories
+and applications are executable, and there are no uid/gid
+considerations. C<-o> is not supported. (S<Mac OS>)
+
+C<-r>, C<-w>, C<-x>, and C<-o> tell whether or not file is accessible,
+which may not reflect UIC-based file protections. (VMS)
+
+C<-s> returns the size of the data fork, not the total size of data fork
+plus resource fork. (S<Mac OS>).
+
+C<-s> by name on an open file will return the space reserved on disk,
+rather than the current extent. C<-s> on an open filehandle returns the
+current size. (S<RISC OS>)
+
+C<-R>, C<-W>, C<-X>, C<-O> are indistinguishable from C<-r>, C<-w>,
+C<-x>, C<-o>. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+C<-b>, C<-c>, C<-k>, C<-g>, C<-p>, C<-u>, C<-A> are not implemented.
+(S<Mac OS>)
+
+C<-g>, C<-k>, C<-l>, C<-p>, C<-u>, C<-A> are not particularly meaningful.
+(Win32, VMS, S<RISC OS>)
+
+C<-d> is true if passed a device spec without an explicit directory.
+(VMS)
+
+C<-T> and C<-B> are implemented, but might misclassify Mac text files
+with foreign characters; this is the case will all platforms, but may
+affect S<Mac OS> often. (S<Mac OS>)
+
+C<-x> (or C<-X>) determine if a file ends in one of the executable
+suffixes. C<-S> is meaningless. (Win32)
+
+C<-x> (or C<-X>) determine if a file has an executable file type.
+(S<RISC OS>)
+
+=item binmode FILEHANDLE
+
+Meaningless. (S<Mac OS>, S<RISC OS>)
+
+Reopens file and restores pointer; if function fails, underlying
+filehandle may be closed, or pointer may be in a different position.
+(VMS)
+
+The value returned by C<tell> may be affected after the call, and
+the filehandle may be flushed. (Win32)
+
+=item chmod LIST
+
+Only limited meaning. Disabling/enabling write permission is mapped to
+locking/unlocking the file. (S<Mac OS>)
+
+Only good for changing "owner" read-write access, "group", and "other"
+bits are meaningless. (Win32)
+
+Only good for changing "owner" and "other" read-write access. (S<RISC OS>)
+
+=item chown LIST
+
+Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>)
+
+Does nothing, but won't fail. (Win32)
+
+=item chroot FILENAME
+
+=item chroot
+
+Not implemented. (S<Mac OS>, Win32, VMS, Plan9, S<RISC OS>)
+
+=item crypt PLAINTEXT,SALT
+
+May not be available if library or source was not provided when building
+perl. (Win32)
+
+=item dbmclose HASH
+
+Not implemented. (VMS, Plan9)
+
+=item dbmopen HASH,DBNAME,MODE
+
+Not implemented. (VMS, Plan9)
+
+=item dump LABEL
+
+Not useful. (S<Mac OS>, S<RISC OS>)
+
+Not implemented. (Win32)
+
+Invokes VMS debugger. (VMS)
+
+=item exec LIST
+
+Not implemented. (S<Mac OS>)
+
+=item fcntl FILEHANDLE,FUNCTION,SCALAR
+
+Not implemented. (Win32, VMS)
+
+=item flock FILEHANDLE,OPERATION
+
+Not implemented (S<Mac OS>, VMS, S<RISC OS>).
+
+Available only on Windows NT (not on Windows 95). (Win32)
+
+=item fork
+
+Not implemented. (S<Mac OS>, Win32, AmigaOS, S<RISC OS>)
+
+=item getlogin
+
+Not implemented. (S<Mac OS>, S<RISC OS>)
+
+=item getpgrp PID
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item getppid
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item getpriority WHICH,WHO
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item getpwnam NAME
+
+Not implemented. (S<Mac OS>, Win32)
+
+Not useful. (S<RISC OS>)
+
+=item getgrnam NAME
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item getnetbyname NAME
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item getpwuid UID
+
+Not implemented. (S<Mac OS>, Win32)
+
+Not useful. (S<RISC OS>)
+
+=item getgrgid GID
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item getnetbyaddr ADDR,ADDRTYPE
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item getprotobynumber NUMBER
+
+Not implemented. (S<Mac OS>)
+
+=item getservbyport PORT,PROTO
+
+Not implemented. (S<Mac OS>)
+
+=item getpwent
+
+Not implemented. (S<Mac OS>, Win32)
+
+=item getgrent
+
+Not implemented. (S<Mac OS>, Win32, VMS)
+
+=item gethostent
+
+Not implemented. (S<Mac OS>, Win32)
+
+=item getnetent
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item getprotoent
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item getservent
+
+Not implemented. (Win32, Plan9)
+
+=item setpwent
+
+Not implemented. (S<Mac OS>, Win32, S<RISC OS>)
+
+=item setgrent
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item sethostent STAYOPEN
+
+Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>)
+
+=item setnetent STAYOPEN
+
+Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>)
+
+=item setprotoent STAYOPEN
+
+Not implemented. (S<Mac OS>, Win32, Plan9, S<RISC OS>)
+
+=item setservent STAYOPEN
+
+Not implemented. (Plan9, Win32, S<RISC OS>)
+
+=item endpwent
+
+Not implemented. (S<Mac OS>, Win32)
+
+=item endgrent
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item endhostent
+
+Not implemented. (S<Mac OS>, Win32)
+
+=item endnetent
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item endprotoent
+
+Not implemented. (S<Mac OS>, Win32, Plan9)
+
+=item endservent
+
+Not implemented. (Plan9, Win32)
+
+=item getsockopt SOCKET,LEVEL,OPTNAME
+
+Not implemented. (S<Mac OS>, Plan9)
+
+=item glob EXPR
+
+=item glob
+
+Globbing built-in, but only C<*> and C<?> metacharacters are supported.
+(S<Mac OS>)
+
+Features depend on external perlglob.exe or perlglob.bat. May be
+overridden with something like File::DosGlob, which is recommended.
+(Win32)
+
+Globbing built-in, but only C<*> and C<?> metacharacters are supported.
+Globbing relies on operating system calls, which may return filenames
+in any order. As most filesystems are case-insensitive, even "sorted"
+filenames will not be in case-sensitive order. (S<RISC OS>)
+
+=item ioctl FILEHANDLE,FUNCTION,SCALAR
+
+Not implemented. (VMS)
+
+Available only for socket handles, and it does what the ioctlsocket() call
+in the Winsock API does. (Win32)
+
+Available only for socket handles. (S<RISC OS>)
+
+=item kill LIST
+
+Not implemented, hence not useful for taint checking. (S<Mac OS>,
+S<RISC OS>)
+
+Available only for process handles returned by the C<system(1, ...)>
+method of spawning a process. (Win32)
+
+=item link OLDFILE,NEWFILE
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item lstat FILEHANDLE
+
+=item lstat EXPR
+
+=item lstat
+
+Not implemented. (VMS, S<RISC OS>)
+
+Return values may be bogus. (Win32)
+
+=item msgctl ID,CMD,ARG
+
+=item msgget KEY,FLAGS
+
+=item msgsnd ID,MSG,FLAGS
+
+=item msgrcv ID,VAR,SIZE,TYPE,FLAGS
+
+Not implemented. (S<Mac OS>, Win32, VMS, Plan9, S<RISC OS>)
+
+=item open FILEHANDLE,EXPR
+
+=item open FILEHANDLE
+
+The C<|> variants are only supported if ToolServer is installed.
+(S<Mac OS>)
+
+open to C<|-> and C<-|> are unsupported. (S<Mac OS>, Win32, S<RISC OS>)
+
+=item pipe READHANDLE,WRITEHANDLE
+
+Not implemented. (S<Mac OS>)
+
+=item readlink EXPR
+
+=item readlink
+
+Not implemented. (Win32, VMS, S<RISC OS>)
+
+=item select RBITS,WBITS,EBITS,TIMEOUT
+
+Only implemented on sockets. (Win32)
+
+Only reliable on sockets. (S<RISC OS>)
+
+=item semctl ID,SEMNUM,CMD,ARG
+
+=item semget KEY,NSEMS,FLAGS
+
+=item semop KEY,OPSTRING
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item setpgrp PID,PGRP
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item setpriority WHICH,WHO,PRIORITY
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
+
+Not implemented. (S<Mac OS>, Plan9)
+
+=item shmctl ID,CMD,ARG
+
+=item shmget KEY,SIZE,FLAGS
+
+=item shmread ID,VAR,POS,SIZE
+
+=item shmwrite ID,STRING,POS,SIZE
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item stat FILEHANDLE
+
+=item stat EXPR
+
+=item stat
+
+mtime and atime are the same thing, and ctime is creation time instead of
+inode change time. (S<Mac OS>)
+
+device and inode are not meaningful. (Win32)
+
+device and inode are not necessarily reliable. (VMS)
+
+mtime, atime and ctime all return the last modification time. Device and
+inode are not necessarily reliable. (S<RISC OS>)
+
+=item symlink OLDFILE,NEWFILE
+
+Not implemented. (Win32, VMS, S<RISC OS>)
+
+=item syscall LIST
+
+Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+
+=item sysopen FILEHANDLE,FILENAME,MODE,PERMS
+
+The traditional "0", "1", and "2" MODEs are implemented with different
+numeric values on some systems. The flags exported by C<Fcntl>
+(O_RDONLY, O_WRONLY, O_RDWR) should work everywhere though. (S<Mac
+OS>, OS/390)
+
+=item system LIST
+
+Only implemented if ToolServer is installed. (S<Mac OS>)
+
+As an optimization, may not call the command shell specified in
+C<$ENV{PERL5SHELL}>. C<system(1, @args)> spawns an external
+process and immediately returns its process designator, without
+waiting for it to terminate. Return value may be used subsequently
+in C<wait> or C<waitpid>. (Win32)
+
+There is no shell to process metacharacters, and the native standard is
+to pass a command line terminated by "\n" "\r" or "\0" to the spawned
+program. Redirection such as C<E<gt> foo> is performed (if at all) by
+the run time library of the spawned program. C<system> I<list> will call
+the Unix emulation library's C<exec> emulation, which attempts to provide
+emulation of the stdin, stdout, stderr in force in the parent, providing
+the child program uses a compatible version of the emulation library.
+I<scalar> will call the native command line direct and no such emulation
+of a child Unix program will exists. Mileage B<will> vary. (S<RISC OS>)
+
+=item times
+
+Only the first entry returned is nonzero. (S<Mac OS>)
+
+"cumulative" times will be bogus. On anything other than Windows NT,
+"system" time will be bogus, and "user" time is actually the time
+returned by the clock() function in the C runtime library. (Win32)
+
+Not useful. (S<RISC OS>)
+
+=item truncate FILEHANDLE,LENGTH
+
+=item truncate EXPR,LENGTH
+
+Not implemented. (VMS)
+
+=item umask EXPR
+
+=item umask
+
+Returns undef where unavailable, as of version 5.005.
+
+=item utime LIST
+
+Only the modification time is updated. (S<Mac OS>, VMS, S<RISC OS>)
+
+May not behave as expected. Behavior depends on the C runtime
+library's implementation of utime(), and the filesystem being
+used. The FAT filesystem typically does not support an "access
+time" field, and it may limit timestamps to a granularity of
+two seconds. (Win32)
+
+=item wait
+
+=item waitpid PID,FLAGS
+
+Not implemented. (S<Mac OS>)
+
+Can only be applied to process handles returned for processes spawned
+using C<system(1, ...)>. (Win32)
+
+Not useful. (S<RISC OS>)
+
+=back
+
+=head1 CHANGES
+
+=over 4
+
+=item 1.33, 06 August 1998
+
+Integrate more minor changes.
+
+=item 1.32, 05 August 1998
+
+Integrate more minor changes.
+
+=item 1.30, 03 August 1998
+
+Major update for RISC OS, other minor changes.
+
+=item 1.23, 10 July 1998
+
+First public release with perl5.005.
+
+=back
+
+=head1 AUTHORS / CONTRIBUTORS
+
+Abigail E<lt>abigail@fnx.comE<gt>,
+Charles Bailey E<lt>bailey@genetics.upenn.eduE<gt>,
+Graham Barr E<lt>gbarr@pobox.comE<gt>,
+Tom Christiansen E<lt>tchrist@perl.comE<gt>,
+Nicholas Clark E<lt>Nicholas.Clark@liverpool.ac.ukE<gt>,
+Andy Dougherty E<lt>doughera@lafcol.lafayette.eduE<gt>,
+Dominic Dunlop E<lt>domo@vo.luE<gt>,
+M.J.T. Guy E<lt>mjtg@cus.cam.ac.ukE<gt>,
+Luther Huffman E<lt>lutherh@stratcom.comE<gt>,
+Nick Ing-Simmons E<lt>nick@ni-s.u-net.comE<gt>,
+Andreas J. KE<ouml>nig E<lt>koenig@kulturbox.deE<gt>,
+Andrew M. Langmead E<lt>aml@world.std.comE<gt>,
+Paul Moore E<lt>Paul.Moore@uk.origin-it.comE<gt>,
+Chris Nandor E<lt>pudge@pobox.comE<gt>,
+Matthias Neeracher E<lt>neeri@iis.ee.ethz.chE<gt>,
+Gary Ng E<lt>71564.1743@CompuServe.COME<gt>,
+Tom Phoenix E<lt>rootbeer@teleport.comE<gt>,
+Peter Prymmer E<lt>pvhp@forte.comE<gt>,
+Hugo van der Sanden E<lt>hv@crypt0.demon.co.ukE<gt>,
+Gurusamy Sarathy E<lt>gsar@umich.eduE<gt>,
+Paul J. Schinder E<lt>schinder@pobox.comE<gt>,
+Dan Sugalski E<lt>sugalskd@ous.eduE<gt>,
+Nathan Torkington E<lt>gnat@frii.comE<gt>.
+
+This document is maintained by Chris Nandor.
+
+=head1 VERSION
+
+Version 1.34, last modified 07 August 1998.
+
+
diff --git a/contrib/perl5/pod/perlre.pod b/contrib/perl5/pod/perlre.pod
new file mode 100644
index 0000000..382ba65
--- /dev/null
+++ b/contrib/perl5/pod/perlre.pod
@@ -0,0 +1,929 @@
+=head1 NAME
+
+perlre - Perl regular expressions
+
+=head1 DESCRIPTION
+
+This page describes the syntax of regular expressions in Perl. For a
+description of how to I<use> regular expressions in matching
+operations, plus various examples of the same, see discussion
+of C<m//>, C<s///>, C<qr//> and C<??> in L<perlop/"Regexp Quote-Like Operators">.
+
+The matching operations can have various modifiers. The modifiers
+that relate to the interpretation of the regular expression inside
+are listed below. For the modifiers that alter the way a regular expression
+is used by Perl, see L<perlop/"Regexp Quote-Like Operators"> and
+L<perlop/"Gory details of parsing quoted constructs">.
+
+=over 4
+
+=item i
+
+Do case-insensitive pattern matching.
+
+If C<use locale> is in effect, the case map is taken from the current
+locale. See L<perllocale>.
+
+=item m
+
+Treat string as multiple lines. That is, change "^" and "$" from matching
+at only the very start or end of the string to the start or end of any
+line anywhere within the string,
+
+=item s
+
+Treat string as single line. That is, change "." to match any character
+whatsoever, even a newline, which it normally would not match.
+
+The C</s> and C</m> modifiers both override the C<$*> setting. That is, no matter
+what C<$*> contains, C</s> without C</m> will force "^" to match only at the
+beginning of the string and "$" to match only at the end (or just before a
+newline at the end) of the string. Together, as /ms, they let the "." match
+any character whatsoever, while yet allowing "^" and "$" to match,
+respectively, just after and just before newlines within the string.
+
+=item x
+
+Extend your pattern's legibility by permitting whitespace and comments.
+
+=back
+
+These are usually written as "the C</x> modifier", even though the delimiter
+in question might not actually be a slash. In fact, any of these
+modifiers may also be embedded within the regular expression itself using
+the new C<(?...)> construct. See below.
+
+The C</x> modifier itself needs a little more explanation. It tells
+the regular expression parser to ignore whitespace that is neither
+backslashed nor within a character class. You can use this to break up
+your regular expression into (slightly) more readable parts. The C<#>
+character is also treated as a metacharacter introducing a comment,
+just as in ordinary Perl code. This also means that if you want real
+whitespace or C<#> characters in the pattern (outside of a character
+class, where they are unaffected by C</x>), that you'll either have to
+escape them or encode them using octal or hex escapes. Taken together,
+these features go a long way towards making Perl's regular expressions
+more readable. Note that you have to be careful not to include the
+pattern delimiter in the comment--perl has no way of knowing you did
+not intend to close the pattern early. See the C-comment deletion code
+in L<perlop>.
+
+=head2 Regular Expressions
+
+The patterns used in pattern matching are regular expressions such as
+those supplied in the Version 8 regex routines. (In fact, the
+routines are derived (distantly) from Henry Spencer's freely
+redistributable reimplementation of the V8 routines.)
+See L<Version 8 Regular Expressions> for details.
+
+In particular the following metacharacters have their standard I<egrep>-ish
+meanings:
+
+ \ Quote the next metacharacter
+ ^ Match the beginning of the line
+ . Match any character (except newline)
+ $ Match the end of the line (or before newline at the end)
+ | Alternation
+ () Grouping
+ [] Character class
+
+By default, the "^" character is guaranteed to match at only the
+beginning of the string, the "$" character at only the end (or before the
+newline at the end) and Perl does certain optimizations with the
+assumption that the string contains only one line. Embedded newlines
+will not be matched by "^" or "$". You may, however, wish to treat a
+string as a multi-line buffer, such that the "^" will match after any
+newline within the string, and "$" will match before any newline. At the
+cost of a little more overhead, you can do this by using the /m modifier
+on the pattern match operator. (Older programs did this by setting C<$*>,
+but this practice is now deprecated.)
+
+To facilitate multi-line substitutions, the "." character never matches a
+newline unless you use the C</s> modifier, which in effect tells Perl to pretend
+the string is a single line--even if it isn't. The C</s> modifier also
+overrides the setting of C<$*>, in case you have some (badly behaved) older
+code that sets it in another module.
+
+The following standard quantifiers are recognized:
+
+ * Match 0 or more times
+ + Match 1 or more times
+ ? Match 1 or 0 times
+ {n} Match exactly n times
+ {n,} Match at least n times
+ {n,m} Match at least n but not more than m times
+
+(If a curly bracket occurs in any other context, it is treated
+as a regular character.) The "*" modifier is equivalent to C<{0,}>, the "+"
+modifier to C<{1,}>, and the "?" modifier to C<{0,1}>. n and m are limited
+to integral values less than 65536.
+
+By default, a quantified subpattern is "greedy", that is, it will match as
+many times as possible (given a particular starting location) while still
+allowing the rest of the pattern to match. If you want it to match the
+minimum number of times possible, follow the quantifier with a "?". Note
+that the meanings don't change, just the "greediness":
+
+ *? Match 0 or more times
+ +? Match 1 or more times
+ ?? Match 0 or 1 time
+ {n}? Match exactly n times
+ {n,}? Match at least n times
+ {n,m}? Match at least n but not more than m times
+
+Because patterns are processed as double quoted strings, the following
+also work:
+
+ \t tab (HT, TAB)
+ \n newline (LF, NL)
+ \r return (CR)
+ \f form feed (FF)
+ \a alarm (bell) (BEL)
+ \e escape (think troff) (ESC)
+ \033 octal char (think of a PDP-11)
+ \x1B hex char
+ \c[ control char
+ \l lowercase next char (think vi)
+ \u uppercase next char (think vi)
+ \L lowercase till \E (think vi)
+ \U uppercase till \E (think vi)
+ \E end case modification (think vi)
+ \Q quote (disable) pattern metacharacters till \E
+
+If C<use locale> is in effect, the case map used by C<\l>, C<\L>, C<\u>
+and C<\U> is taken from the current locale. See L<perllocale>.
+
+You cannot include a literal C<$> or C<@> within a C<\Q> sequence.
+An unescaped C<$> or C<@> interpolates the corresponding variable,
+while escaping will cause the literal string C<\$> to be matched.
+You'll need to write something like C<m/\Quser\E\@\Qhost/>.
+
+In addition, Perl defines the following:
+
+ \w Match a "word" character (alphanumeric plus "_")
+ \W Match a non-word character
+ \s Match a whitespace character
+ \S Match a non-whitespace character
+ \d Match a digit character
+ \D Match a non-digit character
+
+A C<\w> matches a single alphanumeric character, not a whole
+word. To match a word you'd need to say C<\w+>. If C<use locale> is in
+effect, the list of alphabetic characters generated by C<\w> is taken
+from the current locale. See L<perllocale>. You may use C<\w>, C<\W>,
+C<\s>, C<\S>, C<\d>, and C<\D> within character classes (though not as
+either end of a range).
+
+Perl defines the following zero-width assertions:
+
+ \b Match a word boundary
+ \B Match a non-(word boundary)
+ \A Match only at beginning of string
+ \Z Match only at end of string, or before newline at the end
+ \z Match only at end of string
+ \G Match only where previous m//g left off (works only with /g)
+
+A word boundary (C<\b>) is defined as a spot between two characters that
+has a C<\w> on one side of it and a C<\W> on the other side of it (in
+either order), counting the imaginary characters off the beginning and
+end of the string as matching a C<\W>. (Within character classes C<\b>
+represents backspace rather than a word boundary.) The C<\A> and C<\Z> are
+just like "^" and "$", except that they won't match multiple times when the
+C</m> modifier is used, while "^" and "$" will match at every internal line
+boundary. To match the actual end of the string, not ignoring newline,
+you can use C<\z>. The C<\G> assertion can be used to chain global
+matches (using C<m//g>), as described in
+L<perlop/"Regexp Quote-Like Operators">.
+
+It is also useful when writing C<lex>-like scanners, when you have several
+patterns that you want to match against consequent substrings of your
+string, see the previous reference.
+The actual location where C<\G> will match can also be influenced
+by using C<pos()> as an lvalue. See L<perlfunc/pos>.
+
+When the bracketing construct C<( ... )> is used, \E<lt>digitE<gt> matches the
+digit'th substring. Outside of the pattern, always use "$" instead of "\"
+in front of the digit. (While the \E<lt>digitE<gt> notation can on rare occasion work
+outside the current pattern, this should not be relied upon. See the
+WARNING below.) The scope of $E<lt>digitE<gt> (and C<$`>, C<$&>, and C<$'>)
+extends to the end of the enclosing BLOCK or eval string, or to the next
+successful pattern match, whichever comes first. If you want to use
+parentheses to delimit a subpattern (e.g., a set of alternatives) without
+saving it as a subpattern, follow the ( with a ?:.
+
+You may have as many parentheses as you wish. If you have more
+than 9 substrings, the variables $10, $11, ... refer to the
+corresponding substring. Within the pattern, \10, \11, etc. refer back
+to substrings if there have been at least that many left parentheses before
+the backreference. Otherwise (for backward compatibility) \10 is the
+same as \010, a backspace, and \11 the same as \011, a tab. And so
+on. (\1 through \9 are always backreferences.)
+
+C<$+> returns whatever the last bracket match matched. C<$&> returns the
+entire matched string. (C<$0> used to return the same thing, but not any
+more.) C<$`> returns everything before the matched string. C<$'> returns
+everything after the matched string. Examples:
+
+ s/^([^ ]*) *([^ ]*)/$2 $1/; # swap first two words
+
+ if (/Time: (..):(..):(..)/) {
+ $hours = $1;
+ $minutes = $2;
+ $seconds = $3;
+ }
+
+Once perl sees that you need one of C<$&>, C<$`> or C<$'> anywhere in
+the program, it has to provide them on each and every pattern match.
+This can slow your program down. The same mechanism that handles
+these provides for the use of $1, $2, etc., so you pay the same price
+for each pattern that contains capturing parentheses. But if you never
+use $&, etc., in your script, then patterns I<without> capturing
+parentheses won't be penalized. So avoid $&, $', and $` if you can,
+but if you can't (and some algorithms really appreciate them), once
+you've used them once, use them at will, because you've already paid
+the price. As of 5.005, $& is not so costly as the other two.
+
+Backslashed metacharacters in Perl are
+alphanumeric, such as C<\b>, C<\w>, C<\n>. Unlike some other regular
+expression languages, there are no backslashed symbols that aren't
+alphanumeric. So anything that looks like \\, \(, \), \E<lt>, \E<gt>,
+\{, or \} is always interpreted as a literal character, not a
+metacharacter. This was once used in a common idiom to disable or
+quote the special meanings of regular expression metacharacters in a
+string that you want to use for a pattern. Simply quote all
+non-alphanumeric characters:
+
+ $pattern =~ s/(\W)/\\$1/g;
+
+Now it is much more common to see either the quotemeta() function or
+the C<\Q> escape sequence used to disable all metacharacters' special
+meanings like this:
+
+ /$unquoted\Q$quoted\E$unquoted/
+
+Perl defines a consistent extension syntax for regular expressions.
+The syntax is a pair of parentheses with a question mark as the first
+thing within the parentheses (this was a syntax error in older
+versions of Perl). The character after the question mark gives the
+function of the extension. Several extensions are already supported:
+
+=over 10
+
+=item C<(?#text)>
+
+A comment. The text is ignored. If the C</x> switch is used to enable
+whitespace formatting, a simple C<#> will suffice. Note that perl closes
+the comment as soon as it sees a C<)>, so there is no way to put a literal
+C<)> in the comment.
+
+=item C<(?:pattern)>
+
+=item C<(?imsx-imsx:pattern)>
+
+This is for clustering, not capturing; it groups subexpressions like
+"()", but doesn't make backreferences as "()" does. So
+
+ @fields = split(/\b(?:a|b|c)\b/)
+
+is like
+
+ @fields = split(/\b(a|b|c)\b/)
+
+but doesn't spit out extra fields.
+
+The letters between C<?> and C<:> act as flags modifiers, see
+L<C<(?imsx-imsx)>>. In particular,
+
+ /(?s-i:more.*than).*million/i
+
+is equivalent to more verbose
+
+ /(?:(?s-i)more.*than).*million/i
+
+=item C<(?=pattern)>
+
+A zero-width positive lookahead assertion. For example, C</\w+(?=\t)/>
+matches a word followed by a tab, without including the tab in C<$&>.
+
+=item C<(?!pattern)>
+
+A zero-width negative lookahead assertion. For example C</foo(?!bar)/>
+matches any occurrence of "foo" that isn't followed by "bar". Note
+however that lookahead and lookbehind are NOT the same thing. You cannot
+use this for lookbehind.
+
+If you are looking for a "bar" that isn't preceded by a "foo", C</(?!foo)bar/>
+will not do what you want. That's because the C<(?!foo)> is just saying that
+the next thing cannot be "foo"--and it's not, it's a "bar", so "foobar" will
+match. You would have to do something like C</(?!foo)...bar/> for that. We
+say "like" because there's the case of your "bar" not having three characters
+before it. You could cover that this way: C</(?:(?!foo)...|^.{0,2})bar/>.
+Sometimes it's still easier just to say:
+
+ if (/bar/ && $` !~ /foo$/)
+
+For lookbehind see below.
+
+=item C<(?E<lt>=pattern)>
+
+A zero-width positive lookbehind assertion. For example, C</(?E<lt>=\t)\w+/>
+matches a word following a tab, without including the tab in C<$&>.
+Works only for fixed-width lookbehind.
+
+=item C<(?<!pattern)>
+
+A zero-width negative lookbehind assertion. For example C</(?<!bar)foo/>
+matches any occurrence of "foo" that isn't following "bar".
+Works only for fixed-width lookbehind.
+
+=item C<(?{ code })>
+
+Experimental "evaluate any Perl code" zero-width assertion. Always
+succeeds. C<code> is not interpolated. Currently the rules to
+determine where the C<code> ends are somewhat convoluted.
+
+The C<code> is properly scoped in the following sense: if the assertion
+is backtracked (compare L<"Backtracking">), all the changes introduced after
+C<local>isation are undone, so
+
+ $_ = 'a' x 8;
+ m<
+ (?{ $cnt = 0 }) # Initialize $cnt.
+ (
+ a
+ (?{
+ local $cnt = $cnt + 1; # Update $cnt, backtracking-safe.
+ })
+ )*
+ aaaa
+ (?{ $res = $cnt }) # On success copy to non-localized
+ # location.
+ >x;
+
+will set C<$res = 4>. Note that after the match $cnt returns to the globally
+introduced value 0, since the scopes which restrict C<local> statements
+are unwound.
+
+This assertion may be used as L<C<(?(condition)yes-pattern|no-pattern)>>
+switch. If I<not> used in this way, the result of evaluation of C<code>
+is put into variable $^R. This happens immediately, so $^R can be used from
+other C<(?{ code })> assertions inside the same regular expression.
+
+The above assignment to $^R is properly localized, thus the old value of $^R
+is restored if the assertion is backtracked (compare L<"Backtracking">).
+
+Due to security concerns, this construction is not allowed if the regular
+expression involves run-time interpolation of variables, unless
+C<use re 'eval'> pragma is used (see L<re>), or the variables contain
+results of qr() operator (see L<perlop/"qr/STRING/imosx">).
+
+This restriction is due to the wide-spread (questionable) practice of
+using the construct
+
+ $re = <>;
+ chomp $re;
+ $string =~ /$re/;
+
+without tainting. While this code is frowned upon from security point
+of view, when C<(?{})> was introduced, it was considered bad to add
+I<new> security holes to existing scripts.
+
+B<NOTE:> Use of the above insecure snippet without also enabling taint mode
+is to be severely frowned upon. C<use re 'eval'> does not disable tainting
+checks, thus to allow $re in the above snippet to contain C<(?{})>
+I<with tainting enabled>, one needs both C<use re 'eval'> and untaint
+the $re.
+
+=item C<(?E<gt>pattern)>
+
+An "independent" subexpression. Matches the substring that a
+I<standalone> C<pattern> would match if anchored at the given position,
+B<and only this substring>.
+
+Say, C<^(?E<gt>a*)ab> will never match, since C<(?E<gt>a*)> (anchored
+at the beginning of string, as above) will match I<all> characters
+C<a> at the beginning of string, leaving no C<a> for C<ab> to match.
+In contrast, C<a*ab> will match the same as C<a+b>, since the match of
+the subgroup C<a*> is influenced by the following group C<ab> (see
+L<"Backtracking">). In particular, C<a*> inside C<a*ab> will match
+fewer characters than a standalone C<a*>, since this makes the tail match.
+
+An effect similar to C<(?E<gt>pattern)> may be achieved by
+
+ (?=(pattern))\1
+
+since the lookahead is in I<"logical"> context, thus matches the same
+substring as a standalone C<a+>. The following C<\1> eats the matched
+string, thus making a zero-length assertion into an analogue of
+C<(?E<gt>...)>. (The difference between these two constructs is that the
+second one uses a catching group, thus shifting ordinals of
+backreferences in the rest of a regular expression.)
+
+This construct is useful for optimizations of "eternal"
+matches, because it will not backtrack (see L<"Backtracking">).
+
+ m{ \(
+ (
+ [^()]+
+ |
+ \( [^()]* \)
+ )+
+ \)
+ }x
+
+That will efficiently match a nonempty group with matching
+two-or-less-level-deep parentheses. However, if there is no such group,
+it will take virtually forever on a long string. That's because there are
+so many different ways to split a long string into several substrings.
+This is what C<(.+)+> is doing, and C<(.+)+> is similar to a subpattern
+of the above pattern. Consider that the above pattern detects no-match
+on C<((()aaaaaaaaaaaaaaaaaa> in several seconds, but that each extra
+letter doubles this time. This exponential performance will make it
+appear that your program has hung.
+
+However, a tiny modification of this pattern
+
+ m{ \(
+ (
+ (?> [^()]+ )
+ |
+ \( [^()]* \)
+ )+
+ \)
+ }x
+
+which uses C<(?E<gt>...)> matches exactly when the one above does (verifying
+this yourself would be a productive exercise), but finishes in a fourth
+the time when used on a similar string with 1000000 C<a>s. Be aware,
+however, that this pattern currently triggers a warning message under
+B<-w> saying it C<"matches the null string many times">):
+
+On simple groups, such as the pattern C<(?> [^()]+ )>, a comparable
+effect may be achieved by negative lookahead, as in C<[^()]+ (?! [^()] )>.
+This was only 4 times slower on a string with 1000000 C<a>s.
+
+=item C<(?(condition)yes-pattern|no-pattern)>
+
+=item C<(?(condition)yes-pattern)>
+
+Conditional expression. C<(condition)> should be either an integer in
+parentheses (which is valid if the corresponding pair of parentheses
+matched), or lookahead/lookbehind/evaluate zero-width assertion.
+
+Say,
+
+ m{ ( \( )?
+ [^()]+
+ (?(1) \) )
+ }x
+
+matches a chunk of non-parentheses, possibly included in parentheses
+themselves.
+
+=item C<(?imsx-imsx)>
+
+One or more embedded pattern-match modifiers. This is particularly
+useful for patterns that are specified in a table somewhere, some of
+which want to be case sensitive, and some of which don't. The case
+insensitive ones need to include merely C<(?i)> at the front of the
+pattern. For example:
+
+ $pattern = "foobar";
+ if ( /$pattern/i ) { }
+
+ # more flexible:
+
+ $pattern = "(?i)foobar";
+ if ( /$pattern/ ) { }
+
+Letters after C<-> switch modifiers off.
+
+These modifiers are localized inside an enclosing group (if any). Say,
+
+ ( (?i) blah ) \s+ \1
+
+(assuming C<x> modifier, and no C<i> modifier outside of this group)
+will match a repeated (I<including the case>!) word C<blah> in any
+case.
+
+=back
+
+A question mark was chosen for this and for the new minimal-matching
+construct because 1) question mark is pretty rare in older regular
+expressions, and 2) whenever you see one, you should stop and "question"
+exactly what is going on. That's psychology...
+
+=head2 Backtracking
+
+A fundamental feature of regular expression matching involves the
+notion called I<backtracking>, which is currently used (when needed)
+by all regular expression quantifiers, namely C<*>, C<*?>, C<+>,
+C<+?>, C<{n,m}>, and C<{n,m}?>.
+
+For a regular expression to match, the I<entire> regular expression must
+match, not just part of it. So if the beginning of a pattern containing a
+quantifier succeeds in a way that causes later parts in the pattern to
+fail, the matching engine backs up and recalculates the beginning
+part--that's why it's called backtracking.
+
+Here is an example of backtracking: Let's say you want to find the
+word following "foo" in the string "Food is on the foo table.":
+
+ $_ = "Food is on the foo table.";
+ if ( /\b(foo)\s+(\w+)/i ) {
+ print "$2 follows $1.\n";
+ }
+
+When the match runs, the first part of the regular expression (C<\b(foo)>)
+finds a possible match right at the beginning of the string, and loads up
+$1 with "Foo". However, as soon as the matching engine sees that there's
+no whitespace following the "Foo" that it had saved in $1, it realizes its
+mistake and starts over again one character after where it had the
+tentative match. This time it goes all the way until the next occurrence
+of "foo". The complete regular expression matches this time, and you get
+the expected output of "table follows foo."
+
+Sometimes minimal matching can help a lot. Imagine you'd like to match
+everything between "foo" and "bar". Initially, you write something
+like this:
+
+ $_ = "The food is under the bar in the barn.";
+ if ( /foo(.*)bar/ ) {
+ print "got <$1>\n";
+ }
+
+Which perhaps unexpectedly yields:
+
+ got <d is under the bar in the >
+
+That's because C<.*> was greedy, so you get everything between the
+I<first> "foo" and the I<last> "bar". In this case, it's more effective
+to use minimal matching to make sure you get the text between a "foo"
+and the first "bar" thereafter.
+
+ if ( /foo(.*?)bar/ ) { print "got <$1>\n" }
+ got <d is under the >
+
+Here's another example: let's say you'd like to match a number at the end
+of a string, and you also want to keep the preceding part the match.
+So you write this:
+
+ $_ = "I have 2 numbers: 53147";
+ if ( /(.*)(\d*)/ ) { # Wrong!
+ print "Beginning is <$1>, number is <$2>.\n";
+ }
+
+That won't work at all, because C<.*> was greedy and gobbled up the
+whole string. As C<\d*> can match on an empty string the complete
+regular expression matched successfully.
+
+ Beginning is <I have 2 numbers: 53147>, number is <>.
+
+Here are some variants, most of which don't work:
+
+ $_ = "I have 2 numbers: 53147";
+ @pats = qw{
+ (.*)(\d*)
+ (.*)(\d+)
+ (.*?)(\d*)
+ (.*?)(\d+)
+ (.*)(\d+)$
+ (.*?)(\d+)$
+ (.*)\b(\d+)$
+ (.*\D)(\d+)$
+ };
+
+ for $pat (@pats) {
+ printf "%-12s ", $pat;
+ if ( /$pat/ ) {
+ print "<$1> <$2>\n";
+ } else {
+ print "FAIL\n";
+ }
+ }
+
+That will print out:
+
+ (.*)(\d*) <I have 2 numbers: 53147> <>
+ (.*)(\d+) <I have 2 numbers: 5314> <7>
+ (.*?)(\d*) <> <>
+ (.*?)(\d+) <I have > <2>
+ (.*)(\d+)$ <I have 2 numbers: 5314> <7>
+ (.*?)(\d+)$ <I have 2 numbers: > <53147>
+ (.*)\b(\d+)$ <I have 2 numbers: > <53147>
+ (.*\D)(\d+)$ <I have 2 numbers: > <53147>
+
+As you see, this can be a bit tricky. It's important to realize that a
+regular expression is merely a set of assertions that gives a definition
+of success. There may be 0, 1, or several different ways that the
+definition might succeed against a particular string. And if there are
+multiple ways it might succeed, you need to understand backtracking to
+know which variety of success you will achieve.
+
+When using lookahead assertions and negations, this can all get even
+tricker. Imagine you'd like to find a sequence of non-digits not
+followed by "123". You might try to write that as
+
+ $_ = "ABC123";
+ if ( /^\D*(?!123)/ ) { # Wrong!
+ print "Yup, no 123 in $_\n";
+ }
+
+But that isn't going to match; at least, not the way you're hoping. It
+claims that there is no 123 in the string. Here's a clearer picture of
+why it that pattern matches, contrary to popular expectations:
+
+ $x = 'ABC123' ;
+ $y = 'ABC445' ;
+
+ print "1: got $1\n" if $x =~ /^(ABC)(?!123)/ ;
+ print "2: got $1\n" if $y =~ /^(ABC)(?!123)/ ;
+
+ print "3: got $1\n" if $x =~ /^(\D*)(?!123)/ ;
+ print "4: got $1\n" if $y =~ /^(\D*)(?!123)/ ;
+
+This prints
+
+ 2: got ABC
+ 3: got AB
+ 4: got ABC
+
+You might have expected test 3 to fail because it seems to a more
+general purpose version of test 1. The important difference between
+them is that test 3 contains a quantifier (C<\D*>) and so can use
+backtracking, whereas test 1 will not. What's happening is
+that you've asked "Is it true that at the start of $x, following 0 or more
+non-digits, you have something that's not 123?" If the pattern matcher had
+let C<\D*> expand to "ABC", this would have caused the whole pattern to
+fail.
+The search engine will initially match C<\D*> with "ABC". Then it will
+try to match C<(?!123> with "123", which of course fails. But because
+a quantifier (C<\D*>) has been used in the regular expression, the
+search engine can backtrack and retry the match differently
+in the hope of matching the complete regular expression.
+
+The pattern really, I<really> wants to succeed, so it uses the
+standard pattern back-off-and-retry and lets C<\D*> expand to just "AB" this
+time. Now there's indeed something following "AB" that is not
+"123". It's in fact "C123", which suffices.
+
+We can deal with this by using both an assertion and a negation. We'll
+say that the first part in $1 must be followed by a digit, and in fact, it
+must also be followed by something that's not "123". Remember that the
+lookaheads are zero-width expressions--they only look, but don't consume
+any of the string in their match. So rewriting this way produces what
+you'd expect; that is, case 5 will fail, but case 6 succeeds:
+
+ print "5: got $1\n" if $x =~ /^(\D*)(?=\d)(?!123)/ ;
+ print "6: got $1\n" if $y =~ /^(\D*)(?=\d)(?!123)/ ;
+
+ 6: got ABC
+
+In other words, the two zero-width assertions next to each other work as though
+they're ANDed together, just as you'd use any builtin assertions: C</^$/>
+matches only if you're at the beginning of the line AND the end of the
+line simultaneously. The deeper underlying truth is that juxtaposition in
+regular expressions always means AND, except when you write an explicit OR
+using the vertical bar. C</ab/> means match "a" AND (then) match "b",
+although the attempted matches are made at different positions because "a"
+is not a zero-width assertion, but a one-width assertion.
+
+One warning: particularly complicated regular expressions can take
+exponential time to solve due to the immense number of possible ways they
+can use backtracking to try match. For example this will take a very long
+time to run
+
+ /((a{0,5}){0,5}){0,5}/
+
+And if you used C<*>'s instead of limiting it to 0 through 5 matches, then
+it would take literally forever--or until you ran out of stack space.
+
+A powerful tool for optimizing such beasts is "independent" groups,
+which do not backtrace (see L<C<(?E<gt>pattern)>>). Note also that
+zero-length lookahead/lookbehind assertions will not backtrace to make
+the tail match, since they are in "logical" context: only the fact
+whether they match or not is considered relevant. For an example
+where side-effects of a lookahead I<might> have influenced the
+following match, see L<C<(?E<gt>pattern)>>.
+
+=head2 Version 8 Regular Expressions
+
+In case you're not familiar with the "regular" Version 8 regex
+routines, here are the pattern-matching rules not described above.
+
+Any single character matches itself, unless it is a I<metacharacter>
+with a special meaning described here or above. You can cause
+characters that normally function as metacharacters to be interpreted
+literally by prefixing them with a "\" (e.g., "\." matches a ".", not any
+character; "\\" matches a "\"). A series of characters matches that
+series of characters in the target string, so the pattern C<blurfl>
+would match "blurfl" in the target string.
+
+You can specify a character class, by enclosing a list of characters
+in C<[]>, which will match any one character from the list. If the
+first character after the "[" is "^", the class matches any character not
+in the list. Within a list, the "-" character is used to specify a
+range, so that C<a-z> represents all characters between "a" and "z",
+inclusive. If you want "-" itself to be a member of a class, put it
+at the start or end of the list, or escape it with a backslash. (The
+following all specify the same class of three characters: C<[-az]>,
+C<[az-]>, and C<[a\-z]>. All are different from C<[a-z]>, which
+specifies a class containing twenty-six characters.)
+
+Characters may be specified using a metacharacter syntax much like that
+used in C: "\n" matches a newline, "\t" a tab, "\r" a carriage return,
+"\f" a form feed, etc. More generally, \I<nnn>, where I<nnn> is a string
+of octal digits, matches the character whose ASCII value is I<nnn>.
+Similarly, \xI<nn>, where I<nn> are hexadecimal digits, matches the
+character whose ASCII value is I<nn>. The expression \cI<x> matches the
+ASCII character control-I<x>. Finally, the "." metacharacter matches any
+character except "\n" (unless you use C</s>).
+
+You can specify a series of alternatives for a pattern using "|" to
+separate them, so that C<fee|fie|foe> will match any of "fee", "fie",
+or "foe" in the target string (as would C<f(e|i|o)e>). The
+first alternative includes everything from the last pattern delimiter
+("(", "[", or the beginning of the pattern) up to the first "|", and
+the last alternative contains everything from the last "|" to the next
+pattern delimiter. For this reason, it's common practice to include
+alternatives in parentheses, to minimize confusion about where they
+start and end.
+
+Alternatives are tried from left to right, so the first
+alternative found for which the entire expression matches, is the one that
+is chosen. This means that alternatives are not necessarily greedy. For
+example: when mathing C<foo|foot> against "barefoot", only the "foo"
+part will match, as that is the first alternative tried, and it successfully
+matches the target string. (This might not seem important, but it is
+important when you are capturing matched text using parentheses.)
+
+Also remember that "|" is interpreted as a literal within square brackets,
+so if you write C<[fee|fie|foe]> you're really only matching C<[feio|]>.
+
+Within a pattern, you may designate subpatterns for later reference by
+enclosing them in parentheses, and you may refer back to the I<n>th
+subpattern later in the pattern using the metacharacter \I<n>.
+Subpatterns are numbered based on the left to right order of their
+opening parenthesis. A backreference matches whatever
+actually matched the subpattern in the string being examined, not the
+rules for that subpattern. Therefore, C<(0|0x)\d*\s\1\d*> will
+match "0x1234 0x4321", but not "0x1234 01234", because subpattern 1
+actually matched "0x", even though the rule C<0|0x> could
+potentially match the leading 0 in the second number.
+
+=head2 WARNING on \1 vs $1
+
+Some people get too used to writing things like:
+
+ $pattern =~ s/(\W)/\\\1/g;
+
+This is grandfathered for the RHS of a substitute to avoid shocking the
+B<sed> addicts, but it's a dirty habit to get into. That's because in
+PerlThink, the righthand side of a C<s///> is a double-quoted string. C<\1> in
+the usual double-quoted string means a control-A. The customary Unix
+meaning of C<\1> is kludged in for C<s///>. However, if you get into the habit
+of doing that, you get yourself into trouble if you then add an C</e>
+modifier.
+
+ s/(\d+)/ \1 + 1 /eg; # causes warning under -w
+
+Or if you try to do
+
+ s/(\d+)/\1000/;
+
+You can't disambiguate that by saying C<\{1}000>, whereas you can fix it with
+C<${1}000>. Basically, the operation of interpolation should not be confused
+with the operation of matching a backreference. Certainly they mean two
+different things on the I<left> side of the C<s///>.
+
+=head2 Repeated patterns matching zero-length substring
+
+WARNING: Difficult material (and prose) ahead. This section needs a rewrite.
+
+Regular expressions provide a terse and powerful programming language. As
+with most other power tools, power comes together with the ability
+to wreak havoc.
+
+A common abuse of this power stems from the ability to make infinite
+loops using regular expressions, with something as innocous as:
+
+ 'foo' =~ m{ ( o? )* }x;
+
+The C<o?> can match at the beginning of C<'foo'>, and since the position
+in the string is not moved by the match, C<o?> would match again and again
+due to the C<*> modifier. Another common way to create a similar cycle
+is with the looping modifier C<//g>:
+
+ @matches = ( 'foo' =~ m{ o? }xg );
+
+or
+
+ print "match: <$&>\n" while 'foo' =~ m{ o? }xg;
+
+or the loop implied by split().
+
+However, long experience has shown that many programming tasks may
+be significantly simplified by using repeated subexpressions which
+may match zero-length substrings, with a simple example being:
+
+ @chars = split //, $string; # // is not magic in split
+ ($whitewashed = $string) =~ s/()/ /g; # parens avoid magic s// /
+
+Thus Perl allows the C</()/> construct, which I<forcefully breaks
+the infinite loop>. The rules for this are different for lower-level
+loops given by the greedy modifiers C<*+{}>, and for higher-level
+ones like the C</g> modifier or split() operator.
+
+The lower-level loops are I<interrupted> when it is detected that a
+repeated expression did match a zero-length substring, thus
+
+ m{ (?: NON_ZERO_LENGTH | ZERO_LENGTH )* }x;
+
+is made equivalent to
+
+ m{ (?: NON_ZERO_LENGTH )*
+ |
+ (?: ZERO_LENGTH )?
+ }x;
+
+The higher level-loops preserve an additional state between iterations:
+whether the last match was zero-length. To break the loop, the following
+match after a zero-length match is prohibited to have a length of zero.
+This prohibition interacts with backtracking (see L<"Backtracking">),
+and so the I<second best> match is chosen if the I<best> match is of
+zero length.
+
+Say,
+
+ $_ = 'bar';
+ s/\w??/<$&>/g;
+
+results in C<"<><b><><a><><r><>">. At each position of the string the best
+match given by non-greedy C<??> is the zero-length match, and the I<second
+best> match is what is matched by C<\w>. Thus zero-length matches
+alternate with one-character-long matches.
+
+Similarly, for repeated C<m/()/g> the second-best match is the match at the
+position one notch further in the string.
+
+The additional state of being I<matched with zero-length> is associated to
+the matched string, and is reset by each assignment to pos().
+
+=head2 Creating custom RE engines
+
+Overloaded constants (see L<overload>) provide a simple way to extend
+the functionality of the RE engine.
+
+Suppose that we want to enable a new RE escape-sequence C<\Y|> which
+matches at boundary between white-space characters and non-whitespace
+characters. Note that C<(?=\S)(?<!\S)|(?!\S)(?<=\S)> matches exactly
+at these positions, so we want to have each C<\Y|> in the place of the
+more complicated version. We can create a module C<customre> to do
+this:
+
+ package customre;
+ use overload;
+
+ sub import {
+ shift;
+ die "No argument to customre::import allowed" if @_;
+ overload::constant 'qr' => \&convert;
+ }
+
+ sub invalid { die "/$_[0]/: invalid escape '\\$_[1]'"}
+
+ my %rules = ( '\\' => '\\',
+ 'Y|' => qr/(?=\S)(?<!\S)|(?!\S)(?<=\S)/ );
+ sub convert {
+ my $re = shift;
+ $re =~ s{
+ \\ ( \\ | Y . )
+ }
+ { $rules{$1} or invalid($re,$1) }sgex;
+ return $re;
+ }
+
+Now C<use customre> enables the new escape in constant regular
+expressions, i.e., those without any runtime variable interpolations.
+As documented in L<overload>, this conversion will work only over
+literal parts of regular expressions. For C<\Y|$re\Y|> the variable
+part of this regular expression needs to be converted explicitly
+(but only if the special meaning of C<\Y|> should be enabled inside $re):
+
+ use customre;
+ $re = <>;
+ chomp $re;
+ $re = customre::convert $re;
+ /\Y|$re\Y|/;
+
+=head2 SEE ALSO
+
+L<perlop/"Regexp Quote-Like Operators">.
+
+L<perlop/"Gory details of parsing quoted constructs">.
+
+L<perlfunc/pos>.
+
+L<perllocale>.
+
+I<Mastering Regular Expressions> (see L<perlbook>) by Jeffrey Friedl.
diff --git a/contrib/perl5/pod/perlref.pod b/contrib/perl5/pod/perlref.pod
new file mode 100644
index 0000000..66b1a7d
--- /dev/null
+++ b/contrib/perl5/pod/perlref.pod
@@ -0,0 +1,646 @@
+=head1 NAME
+
+perlref - Perl references and nested data structures
+
+=head1 DESCRIPTION
+
+Before release 5 of Perl it was difficult to represent complex data
+structures, because all references had to be symbolic--and even then
+it was difficult to refer to a variable instead of a symbol table entry.
+Perl now not only makes it easier to use symbolic references to variables,
+but also lets you have "hard" references to any piece of data or code.
+Any scalar may hold a hard reference. Because arrays and hashes contain
+scalars, you can now easily build arrays of arrays, arrays of hashes,
+hashes of arrays, arrays of hashes of functions, and so on.
+
+Hard references are smart--they keep track of reference counts for you,
+automatically freeing the thing referred to when its reference count goes
+to zero. (Note: the reference counts for values in self-referential or
+cyclic data structures may not go to zero without a little help; see
+L<perlobj/"Two-Phased Garbage Collection"> for a detailed explanation.)
+If that thing happens to be an object, the object is destructed. See
+L<perlobj> for more about objects. (In a sense, everything in Perl is an
+object, but we usually reserve the word for references to objects that
+have been officially "blessed" into a class package.)
+
+Symbolic references are names of variables or other objects, just as a
+symbolic link in a Unix filesystem contains merely the name of a file.
+The C<*glob> notation is a kind of symbolic reference. (Symbolic
+references are sometimes called "soft references", but please don't call
+them that; references are confusing enough without useless synonyms.)
+
+In contrast, hard references are more like hard links in a Unix file
+system: They are used to access an underlying object without concern for
+what its (other) name is. When the word "reference" is used without an
+adjective, as in the following paragraph, it is usually talking about a
+hard reference.
+
+References are easy to use in Perl. There is just one overriding
+principle: Perl does no implicit referencing or dereferencing. When a
+scalar is holding a reference, it always behaves as a simple scalar. It
+doesn't magically start being an array or hash or subroutine; you have to
+tell it explicitly to do so, by dereferencing it.
+
+=head2 Making References
+
+References can be created in several ways.
+
+=over 4
+
+=item 1.
+
+By using the backslash operator on a variable, subroutine, or value.
+(This works much like the & (address-of) operator in C.) Note
+that this typically creates I<ANOTHER> reference to a variable, because
+there's already a reference to the variable in the symbol table. But
+the symbol table reference might go away, and you'll still have the
+reference that the backslash returned. Here are some examples:
+
+ $scalarref = \$foo;
+ $arrayref = \@ARGV;
+ $hashref = \%ENV;
+ $coderef = \&handler;
+ $globref = \*foo;
+
+It isn't possible to create a true reference to an IO handle (filehandle
+or dirhandle) using the backslash operator. The most you can get is a
+reference to a typeglob, which is actually a complete symbol table entry.
+But see the explanation of the C<*foo{THING}> syntax below. However,
+you can still use type globs and globrefs as though they were IO handles.
+
+=item 2.
+
+A reference to an anonymous array can be created using square
+brackets:
+
+ $arrayref = [1, 2, ['a', 'b', 'c']];
+
+Here we've created a reference to an anonymous array of three elements
+whose final element is itself a reference to another anonymous array of three
+elements. (The multidimensional syntax described later can be used to
+access this. For example, after the above, C<$arrayref-E<gt>[2][1]> would have
+the value "b".)
+
+Note that taking a reference to an enumerated list is not the same
+as using square brackets--instead it's the same as creating
+a list of references!
+
+ @list = (\$a, \@b, \%c);
+ @list = \($a, @b, %c); # same thing!
+
+As a special case, C<\(@foo)> returns a list of references to the contents
+of C<@foo>, not a reference to C<@foo> itself. Likewise for C<%foo>.
+
+=item 3.
+
+A reference to an anonymous hash can be created using curly
+brackets:
+
+ $hashref = {
+ 'Adam' => 'Eve',
+ 'Clyde' => 'Bonnie',
+ };
+
+Anonymous hash and array composers like these can be intermixed freely to
+produce as complicated a structure as you want. The multidimensional
+syntax described below works for these too. The values above are
+literals, but variables and expressions would work just as well, because
+assignment operators in Perl (even within local() or my()) are executable
+statements, not compile-time declarations.
+
+Because curly brackets (braces) are used for several other things
+including BLOCKs, you may occasionally have to disambiguate braces at the
+beginning of a statement by putting a C<+> or a C<return> in front so
+that Perl realizes the opening brace isn't starting a BLOCK. The economy and
+mnemonic value of using curlies is deemed worth this occasional extra
+hassle.
+
+For example, if you wanted a function to make a new hash and return a
+reference to it, you have these options:
+
+ sub hashem { { @_ } } # silently wrong
+ sub hashem { +{ @_ } } # ok
+ sub hashem { return { @_ } } # ok
+
+On the other hand, if you want the other meaning, you can do this:
+
+ sub showem { { @_ } } # ambiguous (currently ok, but may change)
+ sub showem { {; @_ } } # ok
+ sub showem { { return @_ } } # ok
+
+Note how the leading C<+{> and C<{;> always serve to disambiguate
+the expression to mean either the HASH reference, or the BLOCK.
+
+=item 4.
+
+A reference to an anonymous subroutine can be created by using
+C<sub> without a subname:
+
+ $coderef = sub { print "Boink!\n" };
+
+Note the presence of the semicolon. Except for the fact that the code
+inside isn't executed immediately, a C<sub {}> is not so much a
+declaration as it is an operator, like C<do{}> or C<eval{}>. (However, no
+matter how many times you execute that particular line (unless you're in an
+C<eval("...")>), C<$coderef> will still have a reference to the I<SAME>
+anonymous subroutine.)
+
+Anonymous subroutines act as closures with respect to my() variables,
+that is, variables visible lexically within the current scope. Closure
+is a notion out of the Lisp world that says if you define an anonymous
+function in a particular lexical context, it pretends to run in that
+context even when it's called outside of the context.
+
+In human terms, it's a funny way of passing arguments to a subroutine when
+you define it as well as when you call it. It's useful for setting up
+little bits of code to run later, such as callbacks. You can even
+do object-oriented stuff with it, though Perl already provides a different
+mechanism to do that--see L<perlobj>.
+
+You can also think of closure as a way to write a subroutine template without
+using eval. (In fact, in version 5.000, eval was the I<only> way to get
+closures. You may wish to use "require 5.001" if you use closures.)
+
+Here's a small example of how closures works:
+
+ sub newprint {
+ my $x = shift;
+ return sub { my $y = shift; print "$x, $y!\n"; };
+ }
+ $h = newprint("Howdy");
+ $g = newprint("Greetings");
+
+ # Time passes...
+
+ &$h("world");
+ &$g("earthlings");
+
+This prints
+
+ Howdy, world!
+ Greetings, earthlings!
+
+Note particularly that $x continues to refer to the value passed into
+newprint() I<despite> the fact that the "my $x" has seemingly gone out of
+scope by the time the anonymous subroutine runs. That's what closure
+is all about.
+
+This applies only to lexical variables, by the way. Dynamic variables
+continue to work as they have always worked. Closure is not something
+that most Perl programmers need trouble themselves about to begin with.
+
+=item 5.
+
+References are often returned by special subroutines called constructors.
+Perl objects are just references to a special kind of object that happens to know
+which package it's associated with. Constructors are just special
+subroutines that know how to create that association. They do so by
+starting with an ordinary reference, and it remains an ordinary reference
+even while it's also being an object. Constructors are often
+named new() and called indirectly:
+
+ $objref = new Doggie (Tail => 'short', Ears => 'long');
+
+But don't have to be:
+
+ $objref = Doggie->new(Tail => 'short', Ears => 'long');
+
+ use Term::Cap;
+ $terminal = Term::Cap->Tgetent( { OSPEED => 9600 });
+
+ use Tk;
+ $main = MainWindow->new();
+ $menubar = $main->Frame(-relief => "raised",
+ -borderwidth => 2)
+
+=item 6.
+
+References of the appropriate type can spring into existence if you
+dereference them in a context that assumes they exist. Because we haven't
+talked about dereferencing yet, we can't show you any examples yet.
+
+=item 7.
+
+A reference can be created by using a special syntax, lovingly known as
+the *foo{THING} syntax. *foo{THING} returns a reference to the THING
+slot in *foo (which is the symbol table entry which holds everything
+known as foo).
+
+ $scalarref = *foo{SCALAR};
+ $arrayref = *ARGV{ARRAY};
+ $hashref = *ENV{HASH};
+ $coderef = *handler{CODE};
+ $ioref = *STDIN{IO};
+ $globref = *foo{GLOB};
+
+All of these are self-explanatory except for *foo{IO}. It returns the
+IO handle, used for file handles (L<perlfunc/open>), sockets
+(L<perlfunc/socket> and L<perlfunc/socketpair>), and directory handles
+(L<perlfunc/opendir>). For compatibility with previous versions of
+Perl, *foo{FILEHANDLE} is a synonym for *foo{IO}.
+
+*foo{THING} returns undef if that particular THING hasn't been used yet,
+except in the case of scalars. *foo{SCALAR} returns a reference to an
+anonymous scalar if $foo hasn't been used yet. This might change in a
+future release.
+
+*foo{IO} is an alternative to the \*HANDLE mechanism given in
+L<perldata/"Typeglobs and Filehandles"> for passing filehandles
+into or out of subroutines, or storing into larger data structures.
+Its disadvantage is that it won't create a new filehandle for you.
+Its advantage is that you have no risk of clobbering more than you want
+to with a typeglob assignment, although if you assign to a scalar instead
+of a typeglob, you're ok.
+
+ splutter(*STDOUT);
+ splutter(*STDOUT{IO});
+
+ sub splutter {
+ my $fh = shift;
+ print $fh "her um well a hmmm\n";
+ }
+
+ $rec = get_rec(*STDIN);
+ $rec = get_rec(*STDIN{IO});
+
+ sub get_rec {
+ my $fh = shift;
+ return scalar <$fh>;
+ }
+
+=back
+
+=head2 Using References
+
+That's it for creating references. By now you're probably dying to
+know how to use references to get back to your long-lost data. There
+are several basic methods.
+
+=over 4
+
+=item 1.
+
+Anywhere you'd put an identifier (or chain of identifiers) as part
+of a variable or subroutine name, you can replace the identifier with
+a simple scalar variable containing a reference of the correct type:
+
+ $bar = $$scalarref;
+ push(@$arrayref, $filename);
+ $$arrayref[0] = "January";
+ $$hashref{"KEY"} = "VALUE";
+ &$coderef(1,2,3);
+ print $globref "output\n";
+
+It's important to understand that we are specifically I<NOT> dereferencing
+C<$arrayref[0]> or C<$hashref{"KEY"}> there. The dereference of the
+scalar variable happens I<BEFORE> it does any key lookups. Anything more
+complicated than a simple scalar variable must use methods 2 or 3 below.
+However, a "simple scalar" includes an identifier that itself uses method
+1 recursively. Therefore, the following prints "howdy".
+
+ $refrefref = \\\"howdy";
+ print $$$$refrefref;
+
+=item 2.
+
+Anywhere you'd put an identifier (or chain of identifiers) as part of a
+variable or subroutine name, you can replace the identifier with a
+BLOCK returning a reference of the correct type. In other words, the
+previous examples could be written like this:
+
+ $bar = ${$scalarref};
+ push(@{$arrayref}, $filename);
+ ${$arrayref}[0] = "January";
+ ${$hashref}{"KEY"} = "VALUE";
+ &{$coderef}(1,2,3);
+ $globref->print("output\n"); # iff IO::Handle is loaded
+
+Admittedly, it's a little silly to use the curlies in this case, but
+the BLOCK can contain any arbitrary expression, in particular,
+subscripted expressions:
+
+ &{ $dispatch{$index} }(1,2,3); # call correct routine
+
+Because of being able to omit the curlies for the simple case of C<$$x>,
+people often make the mistake of viewing the dereferencing symbols as
+proper operators, and wonder about their precedence. If they were,
+though, you could use parentheses instead of braces. That's not the case.
+Consider the difference below; case 0 is a short-hand version of case 1,
+I<NOT> case 2:
+
+ $$hashref{"KEY"} = "VALUE"; # CASE 0
+ ${$hashref}{"KEY"} = "VALUE"; # CASE 1
+ ${$hashref{"KEY"}} = "VALUE"; # CASE 2
+ ${$hashref->{"KEY"}} = "VALUE"; # CASE 3
+
+Case 2 is also deceptive in that you're accessing a variable
+called %hashref, not dereferencing through $hashref to the hash
+it's presumably referencing. That would be case 3.
+
+=item 3.
+
+Subroutine calls and lookups of individual array elements arise often
+enough that it gets cumbersome to use method 2. As a form of
+syntactic sugar, the examples for method 2 may be written:
+
+ $arrayref->[0] = "January"; # Array element
+ $hashref->{"KEY"} = "VALUE"; # Hash element
+ $coderef->(1,2,3); # Subroutine call
+
+The left side of the arrow can be any expression returning a reference,
+including a previous dereference. Note that C<$array[$x]> is I<NOT> the
+same thing as C<$array-E<gt>[$x]> here:
+
+ $array[$x]->{"foo"}->[0] = "January";
+
+This is one of the cases we mentioned earlier in which references could
+spring into existence when in an lvalue context. Before this
+statement, C<$array[$x]> may have been undefined. If so, it's
+automatically defined with a hash reference so that we can look up
+C<{"foo"}> in it. Likewise C<$array[$x]-E<gt>{"foo"}> will automatically get
+defined with an array reference so that we can look up C<[0]> in it.
+This process is called I<autovivification>.
+
+One more thing here. The arrow is optional I<BETWEEN> brackets
+subscripts, so you can shrink the above down to
+
+ $array[$x]{"foo"}[0] = "January";
+
+Which, in the degenerate case of using only ordinary arrays, gives you
+multidimensional arrays just like C's:
+
+ $score[$x][$y][$z] += 42;
+
+Well, okay, not entirely like C's arrays, actually. C doesn't know how
+to grow its arrays on demand. Perl does.
+
+=item 4.
+
+If a reference happens to be a reference to an object, then there are
+probably methods to access the things referred to, and you should probably
+stick to those methods unless you're in the class package that defines the
+object's methods. In other words, be nice, and don't violate the object's
+encapsulation without a very good reason. Perl does not enforce
+encapsulation. We are not totalitarians here. We do expect some basic
+civility though.
+
+=back
+
+The ref() operator may be used to determine what type of thing the
+reference is pointing to. See L<perlfunc>.
+
+The bless() operator may be used to associate the object a reference
+points to with a package functioning as an object class. See L<perlobj>.
+
+A typeglob may be dereferenced the same way a reference can, because
+the dereference syntax always indicates the kind of reference desired.
+So C<${*foo}> and C<${\$foo}> both indicate the same scalar variable.
+
+Here's a trick for interpolating a subroutine call into a string:
+
+ print "My sub returned @{[mysub(1,2,3)]} that time.\n";
+
+The way it works is that when the C<@{...}> is seen in the double-quoted
+string, it's evaluated as a block. The block creates a reference to an
+anonymous array containing the results of the call to C<mysub(1,2,3)>. So
+the whole block returns a reference to an array, which is then
+dereferenced by C<@{...}> and stuck into the double-quoted string. This
+chicanery is also useful for arbitrary expressions:
+
+ print "That yields @{[$n + 5]} widgets\n";
+
+=head2 Symbolic references
+
+We said that references spring into existence as necessary if they are
+undefined, but we didn't say what happens if a value used as a
+reference is already defined, but I<ISN'T> a hard reference. If you
+use it as a reference in this case, it'll be treated as a symbolic
+reference. That is, the value of the scalar is taken to be the I<NAME>
+of a variable, rather than a direct link to a (possibly) anonymous
+value.
+
+People frequently expect it to work like this. So it does.
+
+ $name = "foo";
+ $$name = 1; # Sets $foo
+ ${$name} = 2; # Sets $foo
+ ${$name x 2} = 3; # Sets $foofoo
+ $name->[0] = 4; # Sets $foo[0]
+ @$name = (); # Clears @foo
+ &$name(); # Calls &foo() (as in Perl 4)
+ $pack = "THAT";
+ ${"${pack}::$name"} = 5; # Sets $THAT::foo without eval
+
+This is very powerful, and slightly dangerous, in that it's possible
+to intend (with the utmost sincerity) to use a hard reference, and
+accidentally use a symbolic reference instead. To protect against
+that, you can say
+
+ use strict 'refs';
+
+and then only hard references will be allowed for the rest of the enclosing
+block. An inner block may countermand that with
+
+ no strict 'refs';
+
+Only package variables (globals, even if localized) are visible to
+symbolic references. Lexical variables (declared with my()) aren't in
+a symbol table, and thus are invisible to this mechanism. For example:
+
+ local $value = 10;
+ $ref = \$value;
+ {
+ my $value = 20;
+ print $$ref;
+ }
+
+This will still print 10, not 20. Remember that local() affects package
+variables, which are all "global" to the package.
+
+=head2 Not-so-symbolic references
+
+A new feature contributing to readability in perl version 5.001 is that the
+brackets around a symbolic reference behave more like quotes, just as they
+always have within a string. That is,
+
+ $push = "pop on ";
+ print "${push}over";
+
+has always meant to print "pop on over", despite the fact that push is
+a reserved word. This has been generalized to work the same outside
+of quotes, so that
+
+ print ${push} . "over";
+
+and even
+
+ print ${ push } . "over";
+
+will have the same effect. (This would have been a syntax error in
+Perl 5.000, though Perl 4 allowed it in the spaceless form.) Note that this
+construct is I<not> considered to be a symbolic reference when you're
+using strict refs:
+
+ use strict 'refs';
+ ${ bareword }; # Okay, means $bareword.
+ ${ "bareword" }; # Error, symbolic reference.
+
+Similarly, because of all the subscripting that is done using single
+words, we've applied the same rule to any bareword that is used for
+subscripting a hash. So now, instead of writing
+
+ $array{ "aaa" }{ "bbb" }{ "ccc" }
+
+you can write just
+
+ $array{ aaa }{ bbb }{ ccc }
+
+and not worry about whether the subscripts are reserved words. In the
+rare event that you do wish to do something like
+
+ $array{ shift }
+
+you can force interpretation as a reserved word by adding anything that
+makes it more than a bareword:
+
+ $array{ shift() }
+ $array{ +shift }
+ $array{ shift @_ }
+
+The B<-w> switch will warn you if it interprets a reserved word as a string.
+But it will no longer warn you about using lowercase words, because the
+string is effectively quoted.
+
+=head2 Pseudo-hashes: Using an array as a hash
+
+WARNING: This section describes an experimental feature. Details may
+change without notice in future versions.
+
+Beginning with release 5.005 of Perl you can use an array reference
+in some contexts that would normally require a hash reference. This
+allows you to access array elements using symbolic names, as if they
+were fields in a structure.
+
+For this to work, the array must contain extra information. The first
+element of the array has to be a hash reference that maps field names
+to array indices. Here is an example:
+
+ $struct = [{foo => 1, bar => 2}, "FOO", "BAR"];
+
+ $struct->{foo}; # same as $struct->[1], i.e. "FOO"
+ $struct->{bar}; # same as $struct->[2], i.e. "BAR"
+
+ keys %$struct; # will return ("foo", "bar") in some order
+ values %$struct; # will return ("FOO", "BAR") in same some order
+
+ while (my($k,$v) = each %$struct) {
+ print "$k => $v\n";
+ }
+
+Perl will raise an exception if you try to delete keys from a pseudo-hash
+or try to access nonexistent fields. For better performance, Perl can also
+do the translation from field names to array indices at compile time for
+typed object references. See L<fields>.
+
+
+=head2 Function Templates
+
+As explained above, a closure is an anonymous function with access to the
+lexical variables visible when that function was compiled. It retains
+access to those variables even though it doesn't get run until later,
+such as in a signal handler or a Tk callback.
+
+Using a closure as a function template allows us to generate many functions
+that act similarly. Suppopose you wanted functions named after the colors
+that generated HTML font changes for the various colors:
+
+ print "Be ", red("careful"), "with that ", green("light");
+
+The red() and green() functions would be very similar. To create these,
+we'll assign a closure to a typeglob of the name of the function we're
+trying to build.
+
+ @colors = qw(red blue green yellow orange purple violet);
+ for my $name (@colors) {
+ no strict 'refs'; # allow symbol table manipulation
+ *$name = *{uc $name} = sub { "<FONT COLOR='$name'>@_</FONT>" };
+ }
+
+Now all those different functions appear to exist independently. You can
+call red(), RED(), blue(), BLUE(), green(), etc. This technique saves on
+both compile time and memory use, and is less error-prone as well, since
+syntax checks happen at compile time. It's critical that any variables in
+the anonymous subroutine be lexicals in order to create a proper closure.
+That's the reasons for the C<my> on the loop iteration variable.
+
+This is one of the only places where giving a prototype to a closure makes
+much sense. If you wanted to impose scalar context on the arguments of
+these functions (probably not a wise idea for this particular example),
+you could have written it this way instead:
+
+ *$name = sub ($) { "<FONT COLOR='$name'>$_[0]</FONT>" };
+
+However, since prototype checking happens at compile time, the assignment
+above happens too late to be of much use. You could address this by
+putting the whole loop of assignments within a BEGIN block, forcing it
+to occur during compilation.
+
+Access to lexicals that change over type--like those in the C<for> loop
+above--only works with closures, not general subroutines. In the general
+case, then, named subroutines do not nest properly, although anonymous
+ones do. If you are accustomed to using nested subroutines in other
+programming languages with their own private variables, you'll have to
+work at it a bit in Perl. The intuitive coding of this kind of thing
+incurs mysterious warnings about ``will not stay shared''. For example,
+this won't work:
+
+ sub outer {
+ my $x = $_[0] + 35;
+ sub inner { return $x * 19 } # WRONG
+ return $x + inner();
+ }
+
+A work-around is the following:
+
+ sub outer {
+ my $x = $_[0] + 35;
+ local *inner = sub { return $x * 19 };
+ return $x + inner();
+ }
+
+Now inner() can only be called from within outer(), because of the
+temporary assignments of the closure (anonymous subroutine). But when
+it does, it has normal access to the lexical variable $x from the scope
+of outer().
+
+This has the interesting effect of creating a function local to another
+function, something not normally supported in Perl.
+
+=head1 WARNING
+
+You may not (usefully) use a reference as the key to a hash. It will be
+converted into a string:
+
+ $x{ \$a } = $a;
+
+If you try to dereference the key, it won't do a hard dereference, and
+you won't accomplish what you're attempting. You might want to do something
+more like
+
+ $r = \@a;
+ $x{ $r } = $r;
+
+And then at least you can use the values(), which will be
+real refs, instead of the keys(), which won't.
+
+The standard Tie::RefHash module provides a convenient workaround to this.
+
+=head1 SEE ALSO
+
+Besides the obvious documents, source code can be instructive.
+Some rather pathological examples of the use of references can be found
+in the F<t/op/ref.t> regression test in the Perl source directory.
+
+See also L<perldsc> and L<perllol> for how to use references to create
+complex data structures, and L<perltoot>, L<perlobj>, and L<perlbot>
+for how to use them to create objects.
diff --git a/contrib/perl5/pod/perlrun.pod b/contrib/perl5/pod/perlrun.pod
new file mode 100644
index 0000000..a0c85b9
--- /dev/null
+++ b/contrib/perl5/pod/perlrun.pod
@@ -0,0 +1,731 @@
+=head1 NAME
+
+perlrun - how to execute the Perl interpreter
+
+=head1 SYNOPSIS
+
+B<perl> S<[ B<-sTuU> ]>
+ S<[ B<-hv> ] [ B<-V>[:I<configvar>] ]>
+ S<[ B<-cw> ] [ B<-d>[:I<debugger>] ] [ B<-D>[I<number/list>] ]>
+ S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [ B<-0>[I<octal>] ]>
+ S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [ B<-M>[B<->]I<'module...'> ]>
+ S<[ B<-P> ]>
+ S<[ B<-S> ]>
+ S<[ B<-x>[I<dir>] ]>
+ S<[ B<-i>[I<extension>] ]>
+ S<[ B<-e> I<'command'> ] [ B<--> ] [ I<programfile> ] [ I<argument> ]...>
+
+=head1 DESCRIPTION
+
+Upon startup, Perl looks for your script in one of the following
+places:
+
+=over 4
+
+=item 1.
+
+Specified line by line via B<-e> switches on the command line.
+
+=item 2.
+
+Contained in the file specified by the first filename on the command line.
+(Note that systems supporting the #! notation invoke interpreters this
+way. See L<Location of Perl>.)
+
+=item 3.
+
+Passed in implicitly via standard input. This works only if there are
+no filename arguments--to pass arguments to a STDIN script you
+must explicitly specify a "-" for the script name.
+
+=back
+
+With methods 2 and 3, Perl starts parsing the input file from the
+beginning, unless you've specified a B<-x> switch, in which case it
+scans for the first line starting with #! and containing the word
+"perl", and starts there instead. This is useful for running a script
+embedded in a larger message. (In this case you would indicate the end
+of the script using the C<__END__> token.)
+
+The #! line is always examined for switches as the line is being
+parsed. Thus, if you're on a machine that allows only one argument
+with the #! line, or worse, doesn't even recognize the #! line, you
+still can get consistent switch behavior regardless of how Perl was
+invoked, even if B<-x> was used to find the beginning of the script.
+
+Because many operating systems silently chop off kernel interpretation of
+the #! line after 32 characters, some switches may be passed in on the
+command line, and some may not; you could even get a "-" without its
+letter, if you're not careful. You probably want to make sure that all
+your switches fall either before or after that 32 character boundary.
+Most switches don't actually care if they're processed redundantly, but
+getting a - instead of a complete switch could cause Perl to try to
+execute standard input instead of your script. And a partial B<-I> switch
+could also cause odd results.
+
+Some switches do care if they are processed twice, for instance combinations
+of B<-l> and B<-0>. Either put all the switches after the 32 character
+boundary (if applicable), or replace the use of B<-0>I<digits> by
+C<BEGIN{ $/ = "\0digits"; }>.
+
+Parsing of the #! switches starts wherever "perl" is mentioned in the line.
+The sequences "-*" and "- " are specifically ignored so that you could,
+if you were so inclined, say
+
+ #!/bin/sh -- # -*- perl -*- -p
+ eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+to let Perl see the B<-p> switch.
+
+If the #! line does not contain the word "perl", the program named after
+the #! is executed instead of the Perl interpreter. This is slightly
+bizarre, but it helps people on machines that don't do #!, because they
+can tell a program that their SHELL is /usr/bin/perl, and Perl will then
+dispatch the program to the correct interpreter for them.
+
+After locating your script, Perl compiles the entire script to an
+internal form. If there are any compilation errors, execution of the
+script is not attempted. (This is unlike the typical shell script,
+which might run part-way through before finding a syntax error.)
+
+If the script is syntactically correct, it is executed. If the script
+runs off the end without hitting an exit() or die() operator, an implicit
+C<exit(0)> is provided to indicate successful completion.
+
+=head2 #! and quoting on non-Unix systems
+
+Unix's #! technique can be simulated on other systems:
+
+=over 4
+
+=item OS/2
+
+Put
+
+ extproc perl -S -your_switches
+
+as the first line in C<*.cmd> file (C<-S> due to a bug in cmd.exe's
+`extproc' handling).
+
+=item MS-DOS
+
+Create a batch file to run your script, and codify it in
+C<ALTERNATIVE_SHEBANG> (see the F<dosish.h> file in the source
+distribution for more information).
+
+=item Win95/NT
+
+The Win95/NT installation, when using the Activeware port of Perl,
+will modify the Registry to associate the F<.pl> extension with the perl
+interpreter. If you install another port of Perl, including the one
+in the Win32 directory of the Perl distribution, then you'll have to
+modify the Registry yourself. Note that this means you can no
+longer tell the difference between an executable Perl program
+and a Perl library file.
+
+=item Macintosh
+
+Macintosh perl scripts will have the appropriate Creator and
+Type, so that double-clicking them will invoke the perl application.
+
+=back
+
+Command-interpreters on non-Unix systems have rather different ideas
+on quoting than Unix shells. You'll need to learn the special
+characters in your command-interpreter (C<*>, C<\> and C<"> are
+common) and how to protect whitespace and these characters to run
+one-liners (see C<-e> below).
+
+On some systems, you may have to change single-quotes to double ones,
+which you must I<NOT> do on Unix or Plan9 systems. You might also
+have to change a single % to a %%.
+
+For example:
+
+ # Unix
+ perl -e 'print "Hello world\n"'
+
+ # MS-DOS, etc.
+ perl -e "print \"Hello world\n\""
+
+ # Macintosh
+ print "Hello world\n"
+ (then Run "Myscript" or Shift-Command-R)
+
+ # VMS
+ perl -e "print ""Hello world\n"""
+
+The problem is that none of this is reliable: it depends on the command
+and it is entirely possible neither works. If 4DOS was the command shell, this would
+probably work better:
+
+ perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
+
+CMD.EXE in Windows NT slipped a lot of standard Unix functionality in
+when nobody was looking, but just try to find documentation for its
+quoting rules.
+
+Under the Macintosh, it depends which environment you are using. The MacPerl
+shell, or MPW, is much like Unix shells in its support for several
+quoting variants, except that it makes free use of the Macintosh's non-ASCII
+characters as control characters.
+
+There is no general solution to all of this. It's just a mess.
+
+=head2 Location of Perl
+
+It may seem obvious to say, but Perl is useful only when users can
+easily find it. When possible, it's good for both B</usr/bin/perl> and
+B</usr/local/bin/perl> to be symlinks to the actual binary. If that
+can't be done, system administrators are strongly encouraged to put
+(symlinks to) perl and its accompanying utilities, such as perldoc, into
+a directory typically found along a user's PATH, or in another obvious
+and convenient place.
+
+In this documentation, C<#!/usr/bin/perl> on the first line of the script
+will stand in for whatever method works on your system.
+
+=head2 Switches
+
+A single-character switch may be combined with the following switch, if
+any.
+
+ #!/usr/bin/perl -spi.bak # same as -s -p -i.bak
+
+Switches include:
+
+=over 5
+
+=item B<-0>[I<digits>]
+
+specifies the input record separator (C<$/>) as an octal number. If there are
+no digits, the null character is the separator. Other switches may
+precede or follow the digits. For example, if you have a version of
+B<find> which can print filenames terminated by the null character, you
+can say this:
+
+ find . -name '*.bak' -print0 | perl -n0e unlink
+
+The special value 00 will cause Perl to slurp files in paragraph mode.
+The value 0777 will cause Perl to slurp files whole because there is no
+legal character with that value.
+
+=item B<-a>
+
+turns on autosplit mode when used with a B<-n> or B<-p>. An implicit
+split command to the @F array is done as the first thing inside the
+implicit while loop produced by the B<-n> or B<-p>.
+
+ perl -ane 'print pop(@F), "\n";'
+
+is equivalent to
+
+ while (<>) {
+ @F = split(' ');
+ print pop(@F), "\n";
+ }
+
+An alternate delimiter may be specified using B<-F>.
+
+=item B<-c>
+
+causes Perl to check the syntax of the script and then exit without
+executing it. Actually, it I<will> execute C<BEGIN>, C<END>, and C<use> blocks,
+because these are considered as occurring outside the execution of
+your program.
+
+=item B<-d>
+
+runs the script under the Perl debugger. See L<perldebug>.
+
+=item B<-d:>I<foo>
+
+runs the script under the control of a debugging or tracing module
+installed as Devel::foo. E.g., B<-d:DProf> executes the script using the
+Devel::DProf profiler. See L<perldebug>.
+
+=item B<-D>I<letters>
+
+=item B<-D>I<number>
+
+sets debugging flags. To watch how it executes your script, use
+B<-Dtls>. (This works only if debugging is compiled into your
+Perl.) Another nice value is B<-Dx>, which lists your compiled
+syntax tree. And B<-Dr> displays compiled regular expressions. As an
+alternative, specify a number instead of list of letters (e.g., B<-D14> is
+equivalent to B<-Dtls>):
+
+ 1 p Tokenizing and parsing
+ 2 s Stack snapshots
+ 4 l Context (loop) stack processing
+ 8 t Trace execution
+ 16 o Method and overloading resolution
+ 32 c String/numeric conversions
+ 64 P Print preprocessor command for -P
+ 128 m Memory allocation
+ 256 f Format processing
+ 512 r Regular expression parsing and execution
+ 1024 x Syntax tree dump
+ 2048 u Tainting checks
+ 4096 L Memory leaks (needs C<-DLEAKTEST> when compiling Perl)
+ 8192 H Hash dump -- usurps values()
+ 16384 X Scratchpad allocation
+ 32768 D Cleaning up
+ 65536 S Thread synchronization
+
+All these flags require C<-DDEBUGGING> when you compile the Perl
+executable. This flag is automatically set if you include C<-g>
+option when C<Configure> asks you about optimizer/debugger flags.
+
+=item B<-e> I<commandline>
+
+may be used to enter one line of script.
+If B<-e> is given, Perl
+will not look for a script filename in the argument list.
+Multiple B<-e> commands may
+be given to build up a multi-line script.
+Make sure to use semicolons where you would in a normal program.
+
+=item B<-F>I<pattern>
+
+specifies the pattern to split on if B<-a> is also in effect. The
+pattern may be surrounded by C<//>, C<"">, or C<''>, otherwise it will be
+put in single quotes.
+
+=item B<-h>
+
+prints a summary of the options.
+
+=item B<-i>[I<extension>]
+
+specifies that files processed by the C<E<lt>E<gt>> construct are to be
+edited in-place. It does this by renaming the input file, opening the
+output file by the original name, and selecting that output file as the
+default for print() statements. The extension, if supplied, is used to
+modify the name of the old file to make a backup copy, following these
+rules:
+
+If no extension is supplied, no backup is made and the current file is
+overwritten.
+
+If the extension doesn't contain a C<*> then it is appended to the end
+of the current filename as a suffix.
+
+If the extension does contain one or more C<*> characters, then each C<*>
+is replaced with the current filename. In perl terms you could think of
+this as:
+
+ ($backup = $extension) =~ s/\*/$file_name/g;
+
+This allows you to add a prefix to the backup file, instead of (or in
+addition to) a suffix:
+
+ $ perl -pi'bak_*' -e 's/bar/baz/' fileA # backup to 'bak_fileA'
+
+Or even to place backup copies of the original files into another
+directory (provided the directory already exists):
+
+ $ perl -pi'old/*.bak' -e 's/bar/baz/' fileA # backup to 'old/fileA.bak'
+
+These sets of one-liners are equivalent:
+
+ $ perl -pi -e 's/bar/baz/' fileA # overwrite current file
+ $ perl -pi'*' -e 's/bar/baz/' fileA # overwrite current file
+
+ $ perl -pi'.bak' -e 's/bar/baz/' fileA # backup to 'fileA.bak'
+ $ perl -pi'*.bak' -e 's/bar/baz/' fileA # backup to 'fileA.bak'
+
+From the shell, saying
+
+ $ perl -p -i.bak -e "s/foo/bar/; ... "
+
+is the same as using the script:
+
+ #!/usr/bin/perl -pi.bak
+ s/foo/bar/;
+
+which is equivalent to
+
+ #!/usr/bin/perl
+ $extension = '.bak';
+ while (<>) {
+ if ($ARGV ne $oldargv) {
+ if ($extension !~ /\*/) {
+ $backup = $ARGV . $extension;
+ }
+ else {
+ ($backup = $extension) =~ s/\*/$ARGV/g;
+ }
+ rename($ARGV, $backup);
+ open(ARGVOUT, ">$ARGV");
+ select(ARGVOUT);
+ $oldargv = $ARGV;
+ }
+ s/foo/bar/;
+ }
+ continue {
+ print; # this prints to original filename
+ }
+ select(STDOUT);
+
+except that the B<-i> form doesn't need to compare $ARGV to $oldargv to
+know when the filename has changed. It does, however, use ARGVOUT for
+the selected filehandle. Note that STDOUT is restored as the default
+output filehandle after the loop.
+
+As shown above, Perl creates the backup file whether or not any output
+is actually changed. So this is just a fancy way to copy files:
+
+ $ perl -p -i'/some/file/path/*' -e 1 file1 file2 file3...
+ or
+ $ perl -p -i'.bak' -e 1 file1 file2 file3...
+
+You can use C<eof> without parentheses to locate the end of each input
+file, in case you want to append to each file, or reset line numbering
+(see example in L<perlfunc/eof>).
+
+If, for a given file, Perl is unable to create the backup file as
+specified in the extension then it will skip that file and continue on
+with the next one (if it exists).
+
+For a discussion of issues surrounding file permissions and C<-i>, see
+L<perlfaq5/Why does Perl let me delete read-only files? Why does -i clobber protected files? Isn't this a bug in Perl?>.
+
+You cannot use B<-i> to create directories or to strip extensions from
+files.
+
+Perl does not expand C<~>, so don't do that.
+
+Finally, note that the B<-i> switch does not impede execution when no
+files are given on the command line. In this case, no backup is made
+(the original file cannot, of course, be determined) and processing
+proceeds from STDIN to STDOUT as might be expected.
+
+=item B<-I>I<directory>
+
+Directories specified by B<-I> are prepended to the search path for
+modules (C<@INC>), and also tells the C preprocessor where to search for
+include files. The C preprocessor is invoked with B<-P>; by default it
+searches /usr/include and /usr/lib/perl.
+
+=item B<-l>[I<octnum>]
+
+enables automatic line-ending processing. It has two effects: first,
+it automatically chomps "C<$/>" (the input record separator) when used
+with B<-n> or B<-p>, and second, it assigns "C<$\>"
+(the output record separator) to have the value of I<octnum> so that
+any print statements will have that separator added back on. If
+I<octnum> is omitted, sets "C<$\>" to the current value of "C<$/>". For
+instance, to trim lines to 80 columns:
+
+ perl -lpe 'substr($_, 80) = ""'
+
+Note that the assignment C<$\ = $/> is done when the switch is processed,
+so the input record separator can be different than the output record
+separator if the B<-l> switch is followed by a B<-0> switch:
+
+ gnufind / -print0 | perl -ln0e 'print "found $_" if -p'
+
+This sets C<$\> to newline and then sets C<$/> to the null character.
+
+=item B<-m>[B<->]I<module>
+
+=item B<-M>[B<->]I<module>
+
+=item B<-M>[B<->]I<'module ...'>
+
+=item B<-[mM]>[B<->]I<module=arg[,arg]...>
+
+C<-m>I<module> executes C<use> I<module> C<();> before executing your
+script.
+
+C<-M>I<module> executes C<use> I<module> C<;> before executing your
+script. You can use quotes to add extra code after the module name,
+e.g., C<-M'module qw(foo bar)'>.
+
+If the first character after the C<-M> or C<-m> is a dash (C<->)
+then the 'use' is replaced with 'no'.
+
+A little builtin syntactic sugar means you can also say
+C<-mmodule=foo,bar> or C<-Mmodule=foo,bar> as a shortcut for
+C<-M'module qw(foo bar)'>. This avoids the need to use quotes when
+importing symbols. The actual code generated by C<-Mmodule=foo,bar> is
+C<use module split(/,/,q{foo,bar})>. Note that the C<=> form
+removes the distinction between C<-m> and C<-M>.
+
+=item B<-n>
+
+causes Perl to assume the following loop around your script, which
+makes it iterate over filename arguments somewhat like B<sed -n> or
+B<awk>:
+
+ while (<>) {
+ ... # your script goes here
+ }
+
+Note that the lines are not printed by default. See B<-p> to have
+lines printed. If a file named by an argument cannot be opened for
+some reason, Perl warns you about it, and moves on to the next file.
+
+Here is an efficient way to delete all files older than a week:
+
+ find . -mtime +7 -print | perl -nle 'unlink;'
+
+This is faster than using the C<-exec> switch of B<find> because you don't
+have to start a process on every filename found.
+
+C<BEGIN> and C<END> blocks may be used to capture control before or after
+the implicit loop, just as in B<awk>.
+
+=item B<-p>
+
+causes Perl to assume the following loop around your script, which
+makes it iterate over filename arguments somewhat like B<sed>:
+
+
+ while (<>) {
+ ... # your script goes here
+ } continue {
+ print or die "-p destination: $!\n";
+ }
+
+If a file named by an argument cannot be opened for some reason, Perl
+warns you about it, and moves on to the next file. Note that the
+lines are printed automatically. An error occuring during printing is
+treated as fatal. To suppress printing use the B<-n> switch. A B<-p>
+overrides a B<-n> switch.
+
+C<BEGIN> and C<END> blocks may be used to capture control before or after
+the implicit loop, just as in awk.
+
+=item B<-P>
+
+causes your script to be run through the C preprocessor before
+compilation by Perl. (Because both comments and cpp directives begin
+with the # character, you should avoid starting comments with any words
+recognized by the C preprocessor such as "if", "else", or "define".)
+
+=item B<-s>
+
+enables some rudimentary switch parsing for switches on the command
+line after the script name but before any filename arguments (or before
+a B<-->). Any switch found there is removed from @ARGV and sets the
+corresponding variable in the Perl script. The following script
+prints "true" if and only if the script is invoked with a B<-xyz> switch.
+
+ #!/usr/bin/perl -s
+ if ($xyz) { print "true\n"; }
+
+=item B<-S>
+
+makes Perl use the PATH environment variable to search for the
+script (unless the name of the script contains directory separators).
+On some platforms, this also makes Perl append suffixes to the
+filename while searching for it. For example, on Win32 platforms,
+the ".bat" and ".cmd" suffixes are appended if a lookup for the
+original name fails, and if the name does not already end in one
+of those suffixes. If your Perl was compiled with DEBUGGING turned
+on, using the -Dp switch to Perl shows how the search progresses.
+
+If the filename supplied contains directory separators (i.e. it is an
+absolute or relative pathname), and if the file is not found,
+platforms that append file extensions will do so and try to look
+for the file with those extensions added, one by one.
+
+On DOS-like platforms, if the script does not contain directory
+separators, it will first be searched for in the current directory
+before being searched for on the PATH. On Unix platforms, the
+script will be searched for strictly on the PATH.
+
+Typically this is used to emulate #! startup on platforms that
+don't support #!. This example works on many platforms that
+have a shell compatible with Bourne shell:
+
+ #!/usr/bin/perl
+ eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+The system ignores the first line and feeds the script to /bin/sh,
+which proceeds to try to execute the Perl script as a shell script.
+The shell executes the second line as a normal shell command, and thus
+starts up the Perl interpreter. On some systems $0 doesn't always
+contain the full pathname, so the B<-S> tells Perl to search for the
+script if necessary. After Perl locates the script, it parses the
+lines and ignores them because the variable $running_under_some_shell
+is never true. If the script will be interpreted by csh, you will need
+to replace C<${1+"$@"}> with C<$*>, even though that doesn't understand
+embedded spaces (and such) in the argument list. To start up sh rather
+than csh, some systems may have to replace the #! line with a line
+containing just a colon, which will be politely ignored by Perl. Other
+systems can't control that, and need a totally devious construct that
+will work under any of csh, sh, or Perl, such as the following:
+
+ eval '(exit $?0)' && eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
+ & eval 'exec /usr/bin/perl -wS $0 $argv:q'
+ if $running_under_some_shell;
+
+=item B<-T>
+
+forces "taint" checks to be turned on so you can test them. Ordinarily
+these checks are done only when running setuid or setgid. It's a good
+idea to turn them on explicitly for programs run on another's behalf,
+such as CGI programs. See L<perlsec>. Note that (for security reasons)
+this option must be seen by Perl quite early; usually this means it must
+appear early on the command line or in the #! line (for systems which
+support that).
+
+=item B<-u>
+
+causes Perl to dump core after compiling your script. You can then
+in theory take this core dump and turn it into an executable file by using the
+B<undump> program (not supplied). This speeds startup at the expense of
+some disk space (which you can minimize by stripping the executable).
+(Still, a "hello world" executable comes out to about 200K on my
+machine.) If you want to execute a portion of your script before dumping,
+use the dump() operator instead. Note: availability of B<undump> is
+platform specific and may not be available for a specific port of
+Perl. It has been superseded by the new perl-to-C compiler, which is more
+portable, even though it's still only considered beta.
+
+=item B<-U>
+
+allows Perl to do unsafe operations. Currently the only "unsafe"
+operations are the unlinking of directories while running as superuser,
+and running setuid programs with fatal taint checks turned into
+warnings. Note that the B<-w> switch (or the C<$^W> variable) must
+be used along with this option to actually B<generate> the
+taint-check warnings.
+
+=item B<-v>
+
+prints the version and patchlevel of your Perl executable.
+
+=item B<-V>
+
+prints summary of the major perl configuration values and the current
+value of @INC.
+
+=item B<-V:>I<name>
+
+Prints to STDOUT the value of the named configuration variable.
+
+=item B<-w>
+
+prints warnings about variable names that are mentioned only once, and
+scalar variables that are used before being set. Also warns about
+redefined subroutines, and references to undefined filehandles or
+filehandles opened read-only that you are attempting to write on. Also
+warns you if you use values as a number that doesn't look like numbers,
+using an array as though it were a scalar, if your subroutines recurse
+more than 100 deep, and innumerable other things.
+
+You can disable specific warnings using C<__WARN__> hooks, as described
+in L<perlvar> and L<perlfunc/warn>. See also L<perldiag> and L<perltrap>.
+
+=item B<-x> I<directory>
+
+tells Perl that the script is embedded in a message. Leading
+garbage will be discarded until the first line that starts with #! and
+contains the string "perl". Any meaningful switches on that line will
+be applied. If a directory name is specified, Perl will switch to
+that directory before running the script. The B<-x> switch controls
+only the disposal of leading garbage. The script must be
+terminated with C<__END__> if there is trailing garbage to be ignored (the
+script can process any or all of the trailing garbage via the DATA
+filehandle if desired).
+
+=back
+
+=head1 ENVIRONMENT
+
+=over 12
+
+=item HOME
+
+Used if chdir has no argument.
+
+=item LOGDIR
+
+Used if chdir has no argument and HOME is not set.
+
+=item PATH
+
+Used in executing subprocesses, and in finding the script if B<-S> is
+used.
+
+=item PERL5LIB
+
+A colon-separated list of directories in which to look for Perl library
+files before looking in the standard library and the current
+directory. If PERL5LIB is not defined, PERLLIB is used. When running
+taint checks (because the script was running setuid or setgid, or the
+B<-T> switch was used), neither variable is used. The script should
+instead say
+
+ use lib "/my/directory";
+
+=item PERL5OPT
+
+Command-line options (switches). Switches in this variable are taken
+as if they were on every Perl command line. Only the B<-[DIMUdmw]>
+switches are allowed. When running taint checks (because the script
+was running setuid or setgid, or the B<-T> switch was used), this
+variable is ignored.
+
+=item PERLLIB
+
+A colon-separated list of directories in which to look for Perl library
+files before looking in the standard library and the current directory.
+If PERL5LIB is defined, PERLLIB is not used.
+
+=item PERL5DB
+
+The command used to load the debugger code. The default is:
+
+ BEGIN { require 'perl5db.pl' }
+
+=item PERL5SHELL (specific to WIN32 port)
+
+May be set to an alternative shell that perl must use internally for
+executing "backtick" commands or system(). Default is C<cmd.exe /x/c>
+on WindowsNT and C<command.com /c> on Windows95. The value is considered
+to be space delimited. Precede any character that needs to be protected
+(like a space or backslash) with a backslash.
+
+Note that Perl doesn't use COMSPEC for this purpose because
+COMSPEC has a high degree of variability among users, leading to
+portability concerns. Besides, perl can use a shell that may not be
+fit for interactive use, and setting COMSPEC to such a shell may
+interfere with the proper functioning of other programs (which usually
+look in COMSPEC to find a shell fit for interactive use).
+
+=item PERL_DEBUG_MSTATS
+
+Relevant only if perl is compiled with the malloc included with the perl
+distribution (that is, if C<perl -V:d_mymalloc> is 'define').
+If set, this causes memory statistics to be dumped after execution. If set
+to an integer greater than one, also causes memory statistics to be dumped
+after compilation.
+
+=item PERL_DESTRUCT_LEVEL
+
+Relevant only if your perl executable was built with B<-DDEBUGGING>,
+this controls the behavior of global destruction of objects and other
+references.
+
+=back
+
+Perl also has environment variables that control how Perl handles data
+specific to particular natural languages. See L<perllocale>.
+
+Apart from these, Perl uses no other environment variables, except
+to make them available to the script being executed, and to child
+processes. However, scripts running setuid would do well to execute
+the following lines before doing anything else, just to keep people
+honest:
+
+ $ENV{PATH} = '/bin:/usr/bin'; # or whatever you need
+ $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
+ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+
diff --git a/contrib/perl5/pod/perlsec.pod b/contrib/perl5/pod/perlsec.pod
new file mode 100644
index 0000000..0b22acd
--- /dev/null
+++ b/contrib/perl5/pod/perlsec.pod
@@ -0,0 +1,351 @@
+=head1 NAME
+
+perlsec - Perl security
+
+=head1 DESCRIPTION
+
+Perl is designed to make it easy to program securely even when running
+with extra privileges, like setuid or setgid programs. Unlike most
+command line shells, which are based on multiple substitution passes on
+each line of the script, Perl uses a more conventional evaluation scheme
+with fewer hidden snags. Additionally, because the language has more
+builtin functionality, it can rely less upon external (and possibly
+untrustworthy) programs to accomplish its purposes.
+
+Perl automatically enables a set of special security checks, called I<taint
+mode>, when it detects its program running with differing real and effective
+user or group IDs. The setuid bit in Unix permissions is mode 04000, the
+setgid bit mode 02000; either or both may be set. You can also enable taint
+mode explicitly by using the B<-T> command line flag. This flag is
+I<strongly> suggested for server programs and any program run on behalf of
+someone else, such as a CGI script. Once taint mode is on, it's on for
+the remainder of your script.
+
+While in this mode, Perl takes special precautions called I<taint
+checks> to prevent both obvious and subtle traps. Some of these checks
+are reasonably simple, such as verifying that path directories aren't
+writable by others; careful programmers have always used checks like
+these. Other checks, however, are best supported by the language itself,
+and it is these checks especially that contribute to making a set-id Perl
+program more secure than the corresponding C program.
+
+You may not use data derived from outside your program to affect
+something else outside your program--at least, not by accident. All
+command line arguments, environment variables, locale information (see
+L<perllocale>), results of certain system calls (readdir, readlink,
+the gecos field of getpw* calls), and all file input are marked as
+"tainted". Tainted data may not be used directly or indirectly in any
+command that invokes a sub-shell, nor in any command that modifies
+files, directories, or processes. (B<Important exception>: If you pass
+a list of arguments to either C<system> or C<exec>, the elements of
+that list are B<NOT> checked for taintedness.) Any variable set
+to a value derived from tainted data will itself be tainted,
+even if it is logically impossible for the tainted data
+to alter the variable. Because taintedness is associated with each
+scalar value, some elements of an array can be tainted and others not.
+
+For example:
+
+ $arg = shift; # $arg is tainted
+ $hid = $arg, 'bar'; # $hid is also tainted
+ $line = <>; # Tainted
+ $line = <STDIN>; # Also tainted
+ open FOO, "/home/me/bar" or die $!;
+ $line = <FOO>; # Still tainted
+ $path = $ENV{'PATH'}; # Tainted, but see below
+ $data = 'abc'; # Not tainted
+
+ system "echo $arg"; # Insecure
+ system "/bin/echo", $arg; # Secure (doesn't use sh)
+ system "echo $hid"; # Insecure
+ system "echo $data"; # Insecure until PATH set
+
+ $path = $ENV{'PATH'}; # $path now tainted
+
+ $ENV{'PATH'} = '/bin:/usr/bin';
+ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+ $path = $ENV{'PATH'}; # $path now NOT tainted
+ system "echo $data"; # Is secure now!
+
+ open(FOO, "< $arg"); # OK - read-only file
+ open(FOO, "> $arg"); # Not OK - trying to write
+
+ open(FOO,"echo $arg|"); # Not OK, but...
+ open(FOO,"-|")
+ or exec 'echo', $arg; # OK
+
+ $shout = `echo $arg`; # Insecure, $shout now tainted
+
+ unlink $data, $arg; # Insecure
+ umask $arg; # Insecure
+
+ exec "echo $arg"; # Insecure
+ exec "echo", $arg; # Secure (doesn't use the shell)
+ exec "sh", '-c', $arg; # Considered secure, alas!
+
+ @files = <*.c>; # Always insecure (uses csh)
+ @files = glob('*.c'); # Always insecure (uses csh)
+
+If you try to do something insecure, you will get a fatal error saying
+something like "Insecure dependency" or "Insecure $ENV{PATH}". Note that you
+can still write an insecure B<system> or B<exec>, but only by explicitly
+doing something like the "considered secure" example above.
+
+=head2 Laundering and Detecting Tainted Data
+
+To test whether a variable contains tainted data, and whose use would thus
+trigger an "Insecure dependency" message, check your nearby CPAN mirror
+for the F<Taint.pm> module, which should become available around November
+1997. Or you may be able to use the following I<is_tainted()> function.
+
+ sub is_tainted {
+ return ! eval {
+ join('',@_), kill 0;
+ 1;
+ };
+ }
+
+This function makes use of the fact that the presence of tainted data
+anywhere within an expression renders the entire expression tainted. It
+would be inefficient for every operator to test every argument for
+taintedness. Instead, the slightly more efficient and conservative
+approach is used that if any tainted value has been accessed within the
+same expression, the whole expression is considered tainted.
+
+But testing for taintedness gets you only so far. Sometimes you have just
+to clear your data's taintedness. The only way to bypass the tainting
+mechanism is by referencing subpatterns from a regular expression match.
+Perl presumes that if you reference a substring using $1, $2, etc., that
+you knew what you were doing when you wrote the pattern. That means using
+a bit of thought--don't just blindly untaint anything, or you defeat the
+entire mechanism. It's better to verify that the variable has only good
+characters (for certain values of "good") rather than checking whether it
+has any bad characters. That's because it's far too easy to miss bad
+characters that you never thought of.
+
+Here's a test to make sure that the data contains nothing but "word"
+characters (alphabetics, numerics, and underscores), a hyphen, an at sign,
+or a dot.
+
+ if ($data =~ /^([-\@\w.]+)$/) {
+ $data = $1; # $data now untainted
+ } else {
+ die "Bad data in $data"; # log this somewhere
+ }
+
+This is fairly secure because C</\w+/> doesn't normally match shell
+metacharacters, nor are dot, dash, or at going to mean something special
+to the shell. Use of C</.+/> would have been insecure in theory because
+it lets everything through, but Perl doesn't check for that. The lesson
+is that when untainting, you must be exceedingly careful with your patterns.
+Laundering data using regular expression is the I<ONLY> mechanism for
+untainting dirty data, unless you use the strategy detailed below to fork
+a child of lesser privilege.
+
+The example does not untaint $data if C<use locale> is in effect,
+because the characters matched by C<\w> are determined by the locale.
+Perl considers that locale definitions are untrustworthy because they
+contain data from outside the program. If you are writing a
+locale-aware program, and want to launder data with a regular expression
+containing C<\w>, put C<no locale> ahead of the expression in the same
+block. See L<perllocale/SECURITY> for further discussion and examples.
+
+=head2 Switches On the "#!" Line
+
+When you make a script executable, in order to make it usable as a
+command, the system will pass switches to perl from the script's #!
+line. Perl checks that any command line switches given to a setuid
+(or setgid) script actually match the ones set on the #! line. Some
+Unix and Unix-like environments impose a one-switch limit on the #!
+line, so you may need to use something like C<-wU> instead of C<-w -U>
+under such systems. (This issue should arise only in Unix or
+Unix-like environments that support #! and setuid or setgid scripts.)
+
+=head2 Cleaning Up Your Path
+
+For "Insecure C<$ENV{PATH}>" messages, you need to set C<$ENV{'PATH'}> to a
+known value, and each directory in the path must be non-writable by others
+than its owner and group. You may be surprised to get this message even
+if the pathname to your executable is fully qualified. This is I<not>
+generated because you didn't supply a full path to the program; instead,
+it's generated because you never set your PATH environment variable, or
+you didn't set it to something that was safe. Because Perl can't
+guarantee that the executable in question isn't itself going to turn
+around and execute some other program that is dependent on your PATH, it
+makes sure you set the PATH.
+
+The PATH isn't the only environment variable which can cause problems.
+Because some shells may use the variables IFS, CDPATH, ENV, and
+BASH_ENV, Perl checks that those are either empty or untainted when
+starting subprocesses. You may wish to add something like this to your
+setid and taint-checking scripts.
+
+ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
+
+It's also possible to get into trouble with other operations that don't
+care whether they use tainted values. Make judicious use of the file
+tests in dealing with any user-supplied filenames. When possible, do
+opens and such B<after> properly dropping any special user (or group!)
+privileges. Perl doesn't prevent you from opening tainted filenames for reading,
+so be careful what you print out. The tainting mechanism is intended to
+prevent stupid mistakes, not to remove the need for thought.
+
+Perl does not call the shell to expand wild cards when you pass B<system>
+and B<exec> explicit parameter lists instead of strings with possible shell
+wildcards in them. Unfortunately, the B<open>, B<glob>, and
+backtick functions provide no such alternate calling convention, so more
+subterfuge will be required.
+
+Perl provides a reasonably safe way to open a file or pipe from a setuid
+or setgid program: just create a child process with reduced privilege who
+does the dirty work for you. First, fork a child using the special
+B<open> syntax that connects the parent and child by a pipe. Now the
+child resets its ID set and any other per-process attributes, like
+environment variables, umasks, current working directories, back to the
+originals or known safe values. Then the child process, which no longer
+has any special permissions, does the B<open> or other system call.
+Finally, the child passes the data it managed to access back to the
+parent. Because the file or pipe was opened in the child while running
+under less privilege than the parent, it's not apt to be tricked into
+doing something it shouldn't.
+
+Here's a way to do backticks reasonably safely. Notice how the B<exec> is
+not called with a string that the shell could expand. This is by far the
+best way to call something that might be subjected to shell escapes: just
+never call the shell at all.
+
+ use English;
+ die "Can't fork: $!" unless defined $pid = open(KID, "-|");
+ if ($pid) { # parent
+ while (<KID>) {
+ # do something
+ }
+ close KID;
+ } else {
+ my @temp = ($EUID, $EGID);
+ $EUID = $UID;
+ $EGID = $GID; # initgroups() also called!
+ # Make sure privs are really gone
+ ($EUID, $EGID) = @temp;
+ die "Can't drop privileges"
+ unless $UID == $EUID && $GID eq $EGID;
+ $ENV{PATH} = "/bin:/usr/bin";
+ exec 'myprog', 'arg1', 'arg2'
+ or die "can't exec myprog: $!";
+ }
+
+A similar strategy would work for wildcard expansion via C<glob>, although
+you can use C<readdir> instead.
+
+Taint checking is most useful when although you trust yourself not to have
+written a program to give away the farm, you don't necessarily trust those
+who end up using it not to try to trick it into doing something bad. This
+is the kind of security checking that's useful for set-id programs and
+programs launched on someone else's behalf, like CGI programs.
+
+This is quite different, however, from not even trusting the writer of the
+code not to try to do something evil. That's the kind of trust needed
+when someone hands you a program you've never seen before and says, "Here,
+run this." For that kind of safety, check out the Safe module,
+included standard in the Perl distribution. This module allows the
+programmer to set up special compartments in which all system operations
+are trapped and namespace access is carefully controlled.
+
+=head2 Security Bugs
+
+Beyond the obvious problems that stem from giving special privileges to
+systems as flexible as scripts, on many versions of Unix, set-id scripts
+are inherently insecure right from the start. The problem is a race
+condition in the kernel. Between the time the kernel opens the file to
+see which interpreter to run and when the (now-set-id) interpreter turns
+around and reopens the file to interpret it, the file in question may have
+changed, especially if you have symbolic links on your system.
+
+Fortunately, sometimes this kernel "feature" can be disabled.
+Unfortunately, there are two ways to disable it. The system can simply
+outlaw scripts with any set-id bit set, which doesn't help much.
+Alternately, it can simply ignore the set-id bits on scripts. If the
+latter is true, Perl can emulate the setuid and setgid mechanism when it
+notices the otherwise useless setuid/gid bits on Perl scripts. It does
+this via a special executable called B<suidperl> that is automatically
+invoked for you if it's needed.
+
+However, if the kernel set-id script feature isn't disabled, Perl will
+complain loudly that your set-id script is insecure. You'll need to
+either disable the kernel set-id script feature, or put a C wrapper around
+the script. A C wrapper is just a compiled program that does nothing
+except call your Perl program. Compiled programs are not subject to the
+kernel bug that plagues set-id scripts. Here's a simple wrapper, written
+in C:
+
+ #define REAL_PATH "/path/to/script"
+ main(ac, av)
+ char **av;
+ {
+ execv(REAL_PATH, av);
+ }
+
+Compile this wrapper into a binary executable and then make I<it> rather
+than your script setuid or setgid.
+
+See the program B<wrapsuid> in the F<eg> directory of your Perl
+distribution for a convenient way to do this automatically for all your
+setuid Perl programs. It moves setuid scripts into files with the same
+name plus a leading dot, and then compiles a wrapper like the one above
+for each of them.
+
+In recent years, vendors have begun to supply systems free of this
+inherent security bug. On such systems, when the kernel passes the name
+of the set-id script to open to the interpreter, rather than using a
+pathname subject to meddling, it instead passes I</dev/fd/3>. This is a
+special file already opened on the script, so that there can be no race
+condition for evil scripts to exploit. On these systems, Perl should be
+compiled with C<-DSETUID_SCRIPTS_ARE_SECURE_NOW>. The B<Configure>
+program that builds Perl tries to figure this out for itself, so you
+should never have to specify this yourself. Most modern releases of
+SysVr4 and BSD 4.4 use this approach to avoid the kernel race condition.
+
+Prior to release 5.003 of Perl, a bug in the code of B<suidperl> could
+introduce a security hole in systems compiled with strict POSIX
+compliance.
+
+=head2 Protecting Your Programs
+
+There are a number of ways to hide the source to your Perl programs,
+with varying levels of "security".
+
+First of all, however, you I<can't> take away read permission, because
+the source code has to be readable in order to be compiled and
+interpreted. (That doesn't mean that a CGI script's source is
+readable by people on the web, though.) So you have to leave the
+permissions at the socially friendly 0755 level. This lets
+people on your local system only see your source.
+
+Some people mistakenly regard this as a security problem. If your program does
+insecure things, and relies on people not knowing how to exploit those
+insecurities, it is not secure. It is often possible for someone to
+determine the insecure things and exploit them without viewing the
+source. Security through obscurity, the name for hiding your bugs
+instead of fixing them, is little security indeed.
+
+You can try using encryption via source filters (Filter::* from CPAN).
+But crackers might be able to decrypt it. You can try using the
+byte code compiler and interpreter described below, but crackers might
+be able to de-compile it. You can try using the native-code compiler
+described below, but crackers might be able to disassemble it. These
+pose varying degrees of difficulty to people wanting to get at your
+code, but none can definitively conceal it (this is true of every
+language, not just Perl).
+
+If you're concerned about people profiting from your code, then the
+bottom line is that nothing but a restrictive licence will give you
+legal security. License your software and pepper it with threatening
+statements like "This is unpublished proprietary software of XYZ Corp.
+Your access to it does not give you permission to use it blah blah
+blah." You should see a lawyer to be sure your licence's wording will
+stand up in court.
+
+=head1 SEE ALSO
+
+L<perlrun> for its description of cleaning up environment variables.
diff --git a/contrib/perl5/pod/perlstyle.pod b/contrib/perl5/pod/perlstyle.pod
new file mode 100644
index 0000000..cf280ce
--- /dev/null
+++ b/contrib/perl5/pod/perlstyle.pod
@@ -0,0 +1,275 @@
+=head1 NAME
+
+perlstyle - Perl style guide
+
+=head1 DESCRIPTION
+
+Each programmer will, of course, have his or her own preferences in
+regards to formatting, but there are some general guidelines that will
+make your programs easier to read, understand, and maintain.
+
+The most important thing is to run your programs under the B<-w>
+flag at all times. You may turn it off explicitly for particular
+portions of code via the C<$^W> variable if you must. You should
+also always run under C<use strict> or know the reason why not.
+The C<use sigtrap> and even C<use diagnostics> pragmas may also prove
+useful.
+
+Regarding aesthetics of code lay out, about the only thing Larry
+cares strongly about is that the closing curly brace of
+a multi-line BLOCK should line up with the keyword that started the construct.
+Beyond that, he has other preferences that aren't so strong:
+
+=over 4
+
+=item *
+
+4-column indent.
+
+=item *
+
+Opening curly on same line as keyword, if possible, otherwise line up.
+
+=item *
+
+Space before the opening curly of a multi-line BLOCK.
+
+=item *
+
+One-line BLOCK may be put on one line, including curlies.
+
+=item *
+
+No space before the semicolon.
+
+=item *
+
+Semicolon omitted in "short" one-line BLOCK.
+
+=item *
+
+Space around most operators.
+
+=item *
+
+Space around a "complex" subscript (inside brackets).
+
+=item *
+
+Blank lines between chunks that do different things.
+
+=item *
+
+Uncuddled elses.
+
+=item *
+
+No space between function name and its opening parenthesis.
+
+=item *
+
+Space after each comma.
+
+=item *
+
+Long lines broken after an operator (except "and" and "or").
+
+=item *
+
+Space after last parenthesis matching on current line.
+
+=item *
+
+Line up corresponding items vertically.
+
+=item *
+
+Omit redundant punctuation as long as clarity doesn't suffer.
+
+=back
+
+Larry has his reasons for each of these things, but he doesn't claim that
+everyone else's mind works the same as his does.
+
+Here are some other more substantive style issues to think about:
+
+=over 4
+
+=item *
+
+Just because you I<CAN> do something a particular way doesn't mean that
+you I<SHOULD> do it that way. Perl is designed to give you several
+ways to do anything, so consider picking the most readable one. For
+instance
+
+ open(FOO,$foo) || die "Can't open $foo: $!";
+
+is better than
+
+ die "Can't open $foo: $!" unless open(FOO,$foo);
+
+because the second way hides the main point of the statement in a
+modifier. On the other hand
+
+ print "Starting analysis\n" if $verbose;
+
+is better than
+
+ $verbose && print "Starting analysis\n";
+
+because the main point isn't whether the user typed B<-v> or not.
+
+Similarly, just because an operator lets you assume default arguments
+doesn't mean that you have to make use of the defaults. The defaults
+are there for lazy systems programmers writing one-shot programs. If
+you want your program to be readable, consider supplying the argument.
+
+Along the same lines, just because you I<CAN> omit parentheses in many
+places doesn't mean that you ought to:
+
+ return print reverse sort num values %array;
+ return print(reverse(sort num (values(%array))));
+
+When in doubt, parenthesize. At the very least it will let some poor
+schmuck bounce on the % key in B<vi>.
+
+Even if you aren't in doubt, consider the mental welfare of the person
+who has to maintain the code after you, and who will probably put
+parentheses in the wrong place.
+
+=item *
+
+Don't go through silly contortions to exit a loop at the top or the
+bottom, when Perl provides the C<last> operator so you can exit in
+the middle. Just "outdent" it a little to make it more visible:
+
+ LINE:
+ for (;;) {
+ statements;
+ last LINE if $foo;
+ next LINE if /^#/;
+ statements;
+ }
+
+=item *
+
+Don't be afraid to use loop labels--they're there to enhance
+readability as well as to allow multilevel loop breaks. See the
+previous example.
+
+=item *
+
+Avoid using grep() (or map()) or `backticks` in a void context, that is,
+when you just throw away their return values. Those functions all
+have return values, so use them. Otherwise use a foreach() loop or
+the system() function instead.
+
+=item *
+
+For portability, when using features that may not be implemented on
+every machine, test the construct in an eval to see if it fails. If
+you know what version or patchlevel a particular feature was
+implemented, you can test C<$]> (C<$PERL_VERSION> in C<English>) to see if it
+will be there. The C<Config> module will also let you interrogate values
+determined by the B<Configure> program when Perl was installed.
+
+=item *
+
+Choose mnemonic identifiers. If you can't remember what mnemonic means,
+you've got a problem.
+
+=item *
+
+While short identifiers like $gotit are probably ok, use underscores to
+separate words. It is generally easier to read $var_names_like_this than
+$VarNamesLikeThis, especially for non-native speakers of English. It's
+also a simple rule that works consistently with VAR_NAMES_LIKE_THIS.
+
+Package names are sometimes an exception to this rule. Perl informally
+reserves lowercase module names for "pragma" modules like C<integer> and
+C<strict>. Other modules should begin with a capital letter and use mixed
+case, but probably without underscores due to limitations in primitive
+file systems' representations of module names as files that must fit into a
+few sparse bytes.
+
+=item *
+
+You may find it helpful to use letter case to indicate the scope
+or nature of a variable. For example:
+
+ $ALL_CAPS_HERE constants only (beware clashes with perl vars!)
+ $Some_Caps_Here package-wide global/static
+ $no_caps_here function scope my() or local() variables
+
+Function and method names seem to work best as all lowercase.
+E.g., $obj-E<gt>as_string().
+
+You can use a leading underscore to indicate that a variable or
+function should not be used outside the package that defined it.
+
+=item *
+
+If you have a really hairy regular expression, use the C</x> modifier and
+put in some whitespace to make it look a little less like line noise.
+Don't use slash as a delimiter when your regexp has slashes or backslashes.
+
+=item *
+
+Use the new "and" and "or" operators to avoid having to parenthesize
+list operators so much, and to reduce the incidence of punctuation
+operators like C<&&> and C<||>. Call your subroutines as if they were
+functions or list operators to avoid excessive ampersands and parentheses.
+
+=item *
+
+Use here documents instead of repeated print() statements.
+
+=item *
+
+Line up corresponding things vertically, especially if it'd be too long
+to fit on one line anyway.
+
+ $IDX = $ST_MTIME;
+ $IDX = $ST_ATIME if $opt_u;
+ $IDX = $ST_CTIME if $opt_c;
+ $IDX = $ST_SIZE if $opt_s;
+
+ mkdir $tmpdir, 0700 or die "can't mkdir $tmpdir: $!";
+ chdir($tmpdir) or die "can't chdir $tmpdir: $!";
+ mkdir 'tmp', 0777 or die "can't mkdir $tmpdir/tmp: $!";
+
+=item *
+
+Always check the return codes of system calls. Good error messages should
+go to STDERR, include which program caused the problem, what the failed
+system call and arguments were, and (VERY IMPORTANT) should contain the
+standard system error message for what went wrong. Here's a simple but
+sufficient example:
+
+ opendir(D, $dir) or die "can't opendir $dir: $!";
+
+=item *
+
+Line up your transliterations when it makes sense:
+
+ tr [abc]
+ [xyz];
+
+=item *
+
+Think about reusability. Why waste brainpower on a one-shot when you
+might want to do something like it again? Consider generalizing your
+code. Consider writing a module or object class. Consider making your
+code run cleanly with C<use strict> and B<-w> in effect. Consider giving away
+your code. Consider changing your whole world view. Consider... oh,
+never mind.
+
+=item *
+
+Be consistent.
+
+=item *
+
+Be nice.
+
+=back
diff --git a/contrib/perl5/pod/perlsub.pod b/contrib/perl5/pod/perlsub.pod
new file mode 100644
index 0000000..957b3d8
--- /dev/null
+++ b/contrib/perl5/pod/perlsub.pod
@@ -0,0 +1,1149 @@
+=head1 NAME
+
+perlsub - Perl subroutines
+
+=head1 SYNOPSIS
+
+To declare subroutines:
+
+ sub NAME; # A "forward" declaration.
+ sub NAME(PROTO); # ditto, but with prototypes
+
+ sub NAME BLOCK # A declaration and a definition.
+ sub NAME(PROTO) BLOCK # ditto, but with prototypes
+
+To define an anonymous subroutine at runtime:
+
+ $subref = sub BLOCK; # no proto
+ $subref = sub (PROTO) BLOCK; # with proto
+
+To import subroutines:
+
+ use PACKAGE qw(NAME1 NAME2 NAME3);
+
+To call subroutines:
+
+ NAME(LIST); # & is optional with parentheses.
+ NAME LIST; # Parentheses optional if predeclared/imported.
+ &NAME; # Makes current @_ visible to called subroutine.
+
+=head1 DESCRIPTION
+
+Like many languages, Perl provides for user-defined subroutines. These
+may be located anywhere in the main program, loaded in from other files
+via the C<do>, C<require>, or C<use> keywords, or even generated on the
+fly using C<eval> or anonymous subroutines (closures). You can even call
+a function indirectly using a variable containing its name or a CODE reference
+to it.
+
+The Perl model for function call and return values is simple: all
+functions are passed as parameters one single flat list of scalars, and
+all functions likewise return to their caller one single flat list of
+scalars. Any arrays or hashes in these call and return lists will
+collapse, losing their identities--but you may always use
+pass-by-reference instead to avoid this. Both call and return lists may
+contain as many or as few scalar elements as you'd like. (Often a
+function without an explicit return statement is called a subroutine, but
+there's really no difference from the language's perspective.)
+
+Any arguments passed to the routine come in as the array C<@_>. Thus if you
+called a function with two arguments, those would be stored in C<$_[0]>
+and C<$_[1]>. The array C<@_> is a local array, but its elements are
+aliases for the actual scalar parameters. In particular, if an element
+C<$_[0]> is updated, the corresponding argument is updated (or an error
+occurs if it is not updatable). If an argument is an array or hash
+element which did not exist when the function was called, that element is
+created only when (and if) it is modified or if a reference to it is
+taken. (Some earlier versions of Perl created the element whether or not
+it was assigned to.) Note that assigning to the whole array C<@_> removes
+the aliasing, and does not update any arguments.
+
+The return value of the subroutine is the value of the last expression
+evaluated. Alternatively, a C<return> statement may be used to exit the
+subroutine, optionally specifying the returned value, which will be
+evaluated in the appropriate context (list, scalar, or void) depending
+on the context of the subroutine call. If you specify no return value,
+the subroutine will return an empty list in a list context, an undefined
+value in a scalar context, or nothing in a void context. If you return
+one or more arrays and/or hashes, these will be flattened together into
+one large indistinguishable list.
+
+Perl does not have named formal parameters, but in practice all you do is
+assign to a C<my()> list of these. Any variables you use in the function
+that aren't declared private are global variables. For the gory details
+on creating private variables, see
+L<"Private Variables via my()"> and L<"Temporary Values via local()">.
+To create protected environments for a set of functions in a separate
+package (and probably a separate file), see L<perlmod/"Packages">.
+
+Example:
+
+ sub max {
+ my $max = shift(@_);
+ foreach $foo (@_) {
+ $max = $foo if $max < $foo;
+ }
+ return $max;
+ }
+ $bestday = max($mon,$tue,$wed,$thu,$fri);
+
+Example:
+
+ # get a line, combining continuation lines
+ # that start with whitespace
+
+ sub get_line {
+ $thisline = $lookahead; # GLOBAL VARIABLES!!
+ LINE: while (defined($lookahead = <STDIN>)) {
+ if ($lookahead =~ /^[ \t]/) {
+ $thisline .= $lookahead;
+ }
+ else {
+ last LINE;
+ }
+ }
+ $thisline;
+ }
+
+ $lookahead = <STDIN>; # get first line
+ while ($_ = get_line()) {
+ ...
+ }
+
+Use array assignment to a local list to name your formal arguments:
+
+ sub maybeset {
+ my($key, $value) = @_;
+ $Foo{$key} = $value unless $Foo{$key};
+ }
+
+This also has the effect of turning call-by-reference into call-by-value,
+because the assignment copies the values. Otherwise a function is free to
+do in-place modifications of C<@_> and change its caller's values.
+
+ upcase_in($v1, $v2); # this changes $v1 and $v2
+ sub upcase_in {
+ for (@_) { tr/a-z/A-Z/ }
+ }
+
+You aren't allowed to modify constants in this way, of course. If an
+argument were actually literal and you tried to change it, you'd take a
+(presumably fatal) exception. For example, this won't work:
+
+ upcase_in("frederick");
+
+It would be much safer if the C<upcase_in()> function
+were written to return a copy of its parameters instead
+of changing them in place:
+
+ ($v3, $v4) = upcase($v1, $v2); # this doesn't
+ sub upcase {
+ return unless defined wantarray; # void context, do nothing
+ my @parms = @_;
+ for (@parms) { tr/a-z/A-Z/ }
+ return wantarray ? @parms : $parms[0];
+ }
+
+Notice how this (unprototyped) function doesn't care whether it was passed
+real scalars or arrays. Perl will see everything as one big long flat C<@_>
+parameter list. This is one of the ways where Perl's simple
+argument-passing style shines. The C<upcase()> function would work perfectly
+well without changing the C<upcase()> definition even if we fed it things
+like this:
+
+ @newlist = upcase(@list1, @list2);
+ @newlist = upcase( split /:/, $var );
+
+Do not, however, be tempted to do this:
+
+ (@a, @b) = upcase(@list1, @list2);
+
+Because like its flat incoming parameter list, the return list is also
+flat. So all you have managed to do here is stored everything in C<@a> and
+made C<@b> an empty list. See L<Pass by Reference> for alternatives.
+
+A subroutine may be called using the "C<&>" prefix. The "C<&>" is optional
+in modern Perls, and so are the parentheses if the subroutine has been
+predeclared. (Note, however, that the "C<&>" is I<NOT> optional when
+you're just naming the subroutine, such as when it's used as an
+argument to C<defined()> or C<undef()>. Nor is it optional when you want to
+do an indirect subroutine call with a subroutine name or reference
+using the C<&$subref()> or C<&{$subref}()> constructs. See L<perlref>
+for more on that.)
+
+Subroutines may be called recursively. If a subroutine is called using
+the "C<&>" form, the argument list is optional, and if omitted, no C<@_> array is
+set up for the subroutine: the C<@_> array at the time of the call is
+visible to subroutine instead. This is an efficiency mechanism that
+new users may wish to avoid.
+
+ &foo(1,2,3); # pass three arguments
+ foo(1,2,3); # the same
+
+ foo(); # pass a null list
+ &foo(); # the same
+
+ &foo; # foo() get current args, like foo(@_) !!
+ foo; # like foo() IFF sub foo predeclared, else "foo"
+
+Not only does the "C<&>" form make the argument list optional, but it also
+disables any prototype checking on the arguments you do provide. This
+is partly for historical reasons, and partly for having a convenient way
+to cheat if you know what you're doing. See the section on Prototypes below.
+
+Function whose names are in all upper case are reserved to the Perl core,
+just as are modules whose names are in all lower case. A function in
+all capitals is a loosely-held convention meaning it will be called
+indirectly by the run-time system itself. Functions that do special,
+pre-defined things are C<BEGIN>, C<END>, C<AUTOLOAD>, and C<DESTROY>--plus all the
+functions mentioned in L<perltie>. The 5.005 release adds C<INIT>
+to this list.
+
+=head2 Private Variables via C<my()>
+
+Synopsis:
+
+ my $foo; # declare $foo lexically local
+ my (@wid, %get); # declare list of variables local
+ my $foo = "flurp"; # declare $foo lexical, and init it
+ my @oof = @bar; # declare @oof lexical, and init it
+
+A "C<my>" declares the listed variables to be confined (lexically) to the
+enclosing block, conditional (C<if/unless/elsif/else>), loop
+(C<for/foreach/while/until/continue>), subroutine, C<eval>, or
+C<do/require/use>'d file. If more than one value is listed, the list
+must be placed in parentheses. All listed elements must be legal lvalues.
+Only alphanumeric identifiers may be lexically scoped--magical
+builtins like C<$/> must currently be C<local>ize with "C<local>" instead.
+
+Unlike dynamic variables created by the "C<local>" operator, lexical
+variables declared with "C<my>" are totally hidden from the outside world,
+including any called subroutines (even if it's the same subroutine called
+from itself or elsewhere--every call gets its own copy).
+
+This doesn't mean that a C<my()> variable declared in a statically
+I<enclosing> lexical scope would be invisible. Only the dynamic scopes
+are cut off. For example, the C<bumpx()> function below has access to the
+lexical C<$x> variable because both the my and the sub occurred at the same
+scope, presumably the file scope.
+
+ my $x = 10;
+ sub bumpx { $x++ }
+
+(An C<eval()>, however, can see the lexical variables of the scope it is
+being evaluated in so long as the names aren't hidden by declarations within
+the C<eval()> itself. See L<perlref>.)
+
+The parameter list to C<my()> may be assigned to if desired, which allows you
+to initialize your variables. (If no initializer is given for a
+particular variable, it is created with the undefined value.) Commonly
+this is used to name the parameters to a subroutine. Examples:
+
+ $arg = "fred"; # "global" variable
+ $n = cube_root(27);
+ print "$arg thinks the root is $n\n";
+ fred thinks the root is 3
+
+ sub cube_root {
+ my $arg = shift; # name doesn't matter
+ $arg **= 1/3;
+ return $arg;
+ }
+
+The "C<my>" is simply a modifier on something you might assign to. So when
+you do assign to the variables in its argument list, the "C<my>" doesn't
+change whether those variables are viewed as a scalar or an array. So
+
+ my ($foo) = <STDIN>; # WRONG?
+ my @FOO = <STDIN>;
+
+both supply a list context to the right-hand side, while
+
+ my $foo = <STDIN>;
+
+supplies a scalar context. But the following declares only one variable:
+
+ my $foo, $bar = 1; # WRONG
+
+That has the same effect as
+
+ my $foo;
+ $bar = 1;
+
+The declared variable is not introduced (is not visible) until after
+the current statement. Thus,
+
+ my $x = $x;
+
+can be used to initialize the new $x with the value of the old C<$x>, and
+the expression
+
+ my $x = 123 and $x == 123
+
+is false unless the old C<$x> happened to have the value C<123>.
+
+Lexical scopes of control structures are not bounded precisely by the
+braces that delimit their controlled blocks; control expressions are
+part of the scope, too. Thus in the loop
+
+ while (defined(my $line = <>)) {
+ $line = lc $line;
+ } continue {
+ print $line;
+ }
+
+the scope of C<$line> extends from its declaration throughout the rest of
+the loop construct (including the C<continue> clause), but not beyond
+it. Similarly, in the conditional
+
+ if ((my $answer = <STDIN>) =~ /^yes$/i) {
+ user_agrees();
+ } elsif ($answer =~ /^no$/i) {
+ user_disagrees();
+ } else {
+ chomp $answer;
+ die "'$answer' is neither 'yes' nor 'no'";
+ }
+
+the scope of C<$answer> extends from its declaration throughout the rest
+of the conditional (including C<elsif> and C<else> clauses, if any),
+but not beyond it.
+
+(None of the foregoing applies to C<if/unless> or C<while/until>
+modifiers appended to simple statements. Such modifiers are not
+control structures and have no effect on scoping.)
+
+The C<foreach> loop defaults to scoping its index variable dynamically
+(in the manner of C<local>; see below). However, if the index
+variable is prefixed with the keyword "C<my>", then it is lexically
+scoped instead. Thus in the loop
+
+ for my $i (1, 2, 3) {
+ some_function();
+ }
+
+the scope of C<$i> extends to the end of the loop, but not beyond it, and
+so the value of C<$i> is unavailable in C<some_function()>.
+
+Some users may wish to encourage the use of lexically scoped variables.
+As an aid to catching implicit references to package variables,
+if you say
+
+ use strict 'vars';
+
+then any variable reference from there to the end of the enclosing
+block must either refer to a lexical variable, or must be fully
+qualified with the package name. A compilation error results
+otherwise. An inner block may countermand this with S<"C<no strict 'vars'>">.
+
+A C<my()> has both a compile-time and a run-time effect. At compile time,
+the compiler takes notice of it; the principle usefulness of this is to
+quiet S<"C<use strict 'vars'>">. The actual initialization is delayed until
+run time, so it gets executed appropriately; every time through a loop,
+for example.
+
+Variables declared with "C<my>" are not part of any package and are therefore
+never fully qualified with the package name. In particular, you're not
+allowed to try to make a package variable (or other global) lexical:
+
+ my $pack::var; # ERROR! Illegal syntax
+ my $_; # also illegal (currently)
+
+In fact, a dynamic variable (also known as package or global variables)
+are still accessible using the fully qualified C<::> notation even while a
+lexical of the same name is also visible:
+
+ package main;
+ local $x = 10;
+ my $x = 20;
+ print "$x and $::x\n";
+
+That will print out C<20> and C<10>.
+
+You may declare "C<my>" variables at the outermost scope of a file to hide
+any such identifiers totally from the outside world. This is similar
+to C's static variables at the file level. To do this with a subroutine
+requires the use of a closure (anonymous function with lexical access).
+If a block (such as an C<eval()>, function, or C<package>) wants to create
+a private subroutine that cannot be called from outside that block,
+it can declare a lexical variable containing an anonymous sub reference:
+
+ my $secret_version = '1.001-beta';
+ my $secret_sub = sub { print $secret_version };
+ &$secret_sub();
+
+As long as the reference is never returned by any function within the
+module, no outside module can see the subroutine, because its name is not in
+any package's symbol table. Remember that it's not I<REALLY> called
+C<$some_pack::secret_version> or anything; it's just C<$secret_version>,
+unqualified and unqualifiable.
+
+This does not work with object methods, however; all object methods have
+to be in the symbol table of some package to be found.
+
+=head2 Peristent Private Variables
+
+Just because a lexical variable is lexically (also called statically)
+scoped to its enclosing block, C<eval>, or C<do> FILE, this doesn't mean that
+within a function it works like a C static. It normally works more
+like a C auto, but with implicit garbage collection.
+
+Unlike local variables in C or C++, Perl's lexical variables don't
+necessarily get recycled just because their scope has exited.
+If something more permanent is still aware of the lexical, it will
+stick around. So long as something else references a lexical, that
+lexical won't be freed--which is as it should be. You wouldn't want
+memory being free until you were done using it, or kept around once you
+were done. Automatic garbage collection takes care of this for you.
+
+This means that you can pass back or save away references to lexical
+variables, whereas to return a pointer to a C auto is a grave error.
+It also gives us a way to simulate C's function statics. Here's a
+mechanism for giving a function private variables with both lexical
+scoping and a static lifetime. If you do want to create something like
+C's static variables, just enclose the whole function in an extra block,
+and put the static variable outside the function but in the block.
+
+ {
+ my $secret_val = 0;
+ sub gimme_another {
+ return ++$secret_val;
+ }
+ }
+ # $secret_val now becomes unreachable by the outside
+ # world, but retains its value between calls to gimme_another
+
+If this function is being sourced in from a separate file
+via C<require> or C<use>, then this is probably just fine. If it's
+all in the main program, you'll need to arrange for the C<my()>
+to be executed early, either by putting the whole block above
+your main program, or more likely, placing merely a C<BEGIN>
+sub around it to make sure it gets executed before your program
+starts to run:
+
+ sub BEGIN {
+ my $secret_val = 0;
+ sub gimme_another {
+ return ++$secret_val;
+ }
+ }
+
+See L<perlmod/"Package Constructors and Destructors"> about the C<BEGIN> function.
+
+If declared at the outermost scope, the file scope, then lexicals work
+someone like C's file statics. They are available to all functions in
+that same file declared below them, but are inaccessible from outside of
+the file. This is sometimes used in modules to create private variables
+for the whole module.
+
+=head2 Temporary Values via local()
+
+B<NOTE>: In general, you should be using "C<my>" instead of "C<local>", because
+it's faster and safer. Exceptions to this include the global punctuation
+variables, filehandles and formats, and direct manipulation of the Perl
+symbol table itself. Format variables often use "C<local>" though, as do
+other variables whose current value must be visible to called
+subroutines.
+
+Synopsis:
+
+ local $foo; # declare $foo dynamically local
+ local (@wid, %get); # declare list of variables local
+ local $foo = "flurp"; # declare $foo dynamic, and init it
+ local @oof = @bar; # declare @oof dynamic, and init it
+
+ local *FH; # localize $FH, @FH, %FH, &FH ...
+ local *merlyn = *randal; # now $merlyn is really $randal, plus
+ # @merlyn is really @randal, etc
+ local *merlyn = 'randal'; # SAME THING: promote 'randal' to *randal
+ local *merlyn = \$randal; # just alias $merlyn, not @merlyn etc
+
+A C<local()> modifies its listed variables to be "local" to the enclosing
+block, C<eval>, or C<do FILE>--and to I<any subroutine called from within that block>.
+A C<local()> just gives temporary values to global (meaning package)
+variables. It does B<not> create a local variable. This is known as
+dynamic scoping. Lexical scoping is done with "C<my>", which works more
+like C's auto declarations.
+
+If more than one variable is given to C<local()>, they must be placed in
+parentheses. All listed elements must be legal lvalues. This operator works
+by saving the current values of those variables in its argument list on a
+hidden stack and restoring them upon exiting the block, subroutine, or
+eval. This means that called subroutines can also reference the local
+variable, but not the global one. The argument list may be assigned to if
+desired, which allows you to initialize your local variables. (If no
+initializer is given for a particular variable, it is created with an
+undefined value.) Commonly this is used to name the parameters to a
+subroutine. Examples:
+
+ for $i ( 0 .. 9 ) {
+ $digits{$i} = $i;
+ }
+ # assume this function uses global %digits hash
+ parse_num();
+
+ # now temporarily add to %digits hash
+ if ($base12) {
+ # (NOTE: not claiming this is efficient!)
+ local %digits = (%digits, 't' => 10, 'e' => 11);
+ parse_num(); # parse_num gets this new %digits!
+ }
+ # old %digits restored here
+
+Because C<local()> is a run-time command, it gets executed every time
+through a loop. In releases of Perl previous to 5.0, this used more stack
+storage each time until the loop was exited. Perl now reclaims the space
+each time through, but it's still more efficient to declare your variables
+outside the loop.
+
+A C<local> is simply a modifier on an lvalue expression. When you assign to
+a C<local>ized variable, the C<local> doesn't change whether its list is viewed
+as a scalar or an array. So
+
+ local($foo) = <STDIN>;
+ local @FOO = <STDIN>;
+
+both supply a list context to the right-hand side, while
+
+ local $foo = <STDIN>;
+
+supplies a scalar context.
+
+A note about C<local()> and composite types is in order. Something
+like C<local(%foo)> works by temporarily placing a brand new hash in
+the symbol table. The old hash is left alone, but is hidden "behind"
+the new one.
+
+This means the old variable is completely invisible via the symbol
+table (i.e. the hash entry in the C<*foo> typeglob) for the duration
+of the dynamic scope within which the C<local()> was seen. This
+has the effect of allowing one to temporarily occlude any magic on
+composite types. For instance, this will briefly alter a tied
+hash to some other implementation:
+
+ tie %ahash, 'APackage';
+ [...]
+ {
+ local %ahash;
+ tie %ahash, 'BPackage';
+ [..called code will see %ahash tied to 'BPackage'..]
+ {
+ local %ahash;
+ [..%ahash is a normal (untied) hash here..]
+ }
+ }
+ [..%ahash back to its initial tied self again..]
+
+As another example, a custom implementation of C<%ENV> might look
+like this:
+
+ {
+ local %ENV;
+ tie %ENV, 'MyOwnEnv';
+ [..do your own fancy %ENV manipulation here..]
+ }
+ [..normal %ENV behavior here..]
+
+It's also worth taking a moment to explain what happens when you
+C<local>ize a member of a composite type (i.e. an array or hash element).
+In this case, the element is C<local>ized I<by name>. This means that
+when the scope of the C<local()> ends, the saved value will be
+restored to the hash element whose key was named in the C<local()>, or
+the array element whose index was named in the C<local()>. If that
+element was deleted while the C<local()> was in effect (e.g. by a
+C<delete()> from a hash or a C<shift()> of an array), it will spring
+back into existence, possibly extending an array and filling in the
+skipped elements with C<undef>. For instance, if you say
+
+ %hash = ( 'This' => 'is', 'a' => 'test' );
+ @ary = ( 0..5 );
+ {
+ local($ary[5]) = 6;
+ local($hash{'a'}) = 'drill';
+ while (my $e = pop(@ary)) {
+ print "$e . . .\n";
+ last unless $e > 3;
+ }
+ if (@ary) {
+ $hash{'only a'} = 'test';
+ delete $hash{'a'};
+ }
+ }
+ print join(' ', map { "$_ $hash{$_}" } sort keys %hash),".\n";
+ print "The array has ",scalar(@ary)," elements: ",
+ join(', ', map { defined $_ ? $_ : 'undef' } @ary),"\n";
+
+Perl will print
+
+ 6 . . .
+ 4 . . .
+ 3 . . .
+ This is a test only a test.
+ The array has 6 elements: 0, 1, 2, undef, undef, 5
+
+=head2 Passing Symbol Table Entries (typeglobs)
+
+[Note: The mechanism described in this section was originally the only
+way to simulate pass-by-reference in older versions of Perl. While it
+still works fine in modern versions, the new reference mechanism is
+generally easier to work with. See below.]
+
+Sometimes you don't want to pass the value of an array to a subroutine
+but rather the name of it, so that the subroutine can modify the global
+copy of it rather than working with a local copy. In perl you can
+refer to all objects of a particular name by prefixing the name
+with a star: C<*foo>. This is often known as a "typeglob", because the
+star on the front can be thought of as a wildcard match for all the
+funny prefix characters on variables and subroutines and such.
+
+When evaluated, the typeglob produces a scalar value that represents
+all the objects of that name, including any filehandle, format, or
+subroutine. When assigned to, it causes the name mentioned to refer to
+whatever "C<*>" value was assigned to it. Example:
+
+ sub doubleary {
+ local(*someary) = @_;
+ foreach $elem (@someary) {
+ $elem *= 2;
+ }
+ }
+ doubleary(*foo);
+ doubleary(*bar);
+
+Note that scalars are already passed by reference, so you can modify
+scalar arguments without using this mechanism by referring explicitly
+to C<$_[0]> etc. You can modify all the elements of an array by passing
+all the elements as scalars, but you have to use the C<*> mechanism (or
+the equivalent reference mechanism) to C<push>, C<pop>, or change the size of
+an array. It will certainly be faster to pass the typeglob (or reference).
+
+Even if you don't want to modify an array, this mechanism is useful for
+passing multiple arrays in a single LIST, because normally the LIST
+mechanism will merge all the array values so that you can't extract out
+the individual arrays. For more on typeglobs, see
+L<perldata/"Typeglobs and Filehandles">.
+
+=head2 When to Still Use local()
+
+Despite the existence of C<my()>, there are still three places where the
+C<local()> operator still shines. In fact, in these three places, you
+I<must> use C<local> instead of C<my>.
+
+=over
+
+=item 1. You need to give a global variable a temporary value, especially C<$_>.
+
+The global variables, like C<@ARGV> or the punctuation variables, must be
+C<local>ized with C<local()>. This block reads in F</etc/motd>, and splits
+it up into chunks separated by lines of equal signs, which are placed
+in C<@Fields>.
+
+ {
+ local @ARGV = ("/etc/motd");
+ local $/ = undef;
+ local $_ = <>;
+ @Fields = split /^\s*=+\s*$/;
+ }
+
+It particular, it's important to C<local>ize C<$_> in any routine that assigns
+to it. Look out for implicit assignments in C<while> conditionals.
+
+=item 2. You need to create a local file or directory handle or a local function.
+
+A function that needs a filehandle of its own must use C<local()> uses
+C<local()> on complete typeglob. This can be used to create new symbol
+table entries:
+
+ sub ioqueue {
+ local (*READER, *WRITER); # not my!
+ pipe (READER, WRITER); or die "pipe: $!";
+ return (*READER, *WRITER);
+ }
+ ($head, $tail) = ioqueue();
+
+See the Symbol module for a way to create anonymous symbol table
+entries.
+
+Because assignment of a reference to a typeglob creates an alias, this
+can be used to create what is effectively a local function, or at least,
+a local alias.
+
+ {
+ local *grow = \&shrink; # only until this block exists
+ grow(); # really calls shrink()
+ move(); # if move() grow()s, it shrink()s too
+ }
+ grow(); # get the real grow() again
+
+See L<perlref/"Function Templates"> for more about manipulating
+functions by name in this way.
+
+=item 3. You want to temporarily change just one element of an array or hash.
+
+You can C<local>ize just one element of an aggregate. Usually this
+is done on dynamics:
+
+ {
+ local $SIG{INT} = 'IGNORE';
+ funct(); # uninterruptible
+ }
+ # interruptibility automatically restored here
+
+But it also works on lexically declared aggregates. Prior to 5.005,
+this operation could on occasion misbehave.
+
+=back
+
+=head2 Pass by Reference
+
+If you want to pass more than one array or hash into a function--or
+return them from it--and have them maintain their integrity, then
+you're going to have to use an explicit pass-by-reference. Before you
+do that, you need to understand references as detailed in L<perlref>.
+This section may not make much sense to you otherwise.
+
+Here are a few simple examples. First, let's pass in several
+arrays to a function and have it C<pop> all of then, return a new
+list of all their former last elements:
+
+ @tailings = popmany ( \@a, \@b, \@c, \@d );
+
+ sub popmany {
+ my $aref;
+ my @retlist = ();
+ foreach $aref ( @_ ) {
+ push @retlist, pop @$aref;
+ }
+ return @retlist;
+ }
+
+Here's how you might write a function that returns a
+list of keys occurring in all the hashes passed to it:
+
+ @common = inter( \%foo, \%bar, \%joe );
+ sub inter {
+ my ($k, $href, %seen); # locals
+ foreach $href (@_) {
+ while ( $k = each %$href ) {
+ $seen{$k}++;
+ }
+ }
+ return grep { $seen{$_} == @_ } keys %seen;
+ }
+
+So far, we're using just the normal list return mechanism.
+What happens if you want to pass or return a hash? Well,
+if you're using only one of them, or you don't mind them
+concatenating, then the normal calling convention is ok, although
+a little expensive.
+
+Where people get into trouble is here:
+
+ (@a, @b) = func(@c, @d);
+or
+ (%a, %b) = func(%c, %d);
+
+That syntax simply won't work. It sets just C<@a> or C<%a> and clears the C<@b> or
+C<%b>. Plus the function didn't get passed into two separate arrays or
+hashes: it got one long list in C<@_>, as always.
+
+If you can arrange for everyone to deal with this through references, it's
+cleaner code, although not so nice to look at. Here's a function that
+takes two array references as arguments, returning the two array elements
+in order of how many elements they have in them:
+
+ ($aref, $bref) = func(\@c, \@d);
+ print "@$aref has more than @$bref\n";
+ sub func {
+ my ($cref, $dref) = @_;
+ if (@$cref > @$dref) {
+ return ($cref, $dref);
+ } else {
+ return ($dref, $cref);
+ }
+ }
+
+It turns out that you can actually do this also:
+
+ (*a, *b) = func(\@c, \@d);
+ print "@a has more than @b\n";
+ sub func {
+ local (*c, *d) = @_;
+ if (@c > @d) {
+ return (\@c, \@d);
+ } else {
+ return (\@d, \@c);
+ }
+ }
+
+Here we're using the typeglobs to do symbol table aliasing. It's
+a tad subtle, though, and also won't work if you're using C<my()>
+variables, because only globals (well, and C<local()>s) are in the symbol table.
+
+If you're passing around filehandles, you could usually just use the bare
+typeglob, like C<*STDOUT>, but typeglobs references would be better because
+they'll still work properly under S<C<use strict 'refs'>>. For example:
+
+ splutter(\*STDOUT);
+ sub splutter {
+ my $fh = shift;
+ print $fh "her um well a hmmm\n";
+ }
+
+ $rec = get_rec(\*STDIN);
+ sub get_rec {
+ my $fh = shift;
+ return scalar <$fh>;
+ }
+
+Another way to do this is using C<*HANDLE{IO}>, see L<perlref> for usage
+and caveats.
+
+If you're planning on generating new filehandles, you could do this:
+
+ sub openit {
+ my $name = shift;
+ local *FH;
+ return open (FH, $path) ? *FH : undef;
+ }
+
+Although that will actually produce a small memory leak. See the bottom
+of L<perlfunc/open()> for a somewhat cleaner way using the C<IO::Handle>
+package.
+
+=head2 Prototypes
+
+As of the 5.002 release of perl, if you declare
+
+ sub mypush (\@@)
+
+then C<mypush()> takes arguments exactly like C<push()> does. The declaration
+of the function to be called must be visible at compile time. The prototype
+affects only the interpretation of new-style calls to the function, where
+new-style is defined as not using the C<&> character. In other words,
+if you call it like a builtin function, then it behaves like a builtin
+function. If you call it like an old-fashioned subroutine, then it
+behaves like an old-fashioned subroutine. It naturally falls out from
+this rule that prototypes have no influence on subroutine references
+like C<\&foo> or on indirect subroutine calls like C<&{$subref}>.
+
+Method calls are not influenced by prototypes either, because the
+function to be called is indeterminate at compile time, because it depends
+on inheritance.
+
+Because the intent is primarily to let you define subroutines that work
+like builtin commands, here are the prototypes for some other functions
+that parse almost exactly like the corresponding builtins.
+
+ Declared as Called as
+
+ sub mylink ($$) mylink $old, $new
+ sub myvec ($$$) myvec $var, $offset, 1
+ sub myindex ($$;$) myindex &getstring, "substr"
+ sub mysyswrite ($$$;$) mysyswrite $buf, 0, length($buf) - $off, $off
+ sub myreverse (@) myreverse $a, $b, $c
+ sub myjoin ($@) myjoin ":", $a, $b, $c
+ sub mypop (\@) mypop @array
+ sub mysplice (\@$$@) mysplice @array, @array, 0, @pushme
+ sub mykeys (\%) mykeys %{$hashref}
+ sub myopen (*;$) myopen HANDLE, $name
+ sub mypipe (**) mypipe READHANDLE, WRITEHANDLE
+ sub mygrep (&@) mygrep { /foo/ } $a, $b, $c
+ sub myrand ($) myrand 42
+ sub mytime () mytime
+
+Any backslashed prototype character represents an actual argument
+that absolutely must start with that character. The value passed
+to the subroutine (as part of C<@_>) will be a reference to the
+actual argument given in the subroutine call, obtained by applying
+C<\> to that argument.
+
+Unbackslashed prototype characters have special meanings. Any
+unbackslashed C<@> or C<%> eats all the rest of the arguments, and forces
+list context. An argument represented by C<$> forces scalar context. An
+C<&> requires an anonymous subroutine, which, if passed as the first
+argument, does not require the "C<sub>" keyword or a subsequent comma. A
+C<*> does whatever it has to do to turn the argument into a reference to a
+symbol table entry.
+
+A semicolon separates mandatory arguments from optional arguments.
+(It is redundant before C<@> or C<%>.)
+
+Note how the last three examples above are treated specially by the parser.
+C<mygrep()> is parsed as a true list operator, C<myrand()> is parsed as a
+true unary operator with unary precedence the same as C<rand()>, and
+C<mytime()> is truly without arguments, just like C<time()>. That is, if you
+say
+
+ mytime +2;
+
+you'll get C<mytime() + 2>, not C<mytime(2)>, which is how it would be parsed
+without the prototype.
+
+The interesting thing about C<&> is that you can generate new syntax with it:
+
+ sub try (&@) {
+ my($try,$catch) = @_;
+ eval { &$try };
+ if ($@) {
+ local $_ = $@;
+ &$catch;
+ }
+ }
+ sub catch (&) { $_[0] }
+
+ try {
+ die "phooey";
+ } catch {
+ /phooey/ and print "unphooey\n";
+ };
+
+That prints C<"unphooey">. (Yes, there are still unresolved
+issues having to do with the visibility of C<@_>. I'm ignoring that
+question for the moment. (But note that if we make C<@_> lexically
+scoped, those anonymous subroutines can act like closures... (Gee,
+is this sounding a little Lispish? (Never mind.))))
+
+And here's a reimplementation of C<grep>:
+
+ sub mygrep (&@) {
+ my $code = shift;
+ my @result;
+ foreach $_ (@_) {
+ push(@result, $_) if &$code;
+ }
+ @result;
+ }
+
+Some folks would prefer full alphanumeric prototypes. Alphanumerics have
+been intentionally left out of prototypes for the express purpose of
+someday in the future adding named, formal parameters. The current
+mechanism's main goal is to let module writers provide better diagnostics
+for module users. Larry feels the notation quite understandable to Perl
+programmers, and that it will not intrude greatly upon the meat of the
+module, nor make it harder to read. The line noise is visually
+encapsulated into a small pill that's easy to swallow.
+
+It's probably best to prototype new functions, not retrofit prototyping
+into older ones. That's because you must be especially careful about
+silent impositions of differing list versus scalar contexts. For example,
+if you decide that a function should take just one parameter, like this:
+
+ sub func ($) {
+ my $n = shift;
+ print "you gave me $n\n";
+ }
+
+and someone has been calling it with an array or expression
+returning a list:
+
+ func(@foo);
+ func( split /:/ );
+
+Then you've just supplied an automatic C<scalar()> in front of their
+argument, which can be more than a bit surprising. The old C<@foo>
+which used to hold one thing doesn't get passed in. Instead,
+the C<func()> now gets passed in C<1>, that is, the number of elements
+in C<@foo>. And the C<split()> gets called in a scalar context and
+starts scribbling on your C<@_> parameter list.
+
+This is all very powerful, of course, and should be used only in moderation
+to make the world a better place.
+
+=head2 Constant Functions
+
+Functions with a prototype of C<()> are potential candidates for
+inlining. If the result after optimization and constant folding is
+either a constant or a lexically-scoped scalar which has no other
+references, then it will be used in place of function calls made
+without C<&> or C<do>. Calls made using C<&> or C<do> are never
+inlined. (See F<constant.pm> for an easy way to declare most
+constants.)
+
+The following functions would all be inlined:
+
+ sub pi () { 3.14159 } # Not exact, but close.
+ sub PI () { 4 * atan2 1, 1 } # As good as it gets,
+ # and it's inlined, too!
+ sub ST_DEV () { 0 }
+ sub ST_INO () { 1 }
+
+ sub FLAG_FOO () { 1 << 8 }
+ sub FLAG_BAR () { 1 << 9 }
+ sub FLAG_MASK () { FLAG_FOO | FLAG_BAR }
+
+ sub OPT_BAZ () { not (0x1B58 & FLAG_MASK) }
+ sub BAZ_VAL () {
+ if (OPT_BAZ) {
+ return 23;
+ }
+ else {
+ return 42;
+ }
+ }
+
+ sub N () { int(BAZ_VAL) / 3 }
+ BEGIN {
+ my $prod = 1;
+ for (1..N) { $prod *= $_ }
+ sub N_FACTORIAL () { $prod }
+ }
+
+If you redefine a subroutine that was eligible for inlining, you'll get
+a mandatory warning. (You can use this warning to tell whether or not a
+particular subroutine is considered constant.) The warning is
+considered severe enough not to be optional because previously compiled
+invocations of the function will still be using the old value of the
+function. If you need to be able to redefine the subroutine you need to
+ensure that it isn't inlined, either by dropping the C<()> prototype
+(which changes the calling semantics, so beware) or by thwarting the
+inlining mechanism in some other way, such as
+
+ sub not_inlined () {
+ 23 if $];
+ }
+
+=head2 Overriding Builtin Functions
+
+Many builtin functions may be overridden, though this should be tried
+only occasionally and for good reason. Typically this might be
+done by a package attempting to emulate missing builtin functionality
+on a non-Unix system.
+
+Overriding may be done only by importing the name from a
+module--ordinary predeclaration isn't good enough. However, the
+C<subs> pragma (compiler directive) lets you, in effect, predeclare subs
+via the import syntax, and these names may then override the builtin ones:
+
+ use subs 'chdir', 'chroot', 'chmod', 'chown';
+ chdir $somewhere;
+ sub chdir { ... }
+
+To unambiguously refer to the builtin form, one may precede the
+builtin name with the special package qualifier C<CORE::>. For example,
+saying C<CORE::open()> will always refer to the builtin C<open()>, even
+if the current package has imported some other subroutine called
+C<&open()> from elsewhere.
+
+Library modules should not in general export builtin names like "C<open>"
+or "C<chdir>" as part of their default C<@EXPORT> list, because these may
+sneak into someone else's namespace and change the semantics unexpectedly.
+Instead, if the module adds the name to the C<@EXPORT_OK> list, then it's
+possible for a user to import the name explicitly, but not implicitly.
+That is, they could say
+
+ use Module 'open';
+
+and it would import the C<open> override, but if they said
+
+ use Module;
+
+they would get the default imports without the overrides.
+
+The foregoing mechanism for overriding builtins is restricted, quite
+deliberately, to the package that requests the import. There is a second
+method that is sometimes applicable when you wish to override a builtin
+everywhere, without regard to namespace boundaries. This is achieved by
+importing a sub into the special namespace C<CORE::GLOBAL::>. Here is an
+example that quite brazenly replaces the C<glob> operator with something
+that understands regular expressions.
+
+ package REGlob;
+ require Exporter;
+ @ISA = 'Exporter';
+ @EXPORT_OK = 'glob';
+
+ sub import {
+ my $pkg = shift;
+ return unless @_;
+ my $sym = shift;
+ my $where = ($sym =~ s/^GLOBAL_// ? 'CORE::GLOBAL' : caller(0));
+ $pkg->export($where, $sym, @_);
+ }
+
+ sub glob {
+ my $pat = shift;
+ my @got;
+ local(*D);
+ if (opendir D, '.') { @got = grep /$pat/, readdir D; closedir D; }
+ @got;
+ }
+ 1;
+
+And here's how it could be (ab)used:
+
+ #use REGlob 'GLOBAL_glob'; # override glob() in ALL namespaces
+ package Foo;
+ use REGlob 'glob'; # override glob() in Foo:: only
+ print for <^[a-z_]+\.pm\$>; # show all pragmatic modules
+
+Note that the initial comment shows a contrived, even dangerous example.
+By overriding C<glob> globally, you would be forcing the new (and
+subversive) behavior for the C<glob> operator for B<every> namespace,
+without the complete cognizance or cooperation of the modules that own
+those namespaces. Naturally, this should be done with extreme caution--if
+it must be done at all.
+
+The C<REGlob> example above does not implement all the support needed to
+cleanly override perl's C<glob> operator. The builtin C<glob> has
+different behaviors depending on whether it appears in a scalar or list
+context, but our C<REGlob> doesn't. Indeed, many perl builtins have such
+context sensitive behaviors, and these must be adequately supported by
+a properly written override. For a fully functional example of overriding
+C<glob>, study the implementation of C<File::DosGlob> in the standard
+library.
+
+
+=head2 Autoloading
+
+If you call a subroutine that is undefined, you would ordinarily get an
+immediate fatal error complaining that the subroutine doesn't exist.
+(Likewise for subroutines being used as methods, when the method
+doesn't exist in any base class of the class package.) If,
+however, there is an C<AUTOLOAD> subroutine defined in the package or
+packages that were searched for the original subroutine, then that
+C<AUTOLOAD> subroutine is called with the arguments that would have been
+passed to the original subroutine. The fully qualified name of the
+original subroutine magically appears in the C<$AUTOLOAD> variable in the
+same package as the C<AUTOLOAD> routine. The name is not passed as an
+ordinary argument because, er, well, just because, that's why...
+
+Most C<AUTOLOAD> routines will load in a definition for the subroutine in
+question using eval, and then execute that subroutine using a special
+form of "goto" that erases the stack frame of the C<AUTOLOAD> routine
+without a trace. (See the standard C<AutoLoader> module, for example.)
+But an C<AUTOLOAD> routine can also just emulate the routine and never
+define it. For example, let's pretend that a function that wasn't defined
+should just call C<system()> with those arguments. All you'd do is this:
+
+ sub AUTOLOAD {
+ my $program = $AUTOLOAD;
+ $program =~ s/.*:://;
+ system($program, @_);
+ }
+ date();
+ who('am', 'i');
+ ls('-l');
+
+In fact, if you predeclare the functions you want to call that way, you don't
+even need the parentheses:
+
+ use subs qw(date who ls);
+ date;
+ who "am", "i";
+ ls -l;
+
+A more complete example of this is the standard Shell module, which
+can treat undefined subroutine calls as calls to Unix programs.
+
+Mechanisms are available for modules writers to help split the modules
+up into autoloadable files. See the standard AutoLoader module
+described in L<AutoLoader> and in L<AutoSplit>, the standard
+SelfLoader modules in L<SelfLoader>, and the document on adding C
+functions to perl code in L<perlxs>.
+
+=head1 SEE ALSO
+
+See L<perlref> for more about references and closures. See L<perlxs> if
+you'd like to learn about calling C subroutines from perl. See L<perlmod>
+to learn about bundling up your functions in separate files.
diff --git a/contrib/perl5/pod/perlsyn.pod b/contrib/perl5/pod/perlsyn.pod
new file mode 100644
index 0000000..8321235
--- /dev/null
+++ b/contrib/perl5/pod/perlsyn.pod
@@ -0,0 +1,617 @@
+=head1 NAME
+
+perlsyn - Perl syntax
+
+=head1 DESCRIPTION
+
+A Perl script consists of a sequence of declarations and statements.
+The only things that need to be declared in Perl are report formats
+and subroutines. See the sections below for more information on those
+declarations. All uninitialized user-created objects are assumed to
+start with a C<null> or C<0> value until they are defined by some explicit
+operation such as assignment. (Though you can get warnings about the
+use of undefined values if you like.) The sequence of statements is
+executed just once, unlike in B<sed> and B<awk> scripts, where the
+sequence of statements is executed for each input line. While this means
+that you must explicitly loop over the lines of your input file (or
+files), it also means you have much more control over which files and
+which lines you look at. (Actually, I'm lying--it is possible to do an
+implicit loop with either the B<-n> or B<-p> switch. It's just not the
+mandatory default like it is in B<sed> and B<awk>.)
+
+=head2 Declarations
+
+Perl is, for the most part, a free-form language. (The only
+exception to this is format declarations, for obvious reasons.) Comments
+are indicated by the C<"#"> character, and extend to the end of the line. If
+you attempt to use C</* */> C-style comments, it will be interpreted
+either as division or pattern matching, depending on the context, and C++
+C<//> comments just look like a null regular expression, so don't do
+that.
+
+A declaration can be put anywhere a statement can, but has no effect on
+the execution of the primary sequence of statements--declarations all
+take effect at compile time. Typically all the declarations are put at
+the beginning or the end of the script. However, if you're using
+lexically-scoped private variables created with C<my()>, you'll have to make sure
+your format or subroutine definition is within the same block scope
+as the my if you expect to be able to access those private variables.
+
+Declaring a subroutine allows a subroutine name to be used as if it were a
+list operator from that point forward in the program. You can declare a
+subroutine without defining it by saying C<sub name>, thus:
+
+ sub myname;
+ $me = myname $0 or die "can't get myname";
+
+Note that it functions as a list operator, not as a unary operator; so
+be careful to use C<or> instead of C<||> in this case. However, if
+you were to declare the subroutine as C<sub myname ($)>, then
+C<myname> would function as a unary operator, so either C<or> or
+C<||> would work.
+
+Subroutines declarations can also be loaded up with the C<require> statement
+or both loaded and imported into your namespace with a C<use> statement.
+See L<perlmod> for details on this.
+
+A statement sequence may contain declarations of lexically-scoped
+variables, but apart from declaring a variable name, the declaration acts
+like an ordinary statement, and is elaborated within the sequence of
+statements as if it were an ordinary statement. That means it actually
+has both compile-time and run-time effects.
+
+=head2 Simple statements
+
+The only kind of simple statement is an expression evaluated for its
+side effects. Every simple statement must be terminated with a
+semicolon, unless it is the final statement in a block, in which case
+the semicolon is optional. (A semicolon is still encouraged there if the
+block takes up more than one line, because you may eventually add another line.)
+Note that there are some operators like C<eval {}> and C<do {}> that look
+like compound statements, but aren't (they're just TERMs in an expression),
+and thus need an explicit termination if used as the last item in a statement.
+
+Any simple statement may optionally be followed by a I<SINGLE> modifier,
+just before the terminating semicolon (or block ending). The possible
+modifiers are:
+
+ if EXPR
+ unless EXPR
+ while EXPR
+ until EXPR
+ foreach EXPR
+
+The C<if> and C<unless> modifiers have the expected semantics,
+presuming you're a speaker of English. The C<foreach> modifier is an
+iterator: For each value in EXPR, it aliases C<$_> to the value and
+executes the statement. The C<while> and C<until> modifiers have the
+usual "C<while> loop" semantics (conditional evaluated first), except
+when applied to a C<do>-BLOCK (or to the now-deprecated C<do>-SUBROUTINE
+statement), in which case the block executes once before the
+conditional is evaluated. This is so that you can write loops like:
+
+ do {
+ $line = <STDIN>;
+ ...
+ } until $line eq ".\n";
+
+See L<perlfunc/do>. Note also that the loop control statements described
+later will I<NOT> work in this construct, because modifiers don't take
+loop labels. Sorry. You can always put another block inside of it
+(for C<next>) or around it (for C<last>) to do that sort of thing.
+For C<next>, just double the braces:
+
+ do {{
+ next if $x == $y;
+ # do something here
+ }} until $x++ > $z;
+
+For C<last>, you have to be more elaborate:
+
+ LOOP: {
+ do {
+ last if $x = $y**2;
+ # do something here
+ } while $x++ <= $z;
+ }
+
+=head2 Compound statements
+
+In Perl, a sequence of statements that defines a scope is called a block.
+Sometimes a block is delimited by the file containing it (in the case
+of a required file, or the program as a whole), and sometimes a block
+is delimited by the extent of a string (in the case of an eval).
+
+But generally, a block is delimited by curly brackets, also known as braces.
+We will call this syntactic construct a BLOCK.
+
+The following compound statements may be used to control flow:
+
+ if (EXPR) BLOCK
+ if (EXPR) BLOCK else BLOCK
+ if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
+ LABEL while (EXPR) BLOCK
+ LABEL while (EXPR) BLOCK continue BLOCK
+ LABEL for (EXPR; EXPR; EXPR) BLOCK
+ LABEL foreach VAR (LIST) BLOCK
+ LABEL BLOCK continue BLOCK
+
+Note that, unlike C and Pascal, these are defined in terms of BLOCKs,
+not statements. This means that the curly brackets are I<required>--no
+dangling statements allowed. If you want to write conditionals without
+curly brackets there are several other ways to do it. The following
+all do the same thing:
+
+ if (!open(FOO)) { die "Can't open $FOO: $!"; }
+ die "Can't open $FOO: $!" unless open(FOO);
+ open(FOO) or die "Can't open $FOO: $!"; # FOO or bust!
+ open(FOO) ? 'hi mom' : die "Can't open $FOO: $!";
+ # a bit exotic, that last one
+
+The C<if> statement is straightforward. Because BLOCKs are always
+bounded by curly brackets, there is never any ambiguity about which
+C<if> an C<else> goes with. If you use C<unless> in place of C<if>,
+the sense of the test is reversed.
+
+The C<while> statement executes the block as long as the expression is
+true (does not evaluate to the null string (C<"">) or C<0> or C<"0")>. The LABEL is
+optional, and if present, consists of an identifier followed by a colon.
+The LABEL identifies the loop for the loop control statements C<next>,
+C<last>, and C<redo>. If the LABEL is omitted, the loop control statement
+refers to the innermost enclosing loop. This may include dynamically
+looking back your call-stack at run time to find the LABEL. Such
+desperate behavior triggers a warning if you use the B<-w> flag.
+
+If there is a C<continue> BLOCK, it is always executed just before the
+conditional is about to be evaluated again, just like the third part of a
+C<for> loop in C. Thus it can be used to increment a loop variable, even
+when the loop has been continued via the C<next> statement (which is
+similar to the C C<continue> statement).
+
+=head2 Loop Control
+
+The C<next> command is like the C<continue> statement in C; it starts
+the next iteration of the loop:
+
+ LINE: while (<STDIN>) {
+ next LINE if /^#/; # discard comments
+ ...
+ }
+
+The C<last> command is like the C<break> statement in C (as used in
+loops); it immediately exits the loop in question. The
+C<continue> block, if any, is not executed:
+
+ LINE: while (<STDIN>) {
+ last LINE if /^$/; # exit when done with header
+ ...
+ }
+
+The C<redo> command restarts the loop block without evaluating the
+conditional again. The C<continue> block, if any, is I<not> executed.
+This command is normally used by programs that want to lie to themselves
+about what was just input.
+
+For example, when processing a file like F</etc/termcap>.
+If your input lines might end in backslashes to indicate continuation, you
+want to skip ahead and get the next record.
+
+ while (<>) {
+ chomp;
+ if (s/\\$//) {
+ $_ .= <>;
+ redo unless eof();
+ }
+ # now process $_
+ }
+
+which is Perl short-hand for the more explicitly written version:
+
+ LINE: while (defined($line = <ARGV>)) {
+ chomp($line);
+ if ($line =~ s/\\$//) {
+ $line .= <ARGV>;
+ redo LINE unless eof(); # not eof(ARGV)!
+ }
+ # now process $line
+ }
+
+Note that if there were a C<continue> block on the above code, it would get
+executed even on discarded lines. This is often used to reset line counters
+or C<?pat?> one-time matches.
+
+ # inspired by :1,$g/fred/s//WILMA/
+ while (<>) {
+ ?(fred)? && s//WILMA $1 WILMA/;
+ ?(barney)? && s//BETTY $1 BETTY/;
+ ?(homer)? && s//MARGE $1 MARGE/;
+ } continue {
+ print "$ARGV $.: $_";
+ close ARGV if eof(); # reset $.
+ reset if eof(); # reset ?pat?
+ }
+
+If the word C<while> is replaced by the word C<until>, the sense of the
+test is reversed, but the conditional is still tested before the first
+iteration.
+
+The loop control statements don't work in an C<if> or C<unless>, since
+they aren't loops. You can double the braces to make them such, though.
+
+ if (/pattern/) {{
+ next if /fred/;
+ next if /barney/;
+ # so something here
+ }}
+
+The form C<while/if BLOCK BLOCK>, available in Perl 4, is no longer
+available. Replace any occurrence of C<if BLOCK> by C<if (do BLOCK)>.
+
+=head2 For Loops
+
+Perl's C-style C<for> loop works exactly like the corresponding C<while> loop;
+that means that this:
+
+ for ($i = 1; $i < 10; $i++) {
+ ...
+ }
+
+is the same as this:
+
+ $i = 1;
+ while ($i < 10) {
+ ...
+ } continue {
+ $i++;
+ }
+
+(There is one minor difference: The first form implies a lexical scope
+for variables declared with C<my> in the initialization expression.)
+
+Besides the normal array index looping, C<for> can lend itself
+to many other interesting applications. Here's one that avoids the
+problem you get into if you explicitly test for end-of-file on
+an interactive file descriptor causing your program to appear to
+hang.
+
+ $on_a_tty = -t STDIN && -t STDOUT;
+ sub prompt { print "yes? " if $on_a_tty }
+ for ( prompt(); <STDIN>; prompt() ) {
+ # do something
+ }
+
+=head2 Foreach Loops
+
+The C<foreach> loop iterates over a normal list value and sets the
+variable VAR to be each element of the list in turn. If the variable
+is preceded with the keyword C<my>, then it is lexically scoped, and
+is therefore visible only within the loop. Otherwise, the variable is
+implicitly local to the loop and regains its former value upon exiting
+the loop. If the variable was previously declared with C<my>, it uses
+that variable instead of the global one, but it's still localized to
+the loop. (Note that a lexically scoped variable can cause problems
+if you have subroutine or format declarations within the loop which
+refer to it.)
+
+The C<foreach> keyword is actually a synonym for the C<for> keyword, so
+you can use C<foreach> for readability or C<for> for brevity. (Or because
+the Bourne shell is more familiar to you than I<csh>, so writing C<for>
+comes more naturally.) If VAR is omitted, C<$_> is set to each value.
+If any element of LIST is an lvalue, you can modify it by modifying VAR
+inside the loop. That's because the C<foreach> loop index variable is
+an implicit alias for each item in the list that you're looping over.
+
+If any part of LIST is an array, C<foreach> will get very confused if
+you add or remove elements within the loop body, for example with
+C<splice>. So don't do that.
+
+C<foreach> probably won't do what you expect if VAR is a tied or other
+special variable. Don't do that either.
+
+Examples:
+
+ for (@ary) { s/foo/bar/ }
+
+ foreach my $elem (@elements) {
+ $elem *= 2;
+ }
+
+ for $count (10,9,8,7,6,5,4,3,2,1,'BOOM') {
+ print $count, "\n"; sleep(1);
+ }
+
+ for (1..15) { print "Merry Christmas\n"; }
+
+ foreach $item (split(/:[\\\n:]*/, $ENV{TERMCAP})) {
+ print "Item: $item\n";
+ }
+
+Here's how a C programmer might code up a particular algorithm in Perl:
+
+ for (my $i = 0; $i < @ary1; $i++) {
+ for (my $j = 0; $j < @ary2; $j++) {
+ if ($ary1[$i] > $ary2[$j]) {
+ last; # can't go to outer :-(
+ }
+ $ary1[$i] += $ary2[$j];
+ }
+ # this is where that last takes me
+ }
+
+Whereas here's how a Perl programmer more comfortable with the idiom might
+do it:
+
+ OUTER: foreach my $wid (@ary1) {
+ INNER: foreach my $jet (@ary2) {
+ next OUTER if $wid > $jet;
+ $wid += $jet;
+ }
+ }
+
+See how much easier this is? It's cleaner, safer, and faster. It's
+cleaner because it's less noisy. It's safer because if code gets added
+between the inner and outer loops later on, the new code won't be
+accidentally executed. The C<next> explicitly iterates the other loop
+rather than merely terminating the inner one. And it's faster because
+Perl executes a C<foreach> statement more rapidly than it would the
+equivalent C<for> loop.
+
+=head2 Basic BLOCKs and Switch Statements
+
+A BLOCK by itself (labeled or not) is semantically equivalent to a
+loop that executes once. Thus you can use any of the loop control
+statements in it to leave or restart the block. (Note that this is
+I<NOT> true in C<eval{}>, C<sub{}>, or contrary to popular belief
+C<do{}> blocks, which do I<NOT> count as loops.) The C<continue>
+block is optional.
+
+The BLOCK construct is particularly nice for doing case
+structures.
+
+ SWITCH: {
+ if (/^abc/) { $abc = 1; last SWITCH; }
+ if (/^def/) { $def = 1; last SWITCH; }
+ if (/^xyz/) { $xyz = 1; last SWITCH; }
+ $nothing = 1;
+ }
+
+There is no official C<switch> statement in Perl, because there are
+already several ways to write the equivalent. In addition to the
+above, you could write
+
+ SWITCH: {
+ $abc = 1, last SWITCH if /^abc/;
+ $def = 1, last SWITCH if /^def/;
+ $xyz = 1, last SWITCH if /^xyz/;
+ $nothing = 1;
+ }
+
+(That's actually not as strange as it looks once you realize that you can
+use loop control "operators" within an expression, That's just the normal
+C comma operator.)
+
+or
+
+ SWITCH: {
+ /^abc/ && do { $abc = 1; last SWITCH; };
+ /^def/ && do { $def = 1; last SWITCH; };
+ /^xyz/ && do { $xyz = 1; last SWITCH; };
+ $nothing = 1;
+ }
+
+or formatted so it stands out more as a "proper" C<switch> statement:
+
+ SWITCH: {
+ /^abc/ && do {
+ $abc = 1;
+ last SWITCH;
+ };
+
+ /^def/ && do {
+ $def = 1;
+ last SWITCH;
+ };
+
+ /^xyz/ && do {
+ $xyz = 1;
+ last SWITCH;
+ };
+ $nothing = 1;
+ }
+
+or
+
+ SWITCH: {
+ /^abc/ and $abc = 1, last SWITCH;
+ /^def/ and $def = 1, last SWITCH;
+ /^xyz/ and $xyz = 1, last SWITCH;
+ $nothing = 1;
+ }
+
+or even, horrors,
+
+ if (/^abc/)
+ { $abc = 1 }
+ elsif (/^def/)
+ { $def = 1 }
+ elsif (/^xyz/)
+ { $xyz = 1 }
+ else
+ { $nothing = 1 }
+
+A common idiom for a C<switch> statement is to use C<foreach>'s aliasing to make
+a temporary assignment to C<$_> for convenient matching:
+
+ SWITCH: for ($where) {
+ /In Card Names/ && do { push @flags, '-e'; last; };
+ /Anywhere/ && do { push @flags, '-h'; last; };
+ /In Rulings/ && do { last; };
+ die "unknown value for form variable where: `$where'";
+ }
+
+Another interesting approach to a switch statement is arrange
+for a C<do> block to return the proper value:
+
+ $amode = do {
+ if ($flag & O_RDONLY) { "r" } # XXX: isn't this 0?
+ elsif ($flag & O_WRONLY) { ($flag & O_APPEND) ? "a" : "w" }
+ elsif ($flag & O_RDWR) {
+ if ($flag & O_CREAT) { "w+" }
+ else { ($flag & O_APPEND) ? "a+" : "r+" }
+ }
+ };
+
+Or
+
+ print do {
+ ($flags & O_WRONLY) ? "write-only" :
+ ($flags & O_RDWR) ? "read-write" :
+ "read-only";
+ };
+
+Or if you are certainly that all the C<&&> clauses are true, you can use
+something like this, which "switches" on the value of the
+C<HTTP_USER_AGENT> envariable.
+
+ #!/usr/bin/perl
+ # pick out jargon file page based on browser
+ $dir = 'http://www.wins.uva.nl/~mes/jargon';
+ for ($ENV{HTTP_USER_AGENT}) {
+ $page = /Mac/ && 'm/Macintrash.html'
+ || /Win(dows )?NT/ && 'e/evilandrude.html'
+ || /Win|MSIE|WebTV/ && 'm/MicroslothWindows.html'
+ || /Linux/ && 'l/Linux.html'
+ || /HP-UX/ && 'h/HP-SUX.html'
+ || /SunOS/ && 's/ScumOS.html'
+ || 'a/AppendixB.html';
+ }
+ print "Location: $dir/$page\015\012\015\012";
+
+That kind of switch statement only works when you know the C<&&> clauses
+will be true. If you don't, the previous C<?:> example should be used.
+
+You might also consider writing a hash instead of synthesizing a C<switch>
+statement.
+
+=head2 Goto
+
+Although not for the faint of heart, Perl does support a C<goto> statement.
+A loop's LABEL is not actually a valid target for a C<goto>;
+it's just the name of the loop. There are three forms: C<goto>-LABEL,
+C<goto>-EXPR, and C<goto>-&NAME.
+
+The C<goto>-LABEL form finds the statement labeled with LABEL and resumes
+execution there. It may not be used to go into any construct that
+requires initialization, such as a subroutine or a C<foreach> loop. It
+also can't be used to go into a construct that is optimized away. It
+can be used to go almost anywhere else within the dynamic scope,
+including out of subroutines, but it's usually better to use some other
+construct such as C<last> or C<die>. The author of Perl has never felt the
+need to use this form of C<goto> (in Perl, that is--C is another matter).
+
+The C<goto>-EXPR form expects a label name, whose scope will be resolved
+dynamically. This allows for computed C<goto>s per FORTRAN, but isn't
+necessarily recommended if you're optimizing for maintainability:
+
+ goto ("FOO", "BAR", "GLARCH")[$i];
+
+The C<goto>-&NAME form is highly magical, and substitutes a call to the
+named subroutine for the currently running subroutine. This is used by
+C<AUTOLOAD()> subroutines that wish to load another subroutine and then
+pretend that the other subroutine had been called in the first place
+(except that any modifications to C<@_> in the current subroutine are
+propagated to the other subroutine.) After the C<goto>, not even C<caller()>
+will be able to tell that this routine was called first.
+
+In almost all cases like this, it's usually a far, far better idea to use the
+structured control flow mechanisms of C<next>, C<last>, or C<redo> instead of
+resorting to a C<goto>. For certain applications, the catch and throw pair of
+C<eval{}> and die() for exception processing can also be a prudent approach.
+
+=head2 PODs: Embedded Documentation
+
+Perl has a mechanism for intermixing documentation with source code.
+While it's expecting the beginning of a new statement, if the compiler
+encounters a line that begins with an equal sign and a word, like this
+
+ =head1 Here There Be Pods!
+
+Then that text and all remaining text up through and including a line
+beginning with C<=cut> will be ignored. The format of the intervening
+text is described in L<perlpod>.
+
+This allows you to intermix your source code
+and your documentation text freely, as in
+
+ =item snazzle($)
+
+ The snazzle() function will behave in the most spectacular
+ form that you can possibly imagine, not even excepting
+ cybernetic pyrotechnics.
+
+ =cut back to the compiler, nuff of this pod stuff!
+
+ sub snazzle($) {
+ my $thingie = shift;
+ .........
+ }
+
+Note that pod translators should look at only paragraphs beginning
+with a pod directive (it makes parsing easier), whereas the compiler
+actually knows to look for pod escapes even in the middle of a
+paragraph. This means that the following secret stuff will be
+ignored by both the compiler and the translators.
+
+ $a=3;
+ =secret stuff
+ warn "Neither POD nor CODE!?"
+ =cut back
+ print "got $a\n";
+
+You probably shouldn't rely upon the C<warn()> being podded out forever.
+Not all pod translators are well-behaved in this regard, and perhaps
+the compiler will become pickier.
+
+One may also use pod directives to quickly comment out a section
+of code.
+
+=head2 Plain Old Comments (Not!)
+
+Much like the C preprocessor, Perl can process line directives. Using
+this, one can control Perl's idea of filenames and line numbers in
+error or warning messages (especially for strings that are processed
+with C<eval()>). The syntax for this mechanism is the same as for most
+C preprocessors: it matches the regular expression
+C</^#\s*line\s+(\d+)\s*(?:\s"([^"]*)")?/> with C<$1> being the line
+number for the next line, and C<$2> being the optional filename
+(specified within quotes).
+
+Here are some examples that you should be able to type into your command
+shell:
+
+ % perl
+ # line 200 "bzzzt"
+ # the `#' on the previous line must be the first char on line
+ die 'foo';
+ __END__
+ foo at bzzzt line 201.
+
+ % perl
+ # line 200 "bzzzt"
+ eval qq[\n#line 2001 ""\ndie 'foo']; print $@;
+ __END__
+ foo at - line 2001.
+
+ % perl
+ eval qq[\n#line 200 "foo bar"\ndie 'foo']; print $@;
+ __END__
+ foo at foo bar line 200.
+
+ % perl
+ # line 345 "goop"
+ eval "\n#line " . __LINE__ . ' "' . __FILE__ ."\"\ndie 'foo'";
+ print $@;
+ __END__
+ foo at goop line 345.
+
+=cut
diff --git a/contrib/perl5/pod/perltie.pod b/contrib/perl5/pod/perltie.pod
new file mode 100644
index 0000000..cae0a15
--- /dev/null
+++ b/contrib/perl5/pod/perltie.pod
@@ -0,0 +1,876 @@
+=head1 NAME
+
+perltie - how to hide an object class in a simple variable
+
+=head1 SYNOPSIS
+
+ tie VARIABLE, CLASSNAME, LIST
+
+ $object = tied VARIABLE
+
+ untie VARIABLE
+
+=head1 DESCRIPTION
+
+Prior to release 5.0 of Perl, a programmer could use dbmopen()
+to connect an on-disk database in the standard Unix dbm(3x)
+format magically to a %HASH in their program. However, their Perl was either
+built with one particular dbm library or another, but not both, and
+you couldn't extend this mechanism to other packages or types of variables.
+
+Now you can.
+
+The tie() function binds a variable to a class (package) that will provide
+the implementation for access methods for that variable. Once this magic
+has been performed, accessing a tied variable automatically triggers
+method calls in the proper class. The complexity of the class is
+hidden behind magic methods calls. The method names are in ALL CAPS,
+which is a convention that Perl uses to indicate that they're called
+implicitly rather than explicitly--just like the BEGIN() and END()
+functions.
+
+In the tie() call, C<VARIABLE> is the name of the variable to be
+enchanted. C<CLASSNAME> is the name of a class implementing objects of
+the correct type. Any additional arguments in the C<LIST> are passed to
+the appropriate constructor method for that class--meaning TIESCALAR(),
+TIEARRAY(), TIEHASH(), or TIEHANDLE(). (Typically these are arguments
+such as might be passed to the dbminit() function of C.) The object
+returned by the "new" method is also returned by the tie() function,
+which would be useful if you wanted to access other methods in
+C<CLASSNAME>. (You don't actually have to return a reference to a right
+"type" (e.g., HASH or C<CLASSNAME>) so long as it's a properly blessed
+object.) You can also retrieve a reference to the underlying object
+using the tied() function.
+
+Unlike dbmopen(), the tie() function will not C<use> or C<require> a module
+for you--you need to do that explicitly yourself.
+
+=head2 Tying Scalars
+
+A class implementing a tied scalar should define the following methods:
+TIESCALAR, FETCH, STORE, and possibly DESTROY.
+
+Let's look at each in turn, using as an example a tie class for
+scalars that allows the user to do something like:
+
+ tie $his_speed, 'Nice', getppid();
+ tie $my_speed, 'Nice', $$;
+
+And now whenever either of those variables is accessed, its current
+system priority is retrieved and returned. If those variables are set,
+then the process's priority is changed!
+
+We'll use Jarkko Hietaniemi <F<jhi@iki.fi>>'s BSD::Resource class (not
+included) to access the PRIO_PROCESS, PRIO_MIN, and PRIO_MAX constants
+from your system, as well as the getpriority() and setpriority() system
+calls. Here's the preamble of the class.
+
+ package Nice;
+ use Carp;
+ use BSD::Resource;
+ use strict;
+ $Nice::DEBUG = 0 unless defined $Nice::DEBUG;
+
+=over
+
+=item TIESCALAR classname, LIST
+
+This is the constructor for the class. That means it is
+expected to return a blessed reference to a new scalar
+(probably anonymous) that it's creating. For example:
+
+ sub TIESCALAR {
+ my $class = shift;
+ my $pid = shift || $$; # 0 means me
+
+ if ($pid !~ /^\d+$/) {
+ carp "Nice::Tie::Scalar got non-numeric pid $pid" if $^W;
+ return undef;
+ }
+
+ unless (kill 0, $pid) { # EPERM or ERSCH, no doubt
+ carp "Nice::Tie::Scalar got bad pid $pid: $!" if $^W;
+ return undef;
+ }
+
+ return bless \$pid, $class;
+ }
+
+This tie class has chosen to return an error rather than raising an
+exception if its constructor should fail. While this is how dbmopen() works,
+other classes may well not wish to be so forgiving. It checks the global
+variable C<$^W> to see whether to emit a bit of noise anyway.
+
+=item FETCH this
+
+This method will be triggered every time the tied variable is accessed
+(read). It takes no arguments beyond its self reference, which is the
+object representing the scalar we're dealing with. Because in this case
+we're using just a SCALAR ref for the tied scalar object, a simple $$self
+allows the method to get at the real value stored there. In our example
+below, that real value is the process ID to which we've tied our variable.
+
+ sub FETCH {
+ my $self = shift;
+ confess "wrong type" unless ref $self;
+ croak "usage error" if @_;
+ my $nicety;
+ local($!) = 0;
+ $nicety = getpriority(PRIO_PROCESS, $$self);
+ if ($!) { croak "getpriority failed: $!" }
+ return $nicety;
+ }
+
+This time we've decided to blow up (raise an exception) if the renice
+fails--there's no place for us to return an error otherwise, and it's
+probably the right thing to do.
+
+=item STORE this, value
+
+This method will be triggered every time the tied variable is set
+(assigned). Beyond its self reference, it also expects one (and only one)
+argument--the new value the user is trying to assign.
+
+ sub STORE {
+ my $self = shift;
+ confess "wrong type" unless ref $self;
+ my $new_nicety = shift;
+ croak "usage error" if @_;
+
+ if ($new_nicety < PRIO_MIN) {
+ carp sprintf
+ "WARNING: priority %d less than minimum system priority %d",
+ $new_nicety, PRIO_MIN if $^W;
+ $new_nicety = PRIO_MIN;
+ }
+
+ if ($new_nicety > PRIO_MAX) {
+ carp sprintf
+ "WARNING: priority %d greater than maximum system priority %d",
+ $new_nicety, PRIO_MAX if $^W;
+ $new_nicety = PRIO_MAX;
+ }
+
+ unless (defined setpriority(PRIO_PROCESS, $$self, $new_nicety)) {
+ confess "setpriority failed: $!";
+ }
+ return $new_nicety;
+ }
+
+=item DESTROY this
+
+This method will be triggered when the tied variable needs to be destructed.
+As with other object classes, such a method is seldom necessary, because Perl
+deallocates its moribund object's memory for you automatically--this isn't
+C++, you know. We'll use a DESTROY method here for debugging purposes only.
+
+ sub DESTROY {
+ my $self = shift;
+ confess "wrong type" unless ref $self;
+ carp "[ Nice::DESTROY pid $$self ]" if $Nice::DEBUG;
+ }
+
+=back
+
+That's about all there is to it. Actually, it's more than all there
+is to it, because we've done a few nice things here for the sake
+of completeness, robustness, and general aesthetics. Simpler
+TIESCALAR classes are certainly possible.
+
+=head2 Tying Arrays
+
+A class implementing a tied ordinary array should define the following
+methods: TIEARRAY, FETCH, STORE, FETCHSIZE, STORESIZE and perhaps DESTROY.
+
+FETCHSIZE and STORESIZE are used to provide C<$#array> and
+equivalent C<scalar(@array)> access.
+
+The methods POP, PUSH, SHIFT, UNSHIFT, SPLICE are required if the perl
+operator with the corresponding (but lowercase) name is to operate on the
+tied array. The B<Tie::Array> class can be used as a base class to implement
+these in terms of the basic five methods above.
+
+In addition EXTEND will be called when perl would have pre-extended
+allocation in a real array.
+
+This means that tied arrays are now I<complete>. The example below needs
+upgrading to illustrate this. (The documentation in B<Tie::Array> is more
+complete.)
+
+For this discussion, we'll implement an array whose indices are fixed at
+its creation. If you try to access anything beyond those bounds, you'll
+take an exception. For example:
+
+ require Bounded_Array;
+ tie @ary, 'Bounded_Array', 2;
+ $| = 1;
+ for $i (0 .. 10) {
+ print "setting index $i: ";
+ $ary[$i] = 10 * $i;
+ $ary[$i] = 10 * $i;
+ print "value of elt $i now $ary[$i]\n";
+ }
+
+The preamble code for the class is as follows:
+
+ package Bounded_Array;
+ use Carp;
+ use strict;
+
+=over
+
+=item TIEARRAY classname, LIST
+
+This is the constructor for the class. That means it is expected to
+return a blessed reference through which the new array (probably an
+anonymous ARRAY ref) will be accessed.
+
+In our example, just to show you that you don't I<really> have to return an
+ARRAY reference, we'll choose a HASH reference to represent our object.
+A HASH works out well as a generic record type: the C<{BOUND}> field will
+store the maximum bound allowed, and the C<{ARRAY}> field will hold the
+true ARRAY ref. If someone outside the class tries to dereference the
+object returned (doubtless thinking it an ARRAY ref), they'll blow up.
+This just goes to show you that you should respect an object's privacy.
+
+ sub TIEARRAY {
+ my $class = shift;
+ my $bound = shift;
+ confess "usage: tie(\@ary, 'Bounded_Array', max_subscript)"
+ if @_ || $bound =~ /\D/;
+ return bless {
+ BOUND => $bound,
+ ARRAY => [],
+ }, $class;
+ }
+
+=item FETCH this, index
+
+This method will be triggered every time an individual element the tied array
+is accessed (read). It takes one argument beyond its self reference: the
+index whose value we're trying to fetch.
+
+ sub FETCH {
+ my($self,$idx) = @_;
+ if ($idx > $self->{BOUND}) {
+ confess "Array OOB: $idx > $self->{BOUND}";
+ }
+ return $self->{ARRAY}[$idx];
+ }
+
+As you may have noticed, the name of the FETCH method (et al.) is the same
+for all accesses, even though the constructors differ in names (TIESCALAR
+vs TIEARRAY). While in theory you could have the same class servicing
+several tied types, in practice this becomes cumbersome, and it's easiest
+to keep them at simply one tie type per class.
+
+=item STORE this, index, value
+
+This method will be triggered every time an element in the tied array is set
+(written). It takes two arguments beyond its self reference: the index at
+which we're trying to store something and the value we're trying to put
+there. For example:
+
+ sub STORE {
+ my($self, $idx, $value) = @_;
+ print "[STORE $value at $idx]\n" if _debug;
+ if ($idx > $self->{BOUND} ) {
+ confess "Array OOB: $idx > $self->{BOUND}";
+ }
+ return $self->{ARRAY}[$idx] = $value;
+ }
+
+=item DESTROY this
+
+This method will be triggered when the tied variable needs to be destructed.
+As with the scalar tie class, this is almost never needed in a
+language that does its own garbage collection, so this time we'll
+just leave it out.
+
+=back
+
+The code we presented at the top of the tied array class accesses many
+elements of the array, far more than we've set the bounds to. Therefore,
+it will blow up once they try to access beyond the 2nd element of @ary, as
+the following output demonstrates:
+
+ setting index 0: value of elt 0 now 0
+ setting index 1: value of elt 1 now 10
+ setting index 2: value of elt 2 now 20
+ setting index 3: Array OOB: 3 > 2 at Bounded_Array.pm line 39
+ Bounded_Array::FETCH called at testba line 12
+
+=head2 Tying Hashes
+
+As the first Perl data type to be tied (see dbmopen()), hashes have the
+most complete and useful tie() implementation. A class implementing a
+tied hash should define the following methods: TIEHASH is the constructor.
+FETCH and STORE access the key and value pairs. EXISTS reports whether a
+key is present in the hash, and DELETE deletes one. CLEAR empties the
+hash by deleting all the key and value pairs. FIRSTKEY and NEXTKEY
+implement the keys() and each() functions to iterate over all the keys.
+And DESTROY is called when the tied variable is garbage collected.
+
+If this seems like a lot, then feel free to inherit from merely the
+standard Tie::Hash module for most of your methods, redefining only the
+interesting ones. See L<Tie::Hash> for details.
+
+Remember that Perl distinguishes between a key not existing in the hash,
+and the key existing in the hash but having a corresponding value of
+C<undef>. The two possibilities can be tested with the C<exists()> and
+C<defined()> functions.
+
+Here's an example of a somewhat interesting tied hash class: it gives you
+a hash representing a particular user's dot files. You index into the hash
+with the name of the file (minus the dot) and you get back that dot file's
+contents. For example:
+
+ use DotFiles;
+ tie %dot, 'DotFiles';
+ if ( $dot{profile} =~ /MANPATH/ ||
+ $dot{login} =~ /MANPATH/ ||
+ $dot{cshrc} =~ /MANPATH/ )
+ {
+ print "you seem to set your MANPATH\n";
+ }
+
+Or here's another sample of using our tied class:
+
+ tie %him, 'DotFiles', 'daemon';
+ foreach $f ( keys %him ) {
+ printf "daemon dot file %s is size %d\n",
+ $f, length $him{$f};
+ }
+
+In our tied hash DotFiles example, we use a regular
+hash for the object containing several important
+fields, of which only the C<{LIST}> field will be what the
+user thinks of as the real hash.
+
+=over 5
+
+=item USER
+
+whose dot files this object represents
+
+=item HOME
+
+where those dot files live
+
+=item CLOBBER
+
+whether we should try to change or remove those dot files
+
+=item LIST
+
+the hash of dot file names and content mappings
+
+=back
+
+Here's the start of F<Dotfiles.pm>:
+
+ package DotFiles;
+ use Carp;
+ sub whowasi { (caller(1))[3] . '()' }
+ my $DEBUG = 0;
+ sub debug { $DEBUG = @_ ? shift : 1 }
+
+For our example, we want to be able to emit debugging info to help in tracing
+during development. We keep also one convenience function around
+internally to help print out warnings; whowasi() returns the function name
+that calls it.
+
+Here are the methods for the DotFiles tied hash.
+
+=over
+
+=item TIEHASH classname, LIST
+
+This is the constructor for the class. That means it is expected to
+return a blessed reference through which the new object (probably but not
+necessarily an anonymous hash) will be accessed.
+
+Here's the constructor:
+
+ sub TIEHASH {
+ my $self = shift;
+ my $user = shift || $>;
+ my $dotdir = shift || '';
+ croak "usage: @{[&whowasi]} [USER [DOTDIR]]" if @_;
+ $user = getpwuid($user) if $user =~ /^\d+$/;
+ my $dir = (getpwnam($user))[7]
+ || croak "@{[&whowasi]}: no user $user";
+ $dir .= "/$dotdir" if $dotdir;
+
+ my $node = {
+ USER => $user,
+ HOME => $dir,
+ LIST => {},
+ CLOBBER => 0,
+ };
+
+ opendir(DIR, $dir)
+ || croak "@{[&whowasi]}: can't opendir $dir: $!";
+ foreach $dot ( grep /^\./ && -f "$dir/$_", readdir(DIR)) {
+ $dot =~ s/^\.//;
+ $node->{LIST}{$dot} = undef;
+ }
+ closedir DIR;
+ return bless $node, $self;
+ }
+
+It's probably worth mentioning that if you're going to filetest the
+return values out of a readdir, you'd better prepend the directory
+in question. Otherwise, because we didn't chdir() there, it would
+have been testing the wrong file.
+
+=item FETCH this, key
+
+This method will be triggered every time an element in the tied hash is
+accessed (read). It takes one argument beyond its self reference: the key
+whose value we're trying to fetch.
+
+Here's the fetch for our DotFiles example.
+
+ sub FETCH {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ my $dot = shift;
+ my $dir = $self->{HOME};
+ my $file = "$dir/.$dot";
+
+ unless (exists $self->{LIST}->{$dot} || -f $file) {
+ carp "@{[&whowasi]}: no $dot file" if $DEBUG;
+ return undef;
+ }
+
+ if (defined $self->{LIST}->{$dot}) {
+ return $self->{LIST}->{$dot};
+ } else {
+ return $self->{LIST}->{$dot} = `cat $dir/.$dot`;
+ }
+ }
+
+It was easy to write by having it call the Unix cat(1) command, but it
+would probably be more portable to open the file manually (and somewhat
+more efficient). Of course, because dot files are a Unixy concept, we're
+not that concerned.
+
+=item STORE this, key, value
+
+This method will be triggered every time an element in the tied hash is set
+(written). It takes two arguments beyond its self reference: the index at
+which we're trying to store something, and the value we're trying to put
+there.
+
+Here in our DotFiles example, we'll be careful not to let
+them try to overwrite the file unless they've called the clobber()
+method on the original object reference returned by tie().
+
+ sub STORE {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ my $dot = shift;
+ my $value = shift;
+ my $file = $self->{HOME} . "/.$dot";
+ my $user = $self->{USER};
+
+ croak "@{[&whowasi]}: $file not clobberable"
+ unless $self->{CLOBBER};
+
+ open(F, "> $file") || croak "can't open $file: $!";
+ print F $value;
+ close(F);
+ }
+
+If they wanted to clobber something, they might say:
+
+ $ob = tie %daemon_dots, 'daemon';
+ $ob->clobber(1);
+ $daemon_dots{signature} = "A true daemon\n";
+
+Another way to lay hands on a reference to the underlying object is to
+use the tied() function, so they might alternately have set clobber
+using:
+
+ tie %daemon_dots, 'daemon';
+ tied(%daemon_dots)->clobber(1);
+
+The clobber method is simply:
+
+ sub clobber {
+ my $self = shift;
+ $self->{CLOBBER} = @_ ? shift : 1;
+ }
+
+=item DELETE this, key
+
+This method is triggered when we remove an element from the hash,
+typically by using the delete() function. Again, we'll
+be careful to check whether they really want to clobber files.
+
+ sub DELETE {
+ carp &whowasi if $DEBUG;
+
+ my $self = shift;
+ my $dot = shift;
+ my $file = $self->{HOME} . "/.$dot";
+ croak "@{[&whowasi]}: won't remove file $file"
+ unless $self->{CLOBBER};
+ delete $self->{LIST}->{$dot};
+ my $success = unlink($file);
+ carp "@{[&whowasi]}: can't unlink $file: $!" unless $success;
+ $success;
+ }
+
+The value returned by DELETE becomes the return value of the call
+to delete(). If you want to emulate the normal behavior of delete(),
+you should return whatever FETCH would have returned for this key.
+In this example, we have chosen instead to return a value which tells
+the caller whether the file was successfully deleted.
+
+=item CLEAR this
+
+This method is triggered when the whole hash is to be cleared, usually by
+assigning the empty list to it.
+
+In our example, that would remove all the user's dot files! It's such a
+dangerous thing that they'll have to set CLOBBER to something higher than
+1 to make it happen.
+
+ sub CLEAR {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ croak "@{[&whowasi]}: won't remove all dot files for $self->{USER}"
+ unless $self->{CLOBBER} > 1;
+ my $dot;
+ foreach $dot ( keys %{$self->{LIST}}) {
+ $self->DELETE($dot);
+ }
+ }
+
+=item EXISTS this, key
+
+This method is triggered when the user uses the exists() function
+on a particular hash. In our example, we'll look at the C<{LIST}>
+hash element for this:
+
+ sub EXISTS {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ my $dot = shift;
+ return exists $self->{LIST}->{$dot};
+ }
+
+=item FIRSTKEY this
+
+This method will be triggered when the user is going
+to iterate through the hash, such as via a keys() or each()
+call.
+
+ sub FIRSTKEY {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ my $a = keys %{$self->{LIST}}; # reset each() iterator
+ each %{$self->{LIST}}
+ }
+
+=item NEXTKEY this, lastkey
+
+This method gets triggered during a keys() or each() iteration. It has a
+second argument which is the last key that had been accessed. This is
+useful if you're carrying about ordering or calling the iterator from more
+than one sequence, or not really storing things in a hash anywhere.
+
+For our example, we're using a real hash so we'll do just the simple
+thing, but we'll have to go through the LIST field indirectly.
+
+ sub NEXTKEY {
+ carp &whowasi if $DEBUG;
+ my $self = shift;
+ return each %{ $self->{LIST} }
+ }
+
+=item DESTROY this
+
+This method is triggered when a tied hash is about to go out of
+scope. You don't really need it unless you're trying to add debugging
+or have auxiliary state to clean up. Here's a very simple function:
+
+ sub DESTROY {
+ carp &whowasi if $DEBUG;
+ }
+
+=back
+
+Note that functions such as keys() and values() may return huge lists
+when used on large objects, like DBM files. You may prefer to use the
+each() function to iterate over such. Example:
+
+ # print out history file offsets
+ use NDBM_File;
+ tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
+ while (($key,$val) = each %HIST) {
+ print $key, ' = ', unpack('L',$val), "\n";
+ }
+ untie(%HIST);
+
+=head2 Tying FileHandles
+
+This is partially implemented now.
+
+A class implementing a tied filehandle should define the following
+methods: TIEHANDLE, at least one of PRINT, PRINTF, WRITE, READLINE, GETC,
+READ, and possibly CLOSE and DESTROY.
+
+It is especially useful when perl is embedded in some other program,
+where output to STDOUT and STDERR may have to be redirected in some
+special way. See nvi and the Apache module for examples.
+
+In our example we're going to create a shouting handle.
+
+ package Shout;
+
+=over
+
+=item TIEHANDLE classname, LIST
+
+This is the constructor for the class. That means it is expected to
+return a blessed reference of some sort. The reference can be used to
+hold some internal information.
+
+ sub TIEHANDLE { print "<shout>\n"; my $i; bless \$i, shift }
+
+=item WRITE this, LIST
+
+This method will be called when the handle is written to via the
+C<syswrite> function.
+
+ sub WRITE {
+ $r = shift;
+ my($buf,$len,$offset) = @_;
+ print "WRITE called, \$buf=$buf, \$len=$len, \$offset=$offset";
+ }
+
+=item PRINT this, LIST
+
+This method will be triggered every time the tied handle is printed to
+with the C<print()> function.
+Beyond its self reference it also expects the list that was passed to
+the print function.
+
+ sub PRINT { $r = shift; $$r++; print join($,,map(uc($_),@_)),$\ }
+
+=item PRINTF this, LIST
+
+This method will be triggered every time the tied handle is printed to
+with the C<printf()> function.
+Beyond its self reference it also expects the format and list that was
+passed to the printf function.
+
+ sub PRINTF {
+ shift;
+ my $fmt = shift;
+ print sprintf($fmt, @_)."\n";
+ }
+
+=item READ this, LIST
+
+This method will be called when the handle is read from via the C<read>
+or C<sysread> functions.
+
+ sub READ {
+ $r = shift;
+ my($buf,$len,$offset) = @_;
+ print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
+ }
+
+=item READLINE this
+
+This method will be called when the handle is read from via <HANDLE>.
+The method should return undef when there is no more data.
+
+ sub READLINE { $r = shift; "PRINT called $$r times\n"; }
+
+=item GETC this
+
+This method will be called when the C<getc> function is called.
+
+ sub GETC { print "Don't GETC, Get Perl"; return "a"; }
+
+=item CLOSE this
+
+This method will be called when the handle is closed via the C<close>
+function.
+
+ sub CLOSE { print "CLOSE called.\n" }
+
+=item DESTROY this
+
+As with the other types of ties, this method will be called when the
+tied handle is about to be destroyed. This is useful for debugging and
+possibly cleaning up.
+
+ sub DESTROY { print "</shout>\n" }
+
+=back
+
+Here's how to use our little example:
+
+ tie(*FOO,'Shout');
+ print FOO "hello\n";
+ $a = 4; $b = 6;
+ print FOO $a, " plus ", $b, " equals ", $a + $b, "\n";
+ print <FOO>;
+
+=head2 The C<untie> Gotcha
+
+If you intend making use of the object returned from either tie() or
+tied(), and if the tie's target class defines a destructor, there is a
+subtle gotcha you I<must> guard against.
+
+As setup, consider this (admittedly rather contrived) example of a
+tie; all it does is use a file to keep a log of the values assigned to
+a scalar.
+
+ package Remember;
+
+ use strict;
+ use IO::File;
+
+ sub TIESCALAR {
+ my $class = shift;
+ my $filename = shift;
+ my $handle = new IO::File "> $filename"
+ or die "Cannot open $filename: $!\n";
+
+ print $handle "The Start\n";
+ bless {FH => $handle, Value => 0}, $class;
+ }
+
+ sub FETCH {
+ my $self = shift;
+ return $self->{Value};
+ }
+
+ sub STORE {
+ my $self = shift;
+ my $value = shift;
+ my $handle = $self->{FH};
+ print $handle "$value\n";
+ $self->{Value} = $value;
+ }
+
+ sub DESTROY {
+ my $self = shift;
+ my $handle = $self->{FH};
+ print $handle "The End\n";
+ close $handle;
+ }
+
+ 1;
+
+Here is an example that makes use of this tie:
+
+ use strict;
+ use Remember;
+
+ my $fred;
+ tie $fred, 'Remember', 'myfile.txt';
+ $fred = 1;
+ $fred = 4;
+ $fred = 5;
+ untie $fred;
+ system "cat myfile.txt";
+
+This is the output when it is executed:
+
+ The Start
+ 1
+ 4
+ 5
+ The End
+
+So far so good. Those of you who have been paying attention will have
+spotted that the tied object hasn't been used so far. So lets add an
+extra method to the Remember class to allow comments to be included in
+the file -- say, something like this:
+
+ sub comment {
+ my $self = shift;
+ my $text = shift;
+ my $handle = $self->{FH};
+ print $handle $text, "\n";
+ }
+
+And here is the previous example modified to use the C<comment> method
+(which requires the tied object):
+
+ use strict;
+ use Remember;
+
+ my ($fred, $x);
+ $x = tie $fred, 'Remember', 'myfile.txt';
+ $fred = 1;
+ $fred = 4;
+ comment $x "changing...";
+ $fred = 5;
+ untie $fred;
+ system "cat myfile.txt";
+
+When this code is executed there is no output. Here's why:
+
+When a variable is tied, it is associated with the object which is the
+return value of the TIESCALAR, TIEARRAY, or TIEHASH function. This
+object normally has only one reference, namely, the implicit reference
+from the tied variable. When untie() is called, that reference is
+destroyed. Then, as in the first example above, the object's
+destructor (DESTROY) is called, which is normal for objects that have
+no more valid references; and thus the file is closed.
+
+In the second example, however, we have stored another reference to
+the tied object in C<$x>. That means that when untie() gets called
+there will still be a valid reference to the object in existence, so
+the destructor is not called at that time, and thus the file is not
+closed. The reason there is no output is because the file buffers
+have not been flushed to disk.
+
+Now that you know what the problem is, what can you do to avoid it?
+Well, the good old C<-w> flag will spot any instances where you call
+untie() and there are still valid references to the tied object. If
+the second script above is run with the C<-w> flag, Perl prints this
+warning message:
+
+ untie attempted while 1 inner references still exist
+
+To get the script to work properly and silence the warning make sure
+there are no valid references to the tied object I<before> untie() is
+called:
+
+ undef $x;
+ untie $fred;
+
+=head1 SEE ALSO
+
+See L<DB_File> or L<Config> for some interesting tie() implementations.
+
+=head1 BUGS
+
+Tied arrays are I<incomplete>. They are also distinctly lacking something
+for the C<$#ARRAY> access (which is hard, as it's an lvalue), as well as
+the other obvious array functions, like push(), pop(), shift(), unshift(),
+and splice().
+
+You cannot easily tie a multilevel data structure (such as a hash of
+hashes) to a dbm file. The first problem is that all but GDBM and
+Berkeley DB have size limitations, but beyond that, you also have problems
+with how references are to be represented on disk. One experimental
+module that does attempt to address this need partially is the MLDBM
+module. Check your nearest CPAN site as described in L<perlmodlib> for
+source code to MLDBM.
+
+=head1 AUTHOR
+
+Tom Christiansen
+
+TIEHANDLE by Sven Verdoolaege <F<skimo@dns.ufsia.ac.be>> and Doug MacEachern <F<dougm@osf.org>>
diff --git a/contrib/perl5/pod/perltoc.pod b/contrib/perl5/pod/perltoc.pod
new file mode 100644
index 0000000..980ca8f
--- /dev/null
+++ b/contrib/perl5/pod/perltoc.pod
@@ -0,0 +1,5840 @@
+
+=head1 NAME
+
+perltoc - perl documentation table of contents
+
+=head1 DESCRIPTION
+
+This page provides a brief table of contents for the rest of the Perl
+documentation set. It is meant to be scanned quickly or grepped
+through to locate the proper section you're looking for.
+
+=head1 BASIC DOCUMENTATION
+
+=head2 perl - Practical Extraction and Report Language
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+Many usability enhancements, Simplified grammar, Lexical scoping,
+Arbitrarily nested data structures, Modularity and reusability,
+Object-oriented programming, Embeddable and Extensible, POSIX compliant,
+Package constructors and destructors, Multiple simultaneous DBM
+implementations, Subroutine definitions may now be autoloaded, Regular
+expression enhancements, Innumerable Unbundled Modules, Compilability
+
+=item ENVIRONMENT
+
+=item AUTHOR
+
+=item FILES
+
+=item SEE ALSO
+
+=item DIAGNOSTICS
+
+=item BUGS
+
+=item NOTES
+
+=head2 perlfaq - frequently asked questions about Perl ($Date: 1998/07/20
+23:12:17 $)
+
+=item DESCRIPTION
+
+perlfaq: Structural overview of the FAQ, L<perlfaq1>: General Questions
+About Perl, L<perlfaq2>: Obtaining and Learning about Perl, L<perlfaq3>:
+Programming Tools, L<perlfaq4>: Data Manipulation, L<perlfaq5>: Files and
+Formats, L<perlfaq6>: Regexps, L<perlfaq7>: General Perl Language Issues,
+L<perlfaq8>: System Interaction, L<perlfaq9>: Networking
+
+=over
+
+=item Where to get this document
+
+=item How to contribute to this document
+
+=item What will happen if you mail your Perl programming problems to the
+authors
+
+=back
+
+=item Credits
+
+=item Author and Copyright Information
+
+=over
+
+=item Bundled Distributions
+
+=item Disclaimer
+
+=back
+
+=item Changes
+
+24/April/97, 23/April/97, 25/March/97, 18/March/97, 17/March/97 Version,
+Initial Release: 11/March/97
+
+=head2 perlfaq1 - General Questions About Perl ($Revision: 1.14 $, $Date:
+1998/06/14 22:15:25 $)
+
+=item DESCRIPTION
+
+=over
+
+=item What is Perl?
+
+=item Who supports Perl? Who develops it? Why is it free?
+
+=item Which version of Perl should I use?
+
+=item What are perl4 and perl5?
+
+=item How stable is Perl?
+
+=item Is Perl difficult to learn?
+
+=item How does Perl compare with other languages like Java, Python, REXX,
+Scheme, or Tcl?
+
+=item Can I do [task] in Perl?
+
+=item When shouldn't I program in Perl?
+
+=item What's the difference between "perl" and "Perl"?
+
+=item Is it a Perl program or a Perl script?
+
+=item What is a JAPH?
+
+=item Where can I get a list of Larry Wall witticisms?
+
+=item How can I convince my sysadmin/supervisor/employees to use version
+(5/5.004/Perl instead of some other language)?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.24 $,
+$Date: 1998/07/20 23:40:28 $)
+
+=item DESCRIPTION
+
+=over
+
+=item What machines support Perl? Where do I get it?
+
+=item How can I get a binary version of Perl?
+
+=item I don't have a C compiler on my system. How can I compile perl?
+
+=item I copied the Perl binary from one machine to another, but scripts
+don't work.
+
+=item I grabbed the sources and tried to compile but gdbm/dynamic
+loading/malloc/linking/... failed. How do I make it work?
+
+=item What modules and extensions are available for Perl? What is CPAN?
+What does CPAN/src/... mean?
+
+=item Is there an ISO or ANSI certified version of Perl?
+
+=item Where can I get information on Perl?
+
+=item What are the Perl newsgroups on USENET? Where do I post questions?
+
+=item Where should I post source code?
+
+=item Perl Books
+
+References, Tutorials
+*Learning Perl [2nd edition]
+by Randal L. Schwartz and Tom Christiansen, Task-Oriented, Special Topics
+
+=item Perl in Magazines
+
+=item Perl on the Net: FTP and WWW Access
+
+=item What mailing lists are there for perl?
+
+MacPerl, Perl5-Porters, NTPerl, Perl-Packrats
+
+=item Archives of comp.lang.perl.misc
+
+=item Where can I buy a commercial version of Perl?
+
+=item Where do I send bug reports?
+
+=item What is perl.com? perl.org? The Perl Institute?
+
+=item How do I learn about object-oriented Perl programming?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq3 - Programming Tools ($Revision: 1.28 $, $Date: 1998/07/16
+22:08:49 $)
+
+=item DESCRIPTION
+
+=over
+
+=item How do I do (anything)?
+
+=item How can I use Perl interactively?
+
+=item Is there a Perl shell?
+
+=item How do I debug my Perl programs?
+
+=item How do I profile my Perl programs?
+
+=item How do I cross-reference my Perl programs?
+
+=item Is there a pretty-printer (formatter) for Perl?
+
+=item Is there a ctags for Perl?
+
+=item Where can I get Perl macros for vi?
+
+=item Where can I get perl-mode for emacs?
+
+=item How can I use curses with Perl?
+
+=item How can I use X or Tk with Perl?
+
+=item How can I generate simple menus without using CGI or Tk?
+
+=item What is undump?
+
+=item How can I make my Perl program run faster?
+
+=item How can I make my Perl program take less memory?
+
+=item Is it unsafe to return a pointer to local data?
+
+=item How can I free an array or hash so my program shrinks?
+
+=item How can I make my CGI script more efficient?
+
+=item How can I hide the source for my Perl program?
+
+=item How can I compile my Perl program into byte code or C?
+
+=item How can I get C<#!perl> to work on [MS-DOS,NT,...]?
+
+=item Can I write useful perl programs on the command line?
+
+=item Why don't perl one-liners work on my DOS/Mac/VMS system?
+
+=item Where can I learn about CGI or Web programming in Perl?
+
+=item Where can I learn about object-oriented Perl programming?
+
+=item Where can I learn about linking C with Perl? [h2xs, xsubpp]
+
+=item I've read perlembed, perlguts, etc., but I can't embed perl in
+my C program, what am I doing wrong?
+
+=item When I tried to run my script, I got this message. What does it
+mean?
+
+=item What's MakeMaker?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq4 - Data Manipulation ($Revision: 1.25 $, $Date: 1998/07/16
+22:49:55 $)
+
+=item DESCRIPTION
+
+=item Data: Numbers
+
+=over
+
+=item Why am I getting long decimals (eg, 19.9499999999999) instead of the
+numbers I should be getting (eg, 19.95)?
+
+=item Why isn't my octal data interpreted correctly?
+
+=item Does perl have a round function? What about ceil() and floor()?
+Trig functions?
+
+=item How do I convert bits into ints?
+
+=item How do I multiply matrices?
+
+=item How do I perform an operation on a series of integers?
+
+=item How can I output Roman numerals?
+
+=item Why aren't my random numbers random?
+
+=back
+
+=item Data: Dates
+
+=over
+
+=item How do I find the week-of-the-year/day-of-the-year?
+
+=item How can I compare two dates and find the difference?
+
+=item How can I take a string and turn it into epoch seconds?
+
+=item How can I find the Julian Day?
+
+=item Does Perl have a year 2000 problem? Is Perl Y2K compliant?
+
+=back
+
+=item Data: Strings
+
+=over
+
+=item How do I validate input?
+
+=item How do I unescape a string?
+
+=item How do I remove consecutive pairs of characters?
+
+=item How do I expand function calls in a string?
+
+=item How do I find matching/nesting anything?
+
+=item How do I reverse a string?
+
+=item How do I expand tabs in a string?
+
+=item How do I reformat a paragraph?
+
+=item How can I access/change the first N letters of a string?
+
+=item How do I change the Nth occurrence of something?
+
+=item How can I count the number of occurrences of a substring within a
+string?
+
+=item How do I capitalize all the words on one line?
+
+=item How can I split a [character] delimited string except when inside
+[character]? (Comma-separated files)
+
+=item How do I strip blank space from the beginning/end of a string?
+
+=item How do I extract selected columns from a string?
+
+=item How do I find the soundex value of a string?
+
+=item How can I expand variables in text strings?
+
+=item What's wrong with always quoting "$vars"?
+
+=item Why don't my <<HERE documents work?
+
+1. There must be no space after the << part, 2. There (probably) should be
+a semicolon at the end, 3. You can't (easily) have any space in front of
+the tag
+
+=back
+
+=item Data: Arrays
+
+=over
+
+=item What is the difference between $array[1] and @array[1]?
+
+=item How can I extract just the unique elements of an array?
+
+a) If @in is sorted, and you want @out to be sorted:(this assumes all true
+values in the array), b) If you don't know whether @in is sorted:, c) Like
+(b), but @in contains only small integers:, d) A way to do (b) without any
+loops or greps:, e) Like (d), but @in contains only small positive
+integers:
+
+=item How can I tell whether a list or array contains a certain element?
+
+=item How do I compute the difference of two arrays? How do I compute the
+intersection of two arrays?
+
+=item How do I find the first array element for which a condition is true?
+
+=item How do I handle linked lists?
+
+=item How do I handle circular lists?
+
+=item How do I shuffle an array randomly?
+
+=item How do I process/modify each element of an array?
+
+=item How do I select a random element from an array?
+
+=item How do I permute N elements of a list?
+
+=item How do I sort an array by (anything)?
+
+=item How do I manipulate arrays of bits?
+
+=item Why does defined() return true on empty arrays and hashes?
+
+=back
+
+=item Data: Hashes (Associative Arrays)
+
+=over
+
+=item How do I process an entire hash?
+
+=item What happens if I add or remove keys from a hash while iterating over
+it?
+
+=item How do I look up a hash element by value?
+
+=item How can I know how many entries are in a hash?
+
+=item How do I sort a hash (optionally by value instead of key)?
+
+=item How can I always keep my hash sorted?
+
+=item What's the difference between "delete" and "undef" with hashes?
+
+=item Why don't my tied hashes make the defined/exists distinction?
+
+=item How do I reset an each() operation part-way through?
+
+=item How can I get the unique keys from two hashes?
+
+=item How can I store a multidimensional array in a DBM file?
+
+=item How can I make my hash remember the order I put elements into it?
+
+=item Why does passing a subroutine an undefined element in a hash create
+it?
+
+=item How can I make the Perl equivalent of a C structure/C++ class/hash or
+array of hashes or arrays?
+
+=item How can I use a reference as a hash key?
+
+=back
+
+=item Data: Misc
+
+=over
+
+=item How do I handle binary data correctly?
+
+=item How do I determine whether a scalar is a number/whole/integer/float?
+
+=item How do I keep persistent data across program calls?
+
+=item How do I print out or copy a recursive data structure?
+
+=item How do I define methods for every class/object?
+
+=item How do I verify a credit card checksum?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq5 - Files and Formats ($Revision: 1.24 $, $Date: 1998/07/05
+15:07:20 $)
+
+=item DESCRIPTION
+
+=over
+
+=item How do I flush/unbuffer an output filehandle? Why must I do this?
+
+=item How do I change one line in a file/delete a line in a file/insert a
+line in the middle of a file/append to the beginning of a file?
+
+=item How do I count the number of lines in a file?
+
+=item How do I make a temporary file name?
+
+=item How can I manipulate fixed-record-length files?
+
+=item How can I make a filehandle local to a subroutine? How do I pass
+filehandles between subroutines? How do I make an array of filehandles?
+
+=item How can I use a filehandle indirectly?
+
+=item How can I set up a footer format to be used with write()?
+
+=item How can I write() into a string?
+
+=item How can I output my numbers with commas added?
+
+=item How can I translate tildes (~) in a filename?
+
+=item How come when I open a file read-write it wipes it out?
+
+=item Why do I sometimes get an "Argument list too long" when I use <*>?
+
+=item Is there a leak/bug in glob()?
+
+=item How can I open a file with a leading "E<gt>" or trailing blanks?
+
+=item How can I reliably rename a file?
+
+=item How can I lock a file?
+
+=item What can't I just open(FH, ">file.lock")?
+
+=item I still don't get locking. I just want to increment the number in
+the file. How can I do this?
+
+=item How do I randomly update a binary file?
+
+=item How do I get a file's timestamp in perl?
+
+=item How do I set a file's timestamp in perl?
+
+=item How do I print to more than one file at once?
+
+=item How can I read in a file by paragraphs?
+
+=item How can I read a single character from a file? From the keyboard?
+
+=item How can I tell if there's a character waiting on a filehandle?
+
+=item How do I do a C<tail -f> in perl?
+
+=item How do I dup() a filehandle in Perl?
+
+=item How do I close a file descriptor by number?
+
+=item Why can't I use "C:\temp\foo" in DOS paths? What doesn't
+`C:\temp\foo.exe` work?
+
+=item Why doesn't glob("*.*") get all the files?
+
+=item Why does Perl let me delete read-only files? Why does C<-i> clobber
+protected files? Isn't this a bug in Perl?
+
+=item How do I select a random line from a file?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq6 - Regexps ($Revision: 1.22 $, $Date: 1998/07/16 14:01:07 $)
+
+=item DESCRIPTION
+
+=over
+
+=item How can I hope to use regular expressions without creating illegible
+and unmaintainable code?
+
+Comments Outside the Regexp, Comments Inside the Regexp, Different
+Delimiters
+
+=item I'm having trouble matching over more than one line. What's wrong?
+
+=item How can I pull out lines between two patterns that are themselves on
+different lines?
+
+=item I put a regular expression into $/ but it didn't work. What's wrong?
+
+=item How do I substitute case insensitively on the LHS, but preserving
+case on the RHS?
+
+=item How can I make C<\w> match national character sets?
+
+=item How can I match a locale-smart version of C</[a-zA-Z]/>?
+
+=item How can I quote a variable to use in a regexp?
+
+=item What is C</o> really for?
+
+=item How do I use a regular expression to strip C style comments from a
+file?
+
+=item Can I use Perl regular expressions to match balanced text?
+
+=item What does it mean that regexps are greedy? How can I get around it?
+
+=item How do I process each word on each line?
+
+=item How can I print out a word-frequency or line-frequency summary?
+
+=item How can I do approximate matching?
+
+=item How do I efficiently match many regular expressions at once?
+
+=item Why don't word-boundary searches with C<\b> work for me?
+
+=item Why does using $&, $`, or $' slow my program down?
+
+=item What good is C<\G> in a regular expression?
+
+=item Are Perl regexps DFAs or NFAs? Are they POSIX compliant?
+
+=item What's wrong with using grep or map in a void context?
+
+=item How can I match strings with multibyte characters?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq7 - Perl Language Issues ($Revision: 1.21 $, $Date:
+1998/06/22 15:20:07 $)
+
+=item DESCRIPTION
+
+=over
+
+=item Can I get a BNF/yacc/RE for the Perl language?
+
+=item What are all these $@%* punctuation signs, and how do I know when to
+use them?
+
+=item Do I always/never have to quote my strings or use semicolons and
+commas?
+
+=item How do I skip some return values?
+
+=item How do I temporarily block warnings?
+
+=item What's an extension?
+
+=item Why do Perl operators have different precedence than C operators?
+
+=item How do I declare/create a structure?
+
+=item How do I create a module?
+
+=item How do I create a class?
+
+=item How can I tell if a variable is tainted?
+
+=item What's a closure?
+
+=item What is variable suicide and how can I prevent it?
+
+=item How can I pass/return a {Function, FileHandle, Array, Hash, Method,
+Regexp}?
+
+Passing Variables and Functions, Passing Filehandles, Passing Regexps,
+Passing Methods
+
+=item How do I create a static variable?
+
+=item What's the difference between dynamic and lexical (static) scoping?
+Between local() and my()?
+
+=item How can I access a dynamic variable while a similarly named lexical
+is in scope?
+
+=item What's the difference between deep and shallow binding?
+
+=item Why doesn't "my($foo) = <FILE>;" work right?
+
+=item How do I redefine a builtin function, operator, or method?
+
+=item What's the difference between calling a function as &foo and foo()?
+
+=item How do I create a switch or case statement?
+
+=item How can I catch accesses to undefined variables/functions/methods?
+
+=item Why can't a method included in this same file be found?
+
+=item How can I find out my current package?
+
+=item How can I comment out a large block of perl code?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq8 - System Interaction ($Revision: 1.25 $, $Date: 1998/07/05
+15:07:20 $)
+
+=item DESCRIPTION
+
+=over
+
+=item How do I find out which operating system I'm running under?
+
+=item How come exec() doesn't return?
+
+=item How do I do fancy stuff with the keyboard/screen/mouse?
+
+Keyboard, Screen, Mouse
+
+=item How do I print something out in color?
+
+=item How do I read just one key without waiting for a return key?
+
+=item How do I check whether input is ready on the keyboard?
+
+=item How do I clear the screen?
+
+=item How do I get the screen size?
+
+=item How do I ask the user for a password?
+
+=item How do I read and write the serial port?
+
+lockfiles, open mode, end of line, flushing output, non-blocking input
+
+=item How do I decode encrypted password files?
+
+=item How do I start a process in the background?
+
+STDIN, STDOUT, and STDERR are shared, Signals, Zombies
+
+=item How do I trap control characters/signals?
+
+=item How do I modify the shadow password file on a Unix system?
+
+=item How do I set the time and date?
+
+=item How can I sleep() or alarm() for under a second?
+
+=item How can I measure time under a second?
+
+=item How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
+
+=item Why doesn't my sockets program work under System V (Solaris)? What
+does the error message "Protocol not supported" mean?
+
+=item How can I call my system's unique C functions from Perl?
+
+=item Where do I get the include files to do ioctl() or syscall()?
+
+=item Why do setuid perl scripts complain about kernel problems?
+
+=item How can I open a pipe both to and from a command?
+
+=item Why can't I get the output of a command with system()?
+
+=item How can I capture STDERR from an external command?
+
+=item Why doesn't open() return an error when a pipe open fails?
+
+=item What's wrong with using backticks in a void context?
+
+=item How can I call backticks without shell processing?
+
+=item Why can't my script read from STDIN after I gave it EOF (^D on Unix,
+^Z on MS-DOS)?
+
+=item How can I convert my shell script to perl?
+
+=item Can I use perl to run a telnet or ftp session?
+
+=item How can I write expect in Perl?
+
+=item Is there a way to hide perl's command line from programs such as
+"ps"?
+
+=item I {changed directory, modified my environment} in a perl script. How
+come the change disappeared when I exited the script? How do I get my
+changes to be visible?
+
+Unix
+
+=item How do I close a process's filehandle without waiting for it to
+complete?
+
+=item How do I fork a daemon process?
+
+=item How do I make my program run with sh and csh?
+
+=item How do I find out if I'm running interactively or not?
+
+=item How do I timeout a slow event?
+
+=item How do I set CPU limits?
+
+=item How do I avoid zombies on a Unix system?
+
+=item How do I use an SQL database?
+
+=item How do I make a system() exit on control-C?
+
+=item How do I open a file without blocking?
+
+=item How do I install a CPAN module?
+
+=item What's the difference between require and use?
+
+=item How do I keep my own module/library directory?
+
+=item How do I add the directory my program lives in to the module/library
+search path?
+
+=item How do I add a directory to my include path at runtime?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perlfaq9 - Networking ($Revision: 1.20 $, $Date: 1998/06/22 18:31:09
+$)
+
+=item DESCRIPTION
+
+=over
+
+=item My CGI script runs from the command line but not the browser. (500
+Server Error)
+
+=item How can I get better error messages from a CGI program?
+
+=item How do I remove HTML from a string?
+
+=item How do I extract URLs?
+
+=item How do I download a file from the user's machine? How do I open a
+file on another machine?
+
+=item How do I make a pop-up menu in HTML?
+
+=item How do I fetch an HTML file?
+
+=item How do I automate an HTML form submission?
+
+=item How do I decode or create those %-encodings on the web?
+
+=item How do I redirect to another page?
+
+=item How do I put a password on my web pages?
+
+=item How do I edit my .htpasswd and .htgroup files with Perl?
+
+=item How do I make sure users can't enter values into a form that cause my
+CGI script to do bad things?
+
+=item How do I parse a mail header?
+
+=item How do I decode a CGI form?
+
+=item How do I check a valid mail address?
+
+=item How do I decode a MIME/BASE64 string?
+
+=item How do I return the user's mail address?
+
+=item How do I send mail?
+
+=item How do I read mail?
+
+=item How do I find out my hostname/domainname/IP address?
+
+=item How do I fetch a news article or the active newsgroups?
+
+=item How do I fetch/put an FTP file?
+
+=item How can I do RPC in Perl?
+
+=back
+
+=item AUTHOR AND COPYRIGHT
+
+=head2 perldelta - what's new for perl5.005
+
+=item DESCRIPTION
+
+=item About the new versioning system
+
+=item Incompatible Changes
+
+=over
+
+=item WARNING: This version is not binary compatible with Perl 5.004.
+
+=item Default installation structure has changed
+
+=item Perl Source Compatibility
+
+=item C Source Compatibility
+
+Core sources now require ANSI C compiler, All Perl global variables must
+now be referenced with an explicit prefix, Enabling threads has source
+compatibility issues
+
+=item Binary Compatibility
+
+=item Security fixes may affect compatibility
+
+=item Relaxed new mandatory warnings introduced in 5.004
+
+=item Licensing
+
+=back
+
+=item Core Changes
+
+=over
+
+=item Threads
+
+=item Compiler
+
+=item Regular Expressions
+
+Many new and improved optimizations, Many bug fixes, New regular expression
+constructs, New operator for precompiled regular expressions, Other
+improvements, Incompatible changes
+
+=item Improved malloc()
+
+=item Quicksort is internally implemented
+
+=item Reliable signals
+
+=item Reliable stack pointers
+
+=item More generous treatment of carriage returns
+
+=item Memory leaks
+
+=item Better support for multiple interpreters
+
+=item Behavior of local() on array and hash elements is now well-defined
+
+=item C<%!> is transparently tied to the L<Errno> module
+
+=item Pseudo-hashes are supported
+
+=item C<EXPR foreach EXPR> is supported
+
+=item Keywords can be globally overridden
+
+=item C<$^E> is meaningful on Win32
+
+=item C<foreach (1..1000000)> optimized
+
+=item C<Foo::> can be used as implicitly quoted package name
+
+=item C<exists $Foo::{Bar::}> tests existence of a package
+
+=item Better locale support
+
+=item Experimental support for 64-bit platforms
+
+=item prototype() returns useful results on builtins
+
+=item Extended support for exception handling
+
+=item Re-blessing in DESTROY() supported for chaining DESTROY() methods
+
+=item All C<printf> format conversions are handled internally
+
+=item New C<INIT> keyword
+
+=item New C<lock> keyword
+
+=item New C<qr//> operator
+
+=item C<our> is now a reserved word
+
+=item Tied arrays are now fully supported
+
+=item Tied handles support is better
+
+=item 4th argument to substr
+
+=item Negative LENGTH argument to splice
+
+=item Magic lvalues are now more magical
+
+=item E<lt>E<gt> now reads in records
+
+=back
+
+=item Supported Platforms
+
+=over
+
+=item New Platforms
+
+=item Changes in existing support
+
+=back
+
+=item Modules and Pragmata
+
+=over
+
+=item New Modules
+
+B, Data::Dumper, Errno, File::Spec, ExtUtils::Installed,
+ExtUtils::Packlist, Fatal, IPC::SysV, Test, Tie::Array, Tie::Handle,
+Thread, attrs, fields, re
+
+=item Changes in existing modules
+
+CGI, POSIX, DB_File, MakeMaker, CPAN, Cwd, Benchmark
+
+=back
+
+=item Utility Changes
+
+=item Documentation Changes
+
+=item New Diagnostics
+
+Ambiguous call resolved as CORE::%s(), qualify as such or use &, Bad index
+while coercing array into hash, Bareword "%s" refers to nonexistent
+package, Can't call method "%s" on an undefined value, Can't coerce array
+into hash, Can't goto subroutine from an eval-string, Can't localize
+pseudo-hash element, Can't use %%! because Errno.pm is not available,
+Cannot find an opnumber for "%s", Character class syntax [. .] is reserved
+for future extensions, Character class syntax [: :] is reserved for future
+extensions, Character class syntax [= =] is reserved for future extensions,
+%s: Eval-group in insecure regular expression, %s: Eval-group not allowed,
+use re 'eval', %s: Eval-group not allowed at run time, Explicit blessing to
+'' (assuming package main), Illegal hex digit ignored, No such array field,
+No such field "%s" in variable %s of type %s, Out of memory during
+ridiculously large request, Range iterator outside integer range, Recursive
+inheritance detected while looking for method '%s' in package '%s',
+Reference found where even-sized list expected, Undefined value assigned to
+typeglob, Use of reserved word "%s" is deprecated, perl: warning: Setting
+locale failed
+
+=item Obsolete Diagnostics
+
+Can't mktemp(), Can't write to temp file for B<-e>: %s, Cannot open
+temporary file
+
+=item BUGS
+
+=item SEE ALSO
+
+=item HISTORY
+
+=head2 perldata - Perl data types
+
+=item DESCRIPTION
+
+=over
+
+=item Variable names
+
+=item Context
+
+=item Scalar values
+
+=item Scalar value constructors
+
+=item List value constructors
+
+=item Typeglobs and Filehandles
+
+=back
+
+=head2 perlsyn - Perl syntax
+
+=item DESCRIPTION
+
+=over
+
+=item Declarations
+
+=item Simple statements
+
+=item Compound statements
+
+=item Loop Control
+
+=item For Loops
+
+=item Foreach Loops
+
+=item Basic BLOCKs and Switch Statements
+
+=item Goto
+
+=item PODs: Embedded Documentation
+
+=item Plain Old Comments (Not!)
+
+=back
+
+=head2 perlop - Perl operators and precedence
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Terms and List Operators (Leftward)
+
+=item The Arrow Operator
+
+=item Auto-increment and Auto-decrement
+
+=item Exponentiation
+
+=item Symbolic Unary Operators
+
+=item Binding Operators
+
+=item Multiplicative Operators
+
+=item Additive Operators
+
+=item Shift Operators
+
+=item Named Unary Operators
+
+=item Relational Operators
+
+=item Equality Operators
+
+=item Bitwise And
+
+=item Bitwise Or and Exclusive Or
+
+=item C-style Logical And
+
+=item C-style Logical Or
+
+=item Range Operators
+
+=item Conditional Operator
+
+=item Assignment Operators
+
+=item Comma Operator
+
+=item List Operators (Rightward)
+
+=item Logical Not
+
+=item Logical And
+
+=item Logical or and Exclusive Or
+
+=item C Operators Missing From Perl
+
+unary &, unary *, (TYPE)
+
+=item Quote and Quote-like Operators
+
+=item Regexp Quote-Like Operators
+
+?PATTERN?, m/PATTERN/cgimosx, /PATTERN/cgimosx, q/STRING/, C<'STRING'>,
+qq/STRING/, "STRING", qr/STRING/imosx, qx/STRING/, `STRING`, qw/STRING/,
+s/PATTERN/REPLACEMENT/egimosx, tr/SEARCHLIST/REPLACEMENTLIST/cds,
+y/SEARCHLIST/REPLACEMENTLIST/cds
+
+=item Gory details of parsing quoted constructs
+
+Finding the end, Removal of backslashes before delimiters, Interpolation,
+C<<<'EOF'>, C<m''>, C<s'''>, C<tr///>, C<y///>, C<''>, C<q//>, C<"">,
+C<``>, C<qq//>, C<qx//>, C<<file*globE<gt>>, C<?RE?>, C</RE/>, C<m/RE/>,
+C<s/RE/foo/>,, Interpolation of regular expressions, Optimization of
+regular expressions
+
+=item I/O Operators
+
+=item Constant Folding
+
+=item Bitwise String Operators
+
+=item Integer Arithmetic
+
+=item Floating-point Arithmetic
+
+=item Bigger Numbers
+
+=back
+
+=head2 perlre - Perl regular expressions
+
+=item DESCRIPTION
+
+i, m, s, x
+
+=over
+
+=item Regular Expressions
+
+C<(?#text)>, C<(?:pattern)>, C<(?imsx-imsx:pattern)>, C<(?=pattern)>,
+C<(?!pattern)>, C<(?E<lt>=pattern)>, C<(?<!pattern)>, C<(?{ code })>,
+C<(?E<gt>pattern)>, C<(?(condition)yes-pattern|no-pattern)>,
+C<(?(condition)yes-pattern)>, C<(?imsx-imsx)>
+
+=item Backtracking
+
+=item Version 8 Regular Expressions
+
+=item WARNING on \1 vs $1
+
+=item Repeated patterns matching zero-length substring
+
+=item Creating custom RE engines
+
+=item SEE ALSO
+
+=back
+
+=head2 perlrun - how to execute the Perl interpreter
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item #! and quoting on non-Unix systems
+
+OS/2, MS-DOS, Win95/NT, Macintosh
+
+=item Location of Perl
+
+=item Switches
+
+B<-0>[I<digits>], B<-a>, B<-c>, B<-d>, B<-d:>I<foo>, B<-D>I<letters>,
+B<-D>I<number>, B<-e> I<commandline>, B<-F>I<pattern>, B<-h>,
+B<-i>[I<extension>], B<-I>I<directory>, B<-l>[I<octnum>],
+B<-m>[B<->]I<module>, B<-M>[B<->]I<module>, B<-M>[B<->]I<'module ...'>,
+B<-[mM]>[B<->]I<module=arg[,arg]...>, B<-n>, B<-p>, B<-P>, B<-s>, B<-S>,
+B<-T>, B<-u>, B<-U>, B<-v>, B<-V>, B<-V:>I<name>, B<-w>, B<-x> I<directory>
+
+=back
+
+=item ENVIRONMENT
+
+HOME, LOGDIR, PATH, PERL5LIB, PERL5OPT, PERLLIB, PERL5DB, PERL5SHELL
+(specific to WIN32 port), PERL_DEBUG_MSTATS, PERL_DESTRUCT_LEVEL
+
+=head2 perlfunc - Perl builtin functions
+
+=item DESCRIPTION
+
+=over
+
+=item Perl Functions by Category
+
+Functions for SCALARs or strings, Regular expressions and pattern matching,
+Numeric functions, Functions for real @ARRAYs, Functions for list data,
+Functions for real %HASHes, Input and output functions, Functions for fixed
+length data or records, Functions for filehandles, files, or directories,
+Keywords related to the control flow of your perl program, Keywords related
+to scoping, Miscellaneous functions, Functions for processes and process
+groups, Keywords related to perl modules, Keywords related to classes and
+object-orientedness, Low-level socket functions, System V interprocess
+communication functions, Fetching user and group info, Fetching network
+info, Time-related functions, Functions new in perl5, Functions obsoleted
+in perl5
+
+=item Alphabetical Listing of Perl Functions
+
+I<-X> FILEHANDLE, I<-X> EXPR, I<-X>, abs VALUE, abs, accept
+NEWSOCKET,GENERICSOCKET, alarm SECONDS, alarm, atan2 Y,X, bind SOCKET,NAME,
+binmode FILEHANDLE, bless REF,CLASSNAME, bless REF, caller EXPR, caller,
+chdir EXPR, chmod LIST, chomp VARIABLE, chomp LIST, chomp, chop VARIABLE,
+chop LIST, chop, chown LIST, chr NUMBER, chr, chroot FILENAME, chroot,
+close FILEHANDLE, close, closedir DIRHANDLE, connect SOCKET,NAME, continue
+BLOCK, cos EXPR, crypt PLAINTEXT,SALT, dbmclose HASH, dbmopen
+HASH,DBNAME,MODE, defined EXPR, defined, delete EXPR, die LIST, do BLOCK,
+do SUBROUTINE(LIST), do EXPR, dump LABEL, each HASH, eof FILEHANDLE, eof
+(), eof, eval EXPR, eval BLOCK, exec LIST, exec PROGRAM LIST, exists EXPR,
+exit EXPR, exp EXPR, exp, fcntl FILEHANDLE,FUNCTION,SCALAR, fileno
+FILEHANDLE, flock FILEHANDLE,OPERATION, fork, format, formline
+PICTURE,LIST, getc FILEHANDLE, getc, getlogin, getpeername SOCKET, getpgrp
+PID, getppid, getpriority WHICH,WHO, getpwnam NAME, getgrnam NAME,
+gethostbyname NAME, getnetbyname NAME, getprotobyname NAME, getpwuid UID,
+getgrgid GID, getservbyname NAME,PROTO, gethostbyaddr ADDR,ADDRTYPE,
+getnetbyaddr ADDR,ADDRTYPE, getprotobynumber NUMBER, getservbyport
+PORT,PROTO, getpwent, getgrent, gethostent, getnetent, getprotoent,
+getservent, setpwent, setgrent, sethostent STAYOPEN, setnetent STAYOPEN,
+setprotoent STAYOPEN, setservent STAYOPEN, endpwent, endgrent, endhostent,
+endnetent, endprotoent, endservent, getsockname SOCKET, getsockopt
+SOCKET,LEVEL,OPTNAME, glob EXPR, glob, gmtime EXPR, goto LABEL, goto EXPR,
+goto &NAME, grep BLOCK LIST, grep EXPR,LIST, hex EXPR, hex, import, index
+STR,SUBSTR,POSITION, index STR,SUBSTR, int EXPR, int, ioctl
+FILEHANDLE,FUNCTION,SCALAR, join EXPR,LIST, keys HASH, kill LIST, last
+LABEL, last, lc EXPR, lc, lcfirst EXPR, lcfirst, length EXPR, length, link
+OLDFILE,NEWFILE, listen SOCKET,QUEUESIZE, local EXPR, localtime EXPR, log
+EXPR, log, lstat FILEHANDLE, lstat EXPR, lstat, m//, map BLOCK LIST, map
+EXPR,LIST, mkdir FILENAME,MODE, msgctl ID,CMD,ARG, msgget KEY,FLAGS, msgsnd
+ID,MSG,FLAGS, msgrcv ID,VAR,SIZE,TYPE,FLAGS, my EXPR, next LABEL, next, no
+Module LIST, oct EXPR, oct, open FILEHANDLE,EXPR, open FILEHANDLE, opendir
+DIRHANDLE,EXPR, ord EXPR, ord, pack TEMPLATE,LIST, package, package
+NAMESPACE, pipe READHANDLE,WRITEHANDLE, pop ARRAY, pop, pos SCALAR, pos,
+print FILEHANDLE LIST, print LIST, print, printf FILEHANDLE FORMAT, LIST,
+printf FORMAT, LIST, prototype FUNCTION, push ARRAY,LIST, q/STRING/,
+qq/STRING/, qr/STRING/, qx/STRING/, qw/STRING/, quotemeta EXPR, quotemeta,
+rand EXPR, rand, read FILEHANDLE,SCALAR,LENGTH,OFFSET, read
+FILEHANDLE,SCALAR,LENGTH, readdir DIRHANDLE, readline EXPR, readlink EXPR,
+readlink, readpipe EXPR, recv SOCKET,SCALAR,LEN,FLAGS, redo LABEL, redo,
+ref EXPR, ref, rename OLDNAME,NEWNAME, require EXPR, require, reset EXPR,
+reset, return EXPR, return, reverse LIST, rewinddir DIRHANDLE, rindex
+STR,SUBSTR,POSITION, rindex STR,SUBSTR, rmdir FILENAME, rmdir, s///, scalar
+EXPR, seek FILEHANDLE,POSITION,WHENCE, seekdir DIRHANDLE,POS, select
+FILEHANDLE, select, select RBITS,WBITS,EBITS,TIMEOUT, semctl
+ID,SEMNUM,CMD,ARG, semget KEY,NSEMS,FLAGS, semop KEY,OPSTRING, send
+SOCKET,MSG,FLAGS,TO, send SOCKET,MSG,FLAGS, setpgrp PID,PGRP, setpriority
+WHICH,WHO,PRIORITY, setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL, shift ARRAY,
+shift, shmctl ID,CMD,ARG, shmget KEY,SIZE,FLAGS, shmread ID,VAR,POS,SIZE,
+shmwrite ID,STRING,POS,SIZE, shutdown SOCKET,HOW, sin EXPR, sin, sleep
+EXPR, sleep, socket SOCKET,DOMAIN,TYPE,PROTOCOL, socketpair
+SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL, sort SUBNAME LIST, sort BLOCK LIST,
+sort LIST, splice ARRAY,OFFSET,LENGTH,LIST, splice ARRAY,OFFSET,LENGTH,
+splice ARRAY,OFFSET, split /PATTERN/,EXPR,LIMIT, split /PATTERN/,EXPR,
+split /PATTERN/, split, sprintf FORMAT, LIST, sqrt EXPR, sqrt, srand EXPR,
+srand, stat FILEHANDLE, stat EXPR, stat, study SCALAR, study, sub BLOCK,
+sub NAME, sub NAME BLOCK, substr EXPR,OFFSET,LEN,REPLACEMENT, substr
+EXPR,OFFSET,LEN, substr EXPR,OFFSET, symlink OLDFILE,NEWFILE, syscall LIST,
+sysopen FILEHANDLE,FILENAME,MODE, sysopen FILEHANDLE,FILENAME,MODE,PERMS,
+sysread FILEHANDLE,SCALAR,LENGTH,OFFSET, sysread FILEHANDLE,SCALAR,LENGTH,
+sysseek FILEHANDLE,POSITION,WHENCE, system LIST, system PROGRAM LIST,
+syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET, syswrite
+FILEHANDLE,SCALAR,LENGTH, tell FILEHANDLE, tell, telldir DIRHANDLE, tie
+VARIABLE,CLASSNAME,LIST, tied VARIABLE, time, times, tr///, truncate
+FILEHANDLE,LENGTH, truncate EXPR,LENGTH, uc EXPR, uc, ucfirst EXPR,
+ucfirst, umask EXPR, umask, undef EXPR, undef, unlink LIST, unlink, unpack
+TEMPLATE,EXPR, untie VARIABLE, unshift ARRAY,LIST, use Module LIST, use
+Module, use Module VERSION LIST, use VERSION, utime LIST, values HASH, vec
+EXPR,OFFSET,BITS, wait, waitpid PID,FLAGS, wantarray, warn LIST, write
+FILEHANDLE, write EXPR, write, y///
+
+=back
+
+=head2 perlvar - Perl predefined variables
+
+=item DESCRIPTION
+
+=over
+
+=item Predefined Names
+
+$ARG, $_, $E<lt>I<digits>E<gt>, $MATCH, $&, $PREMATCH, $`, $POSTMATCH, $',
+$LAST_PAREN_MATCH, $+, $MULTILINE_MATCHING, $*, input_line_number HANDLE
+EXPR, $INPUT_LINE_NUMBER, $NR, $, input_record_separator HANDLE EXPR,
+$INPUT_RECORD_SEPARATOR, $RS, $/, autoflush HANDLE EXPR, $OUTPUT_AUTOFLUSH,
+$|, output_field_separator HANDLE EXPR, $OUTPUT_FIELD_SEPARATOR, $OFS, $,,
+output_record_separator HANDLE EXPR, $OUTPUT_RECORD_SEPARATOR, $ORS, $\,
+$LIST_SEPARATOR, $", $SUBSCRIPT_SEPARATOR, $SUBSEP, $;, $OFMT, $#,
+format_page_number HANDLE EXPR, $FORMAT_PAGE_NUMBER, $%,
+format_lines_per_page HANDLE EXPR, $FORMAT_LINES_PER_PAGE, $=,
+format_lines_left HANDLE EXPR, $FORMAT_LINES_LEFT, $-, format_name HANDLE
+EXPR, $FORMAT_NAME, $~, format_top_name HANDLE EXPR, $FORMAT_TOP_NAME, $^,
+format_line_break_characters HANDLE EXPR, $FORMAT_LINE_BREAK_CHARACTERS,
+$:, format_formfeed HANDLE EXPR, $FORMAT_FORMFEED, $^L, $ACCUMULATOR, $^A,
+$CHILD_ERROR, $?, $OS_ERROR, $ERRNO, $!, $EXTENDED_OS_ERROR, $^E,
+$EVAL_ERROR, $@, $PROCESS_ID, $PID, $$, $REAL_USER_ID, $UID, $<,
+$EFFECTIVE_USER_ID, $EUID, $>, $REAL_GROUP_ID, $GID, $(,
+$EFFECTIVE_GROUP_ID, $EGID, $), $PROGRAM_NAME, $0, $[, $PERL_VERSION, $],
+$DEBUGGING, $^D, $SYSTEM_FD_MAX, $^F, $^H, $INPLACE_EDIT, $^I, $^M,
+$OSNAME, $^O, $PERLDB, $^P, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, $^R, $^S,
+$BASETIME, $^T, $WARNING, $^W, $EXECUTABLE_NAME, $^X, $ARGV, @ARGV, @INC,
+@_, %INC, %ENV $ENV{expr}, %SIG $SIG{expr}
+
+=item Error Indicators
+
+=back
+
+=head2 perlsub - Perl subroutines
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Private Variables via C<my()>
+
+=item Peristent Private Variables
+
+=item Temporary Values via local()
+
+=item Passing Symbol Table Entries (typeglobs)
+
+=item When to Still Use local()
+
+1. You need to give a global variable a temporary value, especially C<$_>,
+2. You need to create a local file or directory handle or a local function,
+3. You want to temporarily change just one element of an array or hash
+
+=item Pass by Reference
+
+=item Prototypes
+
+=item Constant Functions
+
+=item Overriding Builtin Functions
+
+=item Autoloading
+
+=back
+
+=item SEE ALSO
+
+=head2 perlmod - Perl modules (packages and symbol tables)
+
+=item DESCRIPTION
+
+=over
+
+=item Packages
+
+=item Symbol Tables
+
+=item Package Constructors and Destructors
+
+=item Perl Classes
+
+=item Perl Modules
+
+=back
+
+=item SEE ALSO
+
+=head2 perlmodlib - constructing new Perl modules and finding existing ones
+
+=item DESCRIPTION
+
+=item THE PERL MODULE LIBRARY
+
+=over
+
+=item Pragmatic Modules
+
+use autouse MODULE => qw(sub1 sub2 sub3), blib, diagnostics, integer, less,
+lib, locale, ops, overload, re, sigtrap, strict, subs, vmsish, vars
+
+=item Standard Modules
+
+AnyDBM_File, AutoLoader, AutoSplit, Benchmark, CPAN, CPAN::FirstTime,
+CPAN::Nox, Carp, Class::Struct, Config, Cwd, DB_File, Devel::SelfStubber,
+DirHandle, DynaLoader, English, Env, Exporter, ExtUtils::Embed,
+ExtUtils::Install, ExtUtils::Liblist, ExtUtils::MM_OS2, ExtUtils::MM_Unix,
+ExtUtils::MM_VMS, ExtUtils::MakeMaker, ExtUtils::Manifest,
+ExtUtils::Mkbootstrap, ExtUtils::Mksymlists, ExtUtils::testlib, Fatal,
+Fcntl, File::Basename, File::CheckTree, File::Compare, File::Copy,
+File::Find, File::Path, File::stat, FileCache, FileHandle, FindBin,
+GDBM_File, Getopt::Long, Getopt::Std, I18N::Collate, IO, IO::File,
+IO::Handle, IO::Pipe, IO::Seekable, IO::Select, IO::Socket, IPC::Open2,
+IPC::Open3, Math::BigFloat, Math::BigInt, Math::Complex, Math::Trig,
+NDBM_File, Net::Ping, Net::hostent, Net::netent, Net::protoent,
+Net::servent, Opcode, Pod::Text, POSIX, SDBM_File, Safe, Search::Dict,
+SelectSaver, SelfLoader, Shell, Socket, Symbol, Sys::Hostname, Sys::Syslog,
+Term::Cap, Term::Complete, Term::ReadLine, Test::Harness, Text::Abbrev,
+Text::ParseWords, Text::Soundex, Text::Tabs, Text::Wrap, Tie::Hash,
+Tie::RefHash, Tie::Scalar, Tie::SubstrHash, Time::Local, Time::gmtime,
+Time::localtime, Time::tm, UNIVERSAL, User::grent, User::pwent
+
+=item Extension Modules
+
+=back
+
+=item CPAN
+
+Language Extensions and Documentation Tools, Development Support, Operating
+System Interfaces, Networking, Device Control (modems) and InterProcess
+Communication, Data Types and Data Type Utilities, Database Interfaces,
+User Interfaces, Interfaces to / Emulations of Other Programming Languages,
+File Names, File Systems and File Locking (see also File Handles), String
+Processing, Language Text Processing, Parsing, and Searching, Option,
+Argument, Parameter, and Configuration File Processing,
+Internationalization and Locale, Authentication, Security, and Encryption,
+World Wide Web, HTML, HTTP, CGI, MIME, Server and Daemon Utilities,
+Archiving and Compression, Images, Pixmap and Bitmap Manipulation, Drawing,
+and Graphing, Mail and Usenet News, Control Flow Utilities (callbacks and
+exceptions etc), File Handle and Input/Output Stream Utilities,
+Miscellaneous Modules, Africa, Asia, Australasia, Europe, North America,
+South America
+
+=item Modules: Creation, Use, and Abuse
+
+=over
+
+=item Guidelines for Module Creation
+
+Do similar modules already exist in some form?, Try to design the new
+module to be easy to extend and reuse, Some simple style guidelines, Select
+what to export, Select a name for the module, Have you got it right?,
+README and other Additional Files, A description of the
+module/package/extension etc, A copyright notice - see below, Prerequisites
+- what else you may need to have, How to build it - possible changes to
+Makefile.PL etc, How to install it, Recent changes in this release,
+especially incompatibilities, Changes / enhancements you plan to make in
+the future, Adding a Copyright Notice, Give the module a
+version/issue/release number, How to release and distribute a module, Take
+care when changing a released module
+
+=item Guidelines for Converting Perl 4 Library Scripts into Modules
+
+There is no requirement to convert anything, Consider the implications,
+Make the most of the opportunity, The pl2pm utility will get you started,
+Adds the standard Module prologue lines, Converts package specifiers from '
+to ::, Converts die(...) to croak(...), Several other minor changes
+
+=item Guidelines for Reusing Application Code
+
+Complete applications rarely belong in the Perl Module Library, Many
+applications contain some Perl code that could be reused, Break-out the
+reusable code into one or more separate module files, Take the opportunity
+to reconsider and redesign the interfaces, In some cases the 'application'
+can then be reduced to a small
+
+=back
+
+=item NOTE
+
+=head2 perlmodinstall - Installing CPAN Modules
+
+=item DESCRIPTION
+
+=over
+
+=item PREAMBLE
+
+B<DECOMPRESS> the file, B<UNPACK> the file into a directory, B<BUILD> the
+module (sometimes unnecessary), B<INSTALL> the module
+
+=back
+
+=item HEY
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 perlform - Perl formats
+
+=item DESCRIPTION
+
+=over
+
+=item Format Variables
+
+=back
+
+=item NOTES
+
+=over
+
+=item Footers
+
+=item Accessing Formatting Internals
+
+=back
+
+=item WARNINGS
+
+=head2 perllocale - Perl locale handling (internationalization and
+localization)
+
+=item DESCRIPTION
+
+=item PREPARING TO USE LOCALES
+
+=item USING LOCALES
+
+=over
+
+=item The use locale pragma
+
+=item The setlocale function
+
+=item Finding locales
+
+=item LOCALE PROBLEMS
+
+=item Temporarily fixing locale problems
+
+=item Permanently fixing locale problems
+
+=item Permanently fixing your locale configuration
+
+=item Permanently fixing system locale configuration
+
+=item The localeconv function
+
+=back
+
+=item LOCALE CATEGORIES
+
+=over
+
+=item Category LC_COLLATE: Collation
+
+=item Category LC_CTYPE: Character Types
+
+=item Category LC_NUMERIC: Numeric Formatting
+
+=item Category LC_MONETARY: Formatting of monetary amounts
+
+=item LC_TIME
+
+=item Other categories
+
+=back
+
+=item SECURITY
+
+B<Comparison operators> (C<lt>, C<le>, C<ge>, C<gt> and C<cmp>):,
+B<Case-mapping interpolation> (with C<\l>, C<\L>, C<\u> or C<\U>),
+B<Matching operator> (C<m//>):, B<Substitution operator> (C<s///>):,
+B<In-memory formatting function> (sprintf()):, B<Output formatting
+functions> (printf() and write()):, B<Case-mapping functions> (lc(),
+lcfirst(), uc(), ucfirst()):, B<POSIX locale-dependent functions>
+(localeconv(), strcoll(),strftime(), strxfrm()):, B<POSIX character class
+tests> (isalnum(), isalpha(), isdigit(),isgraph(), islower(), isprint(),
+ispunct(), isspace(), isupper(),
+isxdigit()):
+
+=item ENVIRONMENT
+
+PERL_BADLANG, LC_ALL, LC_CTYPE, LC_COLLATE, LC_MONETARY, LC_NUMERIC,
+LC_TIME, LANG
+
+=item NOTES
+
+=over
+
+=item Backward compatibility
+
+=item I18N:Collate obsolete
+
+=item Sort speed and memory use impacts
+
+=item write() and LC_NUMERIC
+
+=item Freely available locale definitions
+
+=item I18n and l10n
+
+=item An imperfect standard
+
+=back
+
+=item BUGS
+
+=over
+
+=item Broken systems
+
+=back
+
+=item SEE ALSO
+
+=item HISTORY
+
+=head2 perlref - Perl references and nested data structures
+
+=item DESCRIPTION
+
+=over
+
+=item Making References
+
+=item Using References
+
+=item Symbolic references
+
+=item Not-so-symbolic references
+
+=item Pseudo-hashes: Using an array as a hash
+
+=item Function Templates
+
+=back
+
+=item WARNING
+
+=item SEE ALSO
+
+=head2 perldsc - Perl Data Structures Cookbook
+
+=item DESCRIPTION
+
+arrays of arrays, hashes of arrays, arrays of hashes, hashes of hashes,
+more elaborate constructs
+
+=item REFERENCES
+
+=item COMMON MISTAKES
+
+=item CAVEAT ON PRECEDENCE
+
+=item WHY YOU SHOULD ALWAYS C<use strict>
+
+=item DEBUGGING
+
+=item CODE EXAMPLES
+
+=item LISTS OF LISTS
+
+=over
+
+=item Declaration of a LIST OF LISTS
+
+=item Generation of a LIST OF LISTS
+
+=item Access and Printing of a LIST OF LISTS
+
+=back
+
+=item HASHES OF LISTS
+
+=over
+
+=item Declaration of a HASH OF LISTS
+
+=item Generation of a HASH OF LISTS
+
+=item Access and Printing of a HASH OF LISTS
+
+=back
+
+=item LISTS OF HASHES
+
+=over
+
+=item Declaration of a LIST OF HASHES
+
+=item Generation of a LIST OF HASHES
+
+=item Access and Printing of a LIST OF HASHES
+
+=back
+
+=item HASHES OF HASHES
+
+=over
+
+=item Declaration of a HASH OF HASHES
+
+=item Generation of a HASH OF HASHES
+
+=item Access and Printing of a HASH OF HASHES
+
+=back
+
+=item MORE ELABORATE RECORDS
+
+=over
+
+=item Declaration of MORE ELABORATE RECORDS
+
+=item Declaration of a HASH OF COMPLEX RECORDS
+
+=item Generation of a HASH OF COMPLEX RECORDS
+
+=back
+
+=item Database Ties
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 perllol, perlLoL - Manipulating Lists of Lists in Perl
+
+=item DESCRIPTION
+
+=item Declaration and Access of Lists of Lists
+
+=item Growing Your Own
+
+=item Access and Printing
+
+=item Slices
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 perltoot - Tom's object-oriented tutorial for perl
+
+=item DESCRIPTION
+
+=item Creating a Class
+
+=over
+
+=item Object Representation
+
+=item Class Interface
+
+=item Constructors and Instance Methods
+
+=item Planning for the Future: Better Constructors
+
+=item Destructors
+
+=item Other Object Methods
+
+=back
+
+=item Class Data
+
+=over
+
+=item Accessing Class Data
+
+=item Debugging Methods
+
+=item Class Destructors
+
+=item Documenting the Interface
+
+=back
+
+=item Aggregation
+
+=item Inheritance
+
+=over
+
+=item Overridden Methods
+
+=item Multiple Inheritance
+
+=item UNIVERSAL: The Root of All Objects
+
+=back
+
+=item Alternate Object Representations
+
+=over
+
+=item Arrays as Objects
+
+=item Closures as Objects
+
+=back
+
+=item AUTOLOAD: Proxy Methods
+
+=over
+
+=item Autoloaded Data Methods
+
+=item Inherited Autoloaded Data Methods
+
+=back
+
+=item Metaclassical Tools
+
+=over
+
+=item Class::Struct
+
+=item Data Members as Variables
+
+=item NOTES
+
+=item Object Terminology
+
+=back
+
+=item SEE ALSO
+
+=item AUTHOR AND COPYRIGHT
+
+=item COPYRIGHT
+
+=over
+
+=item Acknowledgments
+
+=back
+
+=head2 perlobj - Perl objects
+
+=item DESCRIPTION
+
+=over
+
+=item An Object is Simply a Reference
+
+=item A Class is Simply a Package
+
+=item A Method is Simply a Subroutine
+
+=item Method Invocation
+
+=item Default UNIVERSAL methods
+
+isa(CLASS), can(METHOD), VERSION( [NEED] )
+
+=item Destructors
+
+=item WARNING
+
+=item Summary
+
+=item Two-Phased Garbage Collection
+
+=back
+
+=item SEE ALSO
+
+=head2 perltie - how to hide an object class in a simple variable
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Tying Scalars
+
+TIESCALAR classname, LIST, FETCH this, STORE this, value, DESTROY this
+
+=item Tying Arrays
+
+TIEARRAY classname, LIST, FETCH this, index, STORE this, index, value,
+DESTROY this
+
+=item Tying Hashes
+
+USER, HOME, CLOBBER, LIST, TIEHASH classname, LIST, FETCH this, key, STORE
+this, key, value, DELETE this, key, CLEAR this, EXISTS this, key, FIRSTKEY
+this, NEXTKEY this, lastkey, DESTROY this
+
+=item Tying FileHandles
+
+TIEHANDLE classname, LIST, WRITE this, LIST, PRINT this, LIST, PRINTF this,
+LIST, READ this, LIST, READLINE this, GETC this, CLOSE this, DESTROY this
+
+=item The C<untie> Gotcha
+
+=back
+
+=item SEE ALSO
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 perlbot - Bag'o Object Tricks (the BOT)
+
+=item DESCRIPTION
+
+=item OO SCALING TIPS
+
+=item INSTANCE VARIABLES
+
+=item SCALAR INSTANCE VARIABLES
+
+=item INSTANCE VARIABLE INHERITANCE
+
+=item OBJECT RELATIONSHIPS
+
+=item OVERRIDING SUPERCLASS METHODS
+
+=item USING RELATIONSHIP WITH SDBM
+
+=item THINKING OF CODE REUSE
+
+=item CLASS CONTEXT AND THE OBJECT
+
+=item INHERITING A CONSTRUCTOR
+
+=item DELEGATION
+
+=head2 perlipc - Perl interprocess communication (signals, fifos, pipes,
+safe subprocesses, sockets, and semaphores)
+
+=item DESCRIPTION
+
+=item Signals
+
+=item Named Pipes
+
+=over
+
+=item WARNING
+
+=back
+
+=item Using open() for IPC
+
+=over
+
+=item Filehandles
+
+=item Background Processes
+
+=item Complete Dissociation of Child from Parent
+
+=item Safe Pipe Opens
+
+=item Bidirectional Communication with Another Process
+
+=item Bidirectional Communication with Yourself
+
+=back
+
+=item Sockets: Client/Server Communication
+
+=over
+
+=item Internet Line Terminators
+
+=item Internet TCP Clients and Servers
+
+=item Unix-Domain TCP Clients and Servers
+
+=back
+
+=item TCP Clients with IO::Socket
+
+=over
+
+=item A Simple Client
+
+C<Proto>, C<PeerAddr>, C<PeerPort>
+
+=item A Webget Client
+
+=item Interactive Client with IO::Socket
+
+=back
+
+=item TCP Servers with IO::Socket
+
+Proto, LocalPort, Listen, Reuse
+
+=item UDP: Message Passing
+
+=item SysV IPC
+
+=item NOTES
+
+=item BUGS
+
+=item AUTHOR
+
+=item SEE ALSO
+
+=head2 perldebug - Perl debugging
+
+=item DESCRIPTION
+
+=item The Perl Debugger
+
+=over
+
+=item Debugger Commands
+
+h [command], p expr, x expr, V [pkg [vars]], X [vars], T, s [expr], n
+[expr], E<lt>CRE<gt>, c [line|sub], l, l min+incr, l min-max, l line, l
+subname, -, w [line], f filename, /pattern/, ?pattern?, L, S [[!]pattern],
+t, t expr, b [line] [condition], b subname [condition], b postpone subname
+[condition], b load filename, b compile subname, d [line], D, a [line]
+command, A, W [expr], W, O [opt[=val]] [opt"val"] [opt?]..,
+C<recallCommand>, C<ShellBang>, C<pager>, C<tkRunning>, C<signalLevel>,
+C<warnLevel>, C<dieLevel>, C<AutoTrace>, C<LineInfo>, C<inhibit_exit>,
+C<PrintRet>, C<ornaments>, C<frame>, C<maxTraceLen>, C<arrayDepth>,
+C<hashDepth>, C<compactDump>, C<veryCompact>, C<globPrint>, C<DumpDBFiles>,
+C<DumpPackages>, C<DumpReused>, C<quote>, C<HighBit>, C<undefPrint>,
+C<UsageOnly>, C<TTY>, C<noTTY>, C<ReadLine>, C<NonStop>, E<lt> [ command ],
+E<lt>E<lt> command, E<gt> command, E<gt>E<gt> command, { [ command ], {{
+command, ! number, ! -number, ! pattern, !! cmd, H -number, q or ^D, R,
+|dbcmd, ||dbcmd, command, m expr, m package
+
+=item Debugger input/output
+
+Prompt, Multiline commands, Stack backtrace, Listing, Frame listing
+
+=item Debugging compile-time statements
+
+=item Debugger Customization
+
+=item Readline Support
+
+=item Editor Support for Debugging
+
+=item The Perl Profiler
+
+=item Debugger support in perl
+
+=item Debugger Internals
+
+=item Other resources
+
+=item BUGS
+
+=back
+
+=item Debugging Perl memory usage
+
+=over
+
+=item Using C<$ENV{PERL_DEBUG_MSTATS}>
+
+C<buckets SMALLEST(APPROX)..GREATEST(APPROX)>, Free/Used, C<Total sbrk():
+SBRKed/SBRKs:CONTINUOUS>, C<pad: 0>, C<heads: 2192>, C<chain: 0>, C<tail:
+6144>
+
+=item Example of using B<-DL> switch
+
+C<717>, C<002>, C<054>, C<602>, C<702>, C<704>
+
+=item B<-DL> details
+
+C<!!!>, C<!!>, C<!>
+
+=item Limitations of B<-DL> statistic
+
+=back
+
+=item Debugging regular expressions
+
+=over
+
+=item Compile-time output
+
+C<anchored> I<STRING> C<at> I<POS>, C<floating> I<STRING> C<at>
+I<POS1..POS2>, C<matching floating/anchored>, C<minlen>, C<stclass>
+I<TYPE>, C<noscan>, C<isall>, C<GPOS>, C<plus>, C<implicit>, C<with eval>,
+C<anchored(TYPE)>
+
+=item Types of nodes
+
+=item Run-time output
+
+=back
+
+=head2 perldiag - various Perl diagnostics
+
+=item DESCRIPTION
+
+=head2 perlsec - Perl security
+
+=item DESCRIPTION
+
+=over
+
+=item Laundering and Detecting Tainted Data
+
+=item Switches On the "#!" Line
+
+=item Cleaning Up Your Path
+
+=item Security Bugs
+
+=item Protecting Your Programs
+
+=back
+
+=item SEE ALSO
+
+=head2 perltrap - Perl traps for the unwary
+
+=item DESCRIPTION
+
+=over
+
+=item Awk Traps
+
+=item C Traps
+
+=item Sed Traps
+
+=item Shell Traps
+
+=item Perl Traps
+
+=item Perl4 to Perl5 Traps
+
+Discontinuance, Deprecation, and BugFix traps, Parsing Traps, Numerical
+Traps, General data type traps, Context Traps - scalar, list contexts,
+Precedence Traps, General Regular Expression Traps using s///, etc,
+Subroutine, Signal, Sorting Traps, OS Traps, DBM Traps, Unclassified Traps
+
+=item Discontinuance, Deprecation, and BugFix traps
+
+Discontinuance, Deprecation, BugFix, Discontinuance, Discontinuance,
+Discontinuance, BugFix, Discontinuance, Discontinuance, BugFix,
+Discontinuance, Discontinuance, Deprecation, Discontinuance
+
+=item Parsing Traps
+
+Parsing, Parsing, Parsing, Parsing
+
+=item Numerical Traps
+
+Numerical, Numerical, Numerical
+
+=item General data type traps
+
+(Arrays), (Arrays), (Hashes), (Globs), (Globs), (Scalar String),
+(Constants), (Scalars), (Variable Suicide)
+
+=item Context Traps - scalar, list contexts
+
+(list context), (scalar context), (scalar context), (list, builtin)
+
+=item Precedence Traps
+
+Precedence, Precedence, Precedence, Precedence, Precedence, Precedence,
+Precedence
+
+=item General Regular Expression Traps using s///, etc.
+
+Regular Expression, Regular Expression, Regular Expression, Regular
+Expression, Regular Expression, Regular Expression, Regular Expression,
+Regular Expression
+
+=item Subroutine, Signal, Sorting Traps
+
+(Signals), (Sort Subroutine), warn() won't let you specify a filehandle
+
+=item OS Traps
+
+(SysV), (SysV)
+
+=item Interpolation Traps
+
+Interpolation, Interpolation, Interpolation, Interpolation, Interpolation,
+Interpolation, Interpolation, Interpolation, Interpolation
+
+=item DBM Traps
+
+DBM, DBM
+
+=item Unclassified Traps
+
+C<require>/C<do> trap using returned value, C<split> on empty string with
+LIMIT specified
+
+=back
+
+=head2 perlport - Writing portable Perl
+
+=item DESCRIPTION
+
+Not all Perl programs have to be portable, The vast majority of Perl B<is>
+portable
+
+=item ISSUES
+
+=over
+
+=item Newlines
+
+=item File Paths
+
+=item System Interaction
+
+=item Interprocess Communication (IPC)
+
+=item External Subroutines (XS)
+
+=item Standard Modules
+
+=item Time and Date
+
+=item System Resources
+
+=item Security
+
+=item Style
+
+=back
+
+=item CPAN TESTERS
+
+Mailing list: cpan-testers@perl.org, Testing results:
+C<http://www.connect.net/gbarr/cpan-test/>
+
+=item PLATFORMS
+
+=over
+
+=item Unix
+
+=item DOS and Derivatives
+
+The djgpp environment for DOS, C<http://www.delorie.com/djgpp/>, The EMX
+environment for DOS, OS/2, etc.
+C<emx@iaehv.nl>,C<http://www.juge.com/bbs/Hobb.19.html>, Build instructions
+for Win32, L<perlwin32>, The ActiveState Pages,
+C<http://www.activestate.com/>
+
+=item MacPerl
+
+The MacPerl Pages, C<http://www.ptf.com/macperl/>, The MacPerl mailing
+list, C<mac-perl-request@iis.ee.ethz.ch>
+
+=item VMS
+
+L<perlvms.pod>, vmsperl list, C<vmsperl-request@newman.upenn.edu>, vmsperl
+on the web, C<http://www.sidhe.org/vmsperl/index.html>
+
+=item EBCDIC Platforms
+
+perl-mvs list, AS/400 Perl information at C<http://as400.rochester.ibm.com>
+
+=item Other perls
+
+Atari, Guido Flohr's page C<http://stud.uni-sb.de/~gufl0000/>, HP 300
+MPE/iX C<http://www.cccd.edu/~markb/perlix.html>, Novell Netware
+
+=back
+
+=item FUNCTION IMPLEMENTATIONS
+
+=over
+
+=item Alphabetical Listing of Perl Functions
+
+-I<X> FILEHANDLE, -I<X> EXPR, -I<X>, binmode FILEHANDLE, chmod LIST, chown
+LIST, chroot FILENAME, chroot, crypt PLAINTEXT,SALT, dbmclose HASH, dbmopen
+HASH,DBNAME,MODE, dump LABEL, exec LIST, fcntl FILEHANDLE,FUNCTION,SCALAR,
+flock FILEHANDLE,OPERATION, fork, getlogin, getpgrp PID, getppid,
+getpriority WHICH,WHO, getpwnam NAME, getgrnam NAME, getnetbyname NAME,
+getpwuid UID, getgrgid GID, getnetbyaddr ADDR,ADDRTYPE, getprotobynumber
+NUMBER, getservbyport PORT,PROTO, getpwent, getgrent, gethostent,
+getnetent, getprotoent, getservent, setpwent, setgrent, sethostent
+STAYOPEN, setnetent STAYOPEN, setprotoent STAYOPEN, setservent STAYOPEN,
+endpwent, endgrent, endhostent, endnetent, endprotoent, endservent,
+getsockopt SOCKET,LEVEL,OPTNAME, glob EXPR, glob, ioctl
+FILEHANDLE,FUNCTION,SCALAR, kill LIST, link OLDFILE,NEWFILE, lstat
+FILEHANDLE, lstat EXPR, lstat, msgctl ID,CMD,ARG, msgget KEY,FLAGS, msgsnd
+ID,MSG,FLAGS, msgrcv ID,VAR,SIZE,TYPE,FLAGS, open FILEHANDLE,EXPR, open
+FILEHANDLE, pipe READHANDLE,WRITEHANDLE, readlink EXPR, readlink, select
+RBITS,WBITS,EBITS,TIMEOUT, semctl ID,SEMNUM,CMD,ARG, semget
+KEY,NSEMS,FLAGS, semop KEY,OPSTRING, setpgrp PID,PGRP, setpriority
+WHICH,WHO,PRIORITY, setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL, shmctl
+ID,CMD,ARG, shmget KEY,SIZE,FLAGS, shmread ID,VAR,POS,SIZE, shmwrite
+ID,STRING,POS,SIZE, socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL, stat
+FILEHANDLE, stat EXPR, stat, symlink OLDFILE,NEWFILE, syscall LIST, system
+LIST, times, truncate FILEHANDLE,LENGTH, truncate EXPR,LENGTH, umask EXPR,
+umask, utime LIST, wait, waitpid PID,FLAGS
+
+=back
+
+=item AUTHORS / CONTRIBUTORS
+
+=item VERSION
+
+=head2 perlstyle - Perl style guide
+
+=item DESCRIPTION
+
+=head2 perlpod - plain old documentation
+
+=item DESCRIPTION
+
+=over
+
+=item Verbatim Paragraph
+
+=item Command Paragraph
+
+=item Ordinary Block of Text
+
+=item The Intent
+
+=item Embedding Pods in Perl Modules
+
+=item Common Pod Pitfalls
+
+=back
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 perlbook - Perl book information
+
+=item DESCRIPTION
+
+=head2 perlembed - how to embed perl in your C program
+
+=item DESCRIPTION
+
+=over
+
+=item PREAMBLE
+
+B<Use C from Perl?>, B<Use a Unix program from Perl?>, B<Use Perl from
+Perl?>, B<Use C from C?>, B<Use Perl from C?>
+
+=item ROADMAP
+
+=item Compiling your C program
+
+=item Adding a Perl interpreter to your C program
+
+=item Calling a Perl subroutine from your C program
+
+=item Evaluating a Perl statement from your C program
+
+=item Performing Perl pattern matches and substitutions from your C program
+
+=item Fiddling with the Perl stack from your C program
+
+=item Maintaining a persistent interpreter
+
+=item Maintaining multiple interpreter instances
+
+=item Using Perl modules, which themselves use C libraries, from your C
+program
+
+=back
+
+=item Embedding Perl under Win32
+
+=item MORAL
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 perlapio - perl's IO abstraction interface.
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+B<PerlIO *>, B<PerlIO_stdin()>, B<PerlIO_stdout()>, B<PerlIO_stderr()>,
+B<PerlIO_open(path, mode)>, B<PerlIO_fdopen(fd,mode)>,
+B<PerlIO_printf(f,fmt,...)>, B<PerlIO_vprintf(f,fmt,a)>,
+B<PerlIO_stdoutf(fmt,...)>, B<PerlIO_read(f,buf,count)>,
+B<PerlIO_write(f,buf,count)>, B<PerlIO_close(f)>, B<PerlIO_puts(f,s)>,
+B<PerlIO_putc(f,c)>, B<PerlIO_ungetc(f,c)>, B<PerlIO_getc(f)>,
+B<PerlIO_eof(f)>, B<PerlIO_error(f)>, B<PerlIO_fileno(f)>,
+B<PerlIO_clearerr(f)>, B<PerlIO_flush(f)>, B<PerlIO_tell(f)>,
+B<PerlIO_seek(f,o,w)>, B<PerlIO_getpos(f,p)>, B<PerlIO_setpos(f,p)>,
+B<PerlIO_rewind(f)>, B<PerlIO_tmpfile()>
+
+=over
+
+=item Co-existence with stdio
+
+B<PerlIO_importFILE(f,flags)>, B<PerlIO_exportFILE(f,flags)>,
+B<PerlIO_findFILE(f)>, B<PerlIO_releaseFILE(p,f)>, B<PerlIO_setlinebuf(f)>,
+B<PerlIO_has_cntptr(f)>, B<PerlIO_get_ptr(f)>, B<PerlIO_get_cnt(f)>,
+B<PerlIO_canset_cnt(f)>, B<PerlIO_fast_gets(f)>,
+B<PerlIO_set_ptrcnt(f,p,c)>, B<PerlIO_set_cnt(f,c)>, B<PerlIO_has_base(f)>,
+B<PerlIO_get_base(f)>, B<PerlIO_get_bufsiz(f)>
+
+=back
+
+=head2 perlxs - XS language reference manual
+
+=item DESCRIPTION
+
+=over
+
+=item Introduction
+
+=item On The Road
+
+=item The Anatomy of an XSUB
+
+=item The Argument Stack
+
+=item The RETVAL Variable
+
+=item The MODULE Keyword
+
+=item The PACKAGE Keyword
+
+=item The PREFIX Keyword
+
+=item The OUTPUT: Keyword
+
+=item The CODE: Keyword
+
+=item The INIT: Keyword
+
+=item The NO_INIT Keyword
+
+=item Initializing Function Parameters
+
+=item Default Parameter Values
+
+=item The PREINIT: Keyword
+
+=item The SCOPE: Keyword
+
+=item The INPUT: Keyword
+
+=item Variable-length Parameter Lists
+
+=item The C_ARGS: Keyword
+
+=item The PPCODE: Keyword
+
+=item Returning Undef And Empty Lists
+
+=item The REQUIRE: Keyword
+
+=item The CLEANUP: Keyword
+
+=item The BOOT: Keyword
+
+=item The VERSIONCHECK: Keyword
+
+=item The PROTOTYPES: Keyword
+
+=item The PROTOTYPE: Keyword
+
+=item The ALIAS: Keyword
+
+=item The INTERFACE: Keyword
+
+=item The INTERFACE_MACRO: Keyword
+
+=item The INCLUDE: Keyword
+
+=item The CASE: Keyword
+
+=item The & Unary Operator
+
+=item Inserting Comments and C Preprocessor Directives
+
+=item Using XS With C++
+
+=item Interface Strategy
+
+=item Perl Objects And C Structures
+
+=item The Typemap
+
+=back
+
+=item EXAMPLES
+
+=item XS VERSION
+
+=item AUTHOR
+
+=head2 perlxstut, perlXStut - Tutorial for XSUBs
+
+=item DESCRIPTION
+
+=over
+
+=item VERSION CAVEAT
+
+=item DYNAMIC VERSUS STATIC
+
+=item EXAMPLE 1
+
+=item EXAMPLE 2
+
+=item WHAT HAS GONE ON?
+
+=item WRITING GOOD TEST SCRIPTS
+
+=item EXAMPLE 3
+
+=item WHAT'S NEW HERE?
+
+=item INPUT AND OUTPUT PARAMETERS
+
+=item THE XSUBPP COMPILER
+
+=item THE TYPEMAP FILE
+
+=item WARNING
+
+=item EXAMPLE 4
+
+=item WHAT HAS HAPPENED HERE?
+
+=item SPECIFYING ARGUMENTS TO XSUBPP
+
+=item THE ARGUMENT STACK
+
+=item EXTENDING YOUR EXTENSION
+
+=item DOCUMENTING YOUR EXTENSION
+
+=item INSTALLING YOUR EXTENSION
+
+=item SEE ALSO
+
+=item Author
+
+=item Last Changed
+
+=back
+
+=head2 perlguts - Perl's Internal Functions
+
+=item DESCRIPTION
+
+=item Variables
+
+=over
+
+=item Datatypes
+
+=item What is an "IV"?
+
+=item Working with SVs
+
+=item What's Really Stored in an SV?
+
+=item Working with AVs
+
+=item Working with HVs
+
+=item Hash API Extensions
+
+=item References
+
+=item Blessed References and Class Objects
+
+=item Creating New Variables
+
+=item Reference Counts and Mortality
+
+=item Stashes and Globs
+
+=item Double-Typed SVs
+
+=item Magic Variables
+
+=item Assigning Magic
+
+=item Magic Virtual Tables
+
+=item Finding Magic
+
+=item Understanding the Magic of Tied Hashes and Arrays
+
+=item Localizing changes
+
+C<SAVEINT(int i)>, C<SAVEIV(IV i)>, C<SAVEI32(I32 i)>, C<SAVELONG(long i)>,
+C<SAVESPTR(s)>, C<SAVEPPTR(p)>, C<SAVEFREESV(SV *sv)>, C<SAVEFREEOP(OP
+*op)>, C<SAVEFREEPV(p)>, C<SAVECLEARSV(SV *sv)>, C<SAVEDELETE(HV *hv, char
+*key, I32 length)>, C<SAVEDESTRUCTOR(f,p)>, C<SAVESTACK_POS()>, C<SV*
+save_scalar(GV *gv)>, C<AV* save_ary(GV *gv)>, C<HV* save_hash(GV *gv)>,
+C<void save_item(SV *item)>, C<void save_list(SV **sarg, I32 maxsarg)>,
+C<SV* save_svref(SV **sptr)>, C<void save_aptr(AV **aptr)>, C<void
+save_hptr(HV **hptr)>
+
+=back
+
+=item Subroutines
+
+=over
+
+=item XSUBs and the Argument Stack
+
+=item Calling Perl Routines from within C Programs
+
+=item Memory Allocation
+
+=item PerlIO
+
+=item Putting a C value on Perl stack
+
+=item Scratchpads
+
+=item Scratchpads and recursion
+
+=back
+
+=item Compiled code
+
+=over
+
+=item Code tree
+
+=item Examining the tree
+
+=item Compile pass 1: check routines
+
+=item Compile pass 1a: constant folding
+
+=item Compile pass 2: context propagation
+
+=item Compile pass 3: peephole optimization
+
+=back
+
+=item API LISTING
+
+av_clear, av_extend, av_fetch, AvFILL, av_len, av_make, av_pop, av_push,
+av_shift, av_store, av_undef, av_unshift, CLASS, Copy, croak, CvSTASH,
+PL_DBsingle, PL_DBsub, PL_DBtrace, dMARK, dORIGMARK, PL_dowarn, dSP,
+dXSARGS, dXSI32, do_binmode, ENTER, EXTEND, fbm_compile, fbm_instr,
+FREETMPS, G_ARRAY, G_DISCARD, G_EVAL, GIMME, GIMME_V, G_NOARGS, G_SCALAR,
+gv_fetchmeth, gv_fetchmethod, gv_fetchmethod_autoload, G_VOID, gv_stashpv,
+gv_stashsv, GvSV, HEf_SVKEY, HeHASH, HeKEY, HeKLEN, HePV, HeSVKEY,
+HeSVKEY_force, HeSVKEY_set, HeVAL, hv_clear, hv_delayfree_ent, hv_delete,
+hv_delete_ent, hv_exists, hv_exists_ent, hv_fetch, hv_fetch_ent,
+hv_free_ent, hv_iterinit, hv_iterkey, hv_iterkeysv, hv_iternext,
+hv_iternextsv, hv_iterval, hv_magic, HvNAME, hv_store, hv_store_ent,
+hv_undef, isALNUM, isALPHA, isDIGIT, isLOWER, isSPACE, isUPPER, items, ix,
+LEAVE, looks_like_number, MARK, mg_clear, mg_copy, mg_find, mg_free,
+mg_get, mg_len, mg_magical, mg_set, Move, PL_na, New, newAV, Newc,
+newCONSTSUB, newHV, newRV_inc, newRV_noinc, NEWSV, newSViv, newSVnv,
+newSVpv, newSVpvf, newSVpvn, newSVrv, newSVsv, newXS, newXSproto, Newz,
+Nullav, Nullch, Nullcv, Nullhv, Nullsv, ORIGMARK, perl_alloc,
+perl_call_argv, perl_call_method, perl_call_pv, perl_call_sv,
+perl_construct, perl_destruct, perl_eval_sv, perl_eval_pv, perl_free,
+perl_get_av, perl_get_cv, perl_get_hv, perl_get_sv, perl_parse,
+perl_require_pv, perl_run, POPi, POPl, POPp, POPn, POPs, PUSHMARK, PUSHi,
+PUSHn, PUSHp, PUSHs, PUSHu, PUTBACK, Renew, Renewc, RETVAL, safefree,
+safemalloc, saferealloc, savepv, savepvn, SAVETMPS, SP, SPAGAIN, ST, strEQ,
+strGE, strGT, strLE, strLT, strNE, strnEQ, strnNE, sv_2mortal, sv_bless,
+sv_catpv, sv_catpv_mg, sv_catpvn, sv_catpvn_mg, sv_catpvf, sv_catpvf_mg,
+sv_catsv, sv_catsv_mg, sv_chop, sv_cmp, SvCUR, SvCUR_set, sv_dec,
+sv_derived_from, sv_derived_from, SvEND, sv_eq, SvGETMAGIC, SvGROW,
+sv_grow, sv_inc, sv_insert, SvIOK, SvIOK_off, SvIOK_on, SvIOK_only, SvIOKp,
+sv_isa, sv_isobject, SvIV, SvIVX, SvLEN, sv_len, sv_magic, sv_mortalcopy,
+sv_newmortal, SvNIOK, SvNIOK_off, SvNIOKp, PL_sv_no, SvNOK, SvNOK_off,
+SvNOK_on, SvNOK_only, SvNOKp, SvNV, SvNVX, SvOK, SvOOK, SvPOK, SvPOK_off,
+SvPOK_on, SvPOK_only, SvPOKp, SvPV, SvPV_force, SvPVX, SvREFCNT,
+SvREFCNT_dec, SvREFCNT_inc, SvROK, SvROK_off, SvROK_on, SvRV, SvSETMAGIC,
+sv_setiv, sv_setiv_mg, sv_setnv, sv_setnv_mg, sv_setpv, sv_setpv_mg,
+sv_setpviv, sv_setpviv_mg, sv_setpvn, sv_setpvn_mg, sv_setpvf,
+sv_setpvf_mg, sv_setref_iv, sv_setref_nv, sv_setref_pv, sv_setref_pvn,
+SvSetSV, SvSetSV_nosteal, sv_setsv, sv_setsv_mg, sv_setuv, sv_setuv_mg,
+SvSTASH, SvTAINT, SvTAINTED, SvTAINTED_off, SvTAINTED_on, SVt_IV, SVt_PV,
+SVt_PVAV, SVt_PVCV, SVt_PVHV, SVt_PVMG, SVt_NV, SvTRUE, SvTYPE, svtype,
+PL_sv_undef, sv_unref, SvUPGRADE, sv_upgrade, sv_usepvn, sv_usepvn_mg,
+sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, used_locale),
+sv_vsetpvfn(sv, pat, patlen, args, svargs, svmax, used_locale), SvUV,
+SvUVX, PL_sv_yes, THIS, toLOWER, toUPPER, warn, XPUSHi, XPUSHn, XPUSHp,
+XPUSHs, XPUSHu, XS, XSRETURN, XSRETURN_EMPTY, XSRETURN_IV, XSRETURN_NO,
+XSRETURN_NV, XSRETURN_PV, XSRETURN_UNDEF, XSRETURN_YES, XST_mIV, XST_mNV,
+XST_mNO, XST_mPV, XST_mUNDEF, XST_mYES, XS_VERSION, XS_VERSION_BOOTCHECK,
+Zero
+
+=item AUTHORS
+
+=head2 perlcall - Perl calling conventions from C
+
+=item DESCRIPTION
+
+An Error Handler, An Event Driven Program
+
+=item THE PERL_CALL FUNCTIONS
+
+B<perl_call_sv>, B<perl_call_pv>, B<perl_call_method>, B<perl_call_argv>
+
+=item FLAG VALUES
+
+=over
+
+=item G_VOID
+
+=item G_SCALAR
+
+=item G_ARRAY
+
+=item G_DISCARD
+
+=item G_NOARGS
+
+=item G_EVAL
+
+=item G_KEEPERR
+
+=item Determining the Context
+
+=back
+
+=item KNOWN PROBLEMS
+
+=item EXAMPLES
+
+=over
+
+=item No Parameters, Nothing returned
+
+=item Passing Parameters
+
+=item Returning a Scalar
+
+=item Returning a list of values
+
+=item Returning a list in a scalar context
+
+=item Returning Data from Perl via the parameter list
+
+=item Using G_EVAL
+
+=item Using G_KEEPERR
+
+=item Using perl_call_sv
+
+=item Using perl_call_argv
+
+=item Using perl_call_method
+
+=item Using GIMME_V
+
+=item Using Perl to dispose of temporaries
+
+=item Strategies for storing Callback Context Information
+
+1. Ignore the problem - Allow only 1 callback, 2. Create a sequence of
+callbacks - hard wired limit, 3. Use a parameter to map to the Perl
+callback
+
+=item Alternate Stack Manipulation
+
+=item Creating and calling an anonymous subroutine in C
+
+=back
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=item DATE
+
+=head2 perlhist - the Perl history records
+
+=item DESCRIPTION
+
+=item INTRODUCTION
+
+=item THE KEEPERS OF THE PUMPKIN
+
+=over
+
+=item PUMPKIN?
+
+=back
+
+=item THE RECORDS
+
+=over
+
+=item SELECTED RELEASE SIZES
+
+=item SELECTED PATCH SIZES
+
+=back
+
+=item THE KEEPERS OF THE RECORDS
+
+=head1 PRAGMA DOCUMENTATION
+
+=head2 attrs - set/get attributes of a subroutine
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+method, locked
+
+=head2 re - Perl pragma to alter regular expression behaviour
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 autouse - postpone load of modules until a function is used
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item WARNING
+
+=item AUTHOR
+
+=item SEE ALSO
+
+=head2 base - Establish IS-A relationship with base class at compile time
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=head2 blib - Use MakeMaker's uninstalled version of a package
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 constant - Perl pragma to declare constants
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTES
+
+=item TECHNICAL NOTE
+
+=item BUGS
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 diagnostics - Perl compiler pragma to force verbose warning
+diagnostics
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item The C<diagnostics> Pragma
+
+=item The I<splain> Program
+
+=back
+
+=item EXAMPLES
+
+=item INTERNALS
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 fields - compile-time class fields
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=head2 integer - Perl pragma to compute arithmetic in integer instead of
+double
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 less - perl pragma to request less of something from the compiler
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 lib - manipulate @INC at compile time
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item ADDING DIRECTORIES TO @INC
+
+=item DELETING DIRECTORIES FROM @INC
+
+=item RESTORING ORIGINAL @INC
+
+=back
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 locale - Perl pragma to use and avoid POSIX locales for built-in
+operations
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 overload - Package for overloading perl operations
+
+=item SYNOPSIS
+
+=item CAVEAT SCRIPTOR
+
+=item DESCRIPTION
+
+=over
+
+=item Declaration of overloaded functions
+
+=item Calling Conventions for Binary Operations
+
+FALSE, TRUE, C<undef>
+
+=item Calling Conventions for Unary Operations
+
+=item Overloadable Operations
+
+I<Arithmetic operations>, I<Comparison operations>, I<Bit operations>,
+I<Increment and decrement>, I<Transcendental functions>, I<Boolean, string
+and numeric conversion>, I<Special>
+
+=item Inheritance and overloading
+
+Strings as values of C<use overload> directive, Overloading of an operation
+is inherited by derived classes
+
+=back
+
+=item SPECIAL SYMBOLS FOR C<use overload>
+
+=over
+
+=item Last Resort
+
+=item Fallback
+
+C<undef>, TRUE, defined, but FALSE
+
+=item Copy Constructor
+
+B<Example>
+
+=back
+
+=item MAGIC AUTOGENERATION
+
+I<Assignment forms of arithmetic operations>, I<Conversion operations>,
+I<Increment and decrement>, C<abs($a)>, I<Unary minus>, I<Negation>,
+I<Concatenation>, I<Comparison operations>, I<Copy operator>
+
+=item WARNING
+
+=item Run-time Overloading
+
+=item Public functions
+
+overload::StrVal(arg), overload::Overloaded(arg), overload::Method(obj,op)
+
+=item Overloading constants
+
+integer, float, binary, q, qr
+
+=item IMPLEMENTATION
+
+=item AUTHOR
+
+=item DIAGNOSTICS
+
+=item BUGS
+
+=head2 sigtrap - Perl pragma to enable simple signal handling
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+=over
+
+=item SIGNAL HANDLERS
+
+B<stack-trace>, B<die>, B<handler> I<your-handler>
+
+=item SIGNAL LISTS
+
+B<normal-signals>, B<error-signals>, B<old-interface-signals>
+
+=item OTHER
+
+B<untrapped>, B<any>, I<signal>, I<number>
+
+=back
+
+=item EXAMPLES
+
+=head2 strict - Perl pragma to restrict unsafe constructs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+C<strict refs>, C<strict vars>, C<strict subs>
+
+=head2 subs - Perl pragma to predeclare sub names
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 vars - Perl pragma to predeclare global variable names
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head1 MODULE DOCUMENTATION
+
+=head2 AnyDBM_File - provide framework for multiple DBMs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item DBM Comparisons
+
+[0], [1], [2], [3]
+
+=back
+
+=item SEE ALSO
+
+=head2 AutoLoader - load subroutines only on demand
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Subroutine Stubs
+
+=item Using B<AutoLoader>'s AUTOLOAD Subroutine
+
+=item Overriding B<AutoLoader>'s AUTOLOAD Subroutine
+
+=item Package Lexicals
+
+=item B<AutoLoader> vs. B<SelfLoader>
+
+=back
+
+=item CAVEATS
+
+=item SEE ALSO
+
+=head2 AutoSplit - split a package for autoloading
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+$keep, $check, $modtime
+
+=over
+
+=item Multiple packages
+
+=back
+
+=item DIAGNOSTICS
+
+=head2 B - The Perl Compiler
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OVERVIEW OF CLASSES
+
+=over
+
+=item SV-RELATED CLASSES
+
+=item B::SV METHODS
+
+REFCNT, FLAGS
+
+=item B::IV METHODS
+
+IV, IVX, needs64bits, packiv
+
+=item B::NV METHODS
+
+NV, NVX
+
+=item B::RV METHODS
+
+RV
+
+=item B::PV METHODS
+
+PV
+
+=item B::PVMG METHODS
+
+MAGIC, SvSTASH
+
+=item B::MAGIC METHODS
+
+MOREMAGIC, PRIVATE, TYPE, FLAGS, OBJ, PTR
+
+=item B::PVLV METHODS
+
+TARGOFF, TARGLEN, TYPE, TARG
+
+=item B::BM METHODS
+
+USEFUL, PREVIOUS, RARE, TABLE
+
+=item B::GV METHODS
+
+NAME, STASH, SV, IO, FORM, AV, HV, EGV, CV, CVGEN, LINE, FILEGV, GvREFCNT,
+FLAGS
+
+=item B::IO METHODS
+
+LINES, PAGE, PAGE_LEN, LINES_LEFT, TOP_NAME, TOP_GV, FMT_NAME, FMT_GV,
+BOTTOM_NAME, BOTTOM_GV, SUBPROCESS, IoTYPE, IoFLAGS
+
+=item B::AV METHODS
+
+FILL, MAX, OFF, ARRAY, AvFLAGS
+
+=item B::CV METHODS
+
+STASH, START, ROOT, GV, FILEGV, DEPTH, PADLIST, OUTSIDE, XSUB, XSUBANY
+
+=item B::HV METHODS
+
+FILL, MAX, KEYS, RITER, NAME, PMROOT, ARRAY
+
+=item OP-RELATED CLASSES
+
+=item B::OP METHODS
+
+next, sibling, ppaddr, desc, targ, type, seq, flags, private
+
+=item B::UNOP METHOD
+
+first
+
+=item B::BINOP METHOD
+
+last
+
+=item B::LOGOP METHOD
+
+other
+
+=item B::CONDOP METHODS
+
+true, false
+
+=item B::LISTOP METHOD
+
+children
+
+=item B::PMOP METHODS
+
+pmreplroot, pmreplstart, pmnext, pmregexp, pmflags, pmpermflags, precomp
+
+=item B::SVOP METHOD
+
+sv
+
+=item B::GVOP METHOD
+
+gv
+
+=item B::PVOP METHOD
+
+pv
+
+=item B::LOOP METHODS
+
+redoop, nextop, lastop
+
+=item B::COP METHODS
+
+label, stash, filegv, cop_seq, arybase, line
+
+=back
+
+=item FUNCTIONS EXPORTED BY C<B>
+
+main_cv, main_root, main_start, comppadlist, sv_undef, sv_yes, sv_no,
+walkoptree(OP, METHOD), walkoptree_debug(DEBUG), walksymtable(SYMREF,
+METHOD, RECURSE), svref_2object(SV), ppname(OPNUM), hash(STR), cast_I32(I),
+minus_c, cstring(STR), class(OBJ), threadsv_names, byteload_fh(FILEHANDLE)
+
+=item AUTHOR
+
+=head2 B::Asmdata - Autogenerated data about Perl ops, used to generate
+bytecode
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Assembler - Assemble Perl bytecode
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Bblock - Walk basic blocks
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Bytecode - Perl compiler's bytecode backend
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+B<-ofilename>, B<-->, B<-f>, B<-fcompress-nullops>,
+B<-fomit-sequence-numbers>, B<-fbypass-nullops>, B<-fstrip-syntax-tree>,
+B<-On>, B<-D>, B<-Do>, B<-Db>, B<-Da>, B<-DC>, B<-S>, B<-m>
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 B::C - Perl compiler's C backend
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+B<-ofilename>, B<-v>, B<-->, B<-uPackname>, B<-D>, B<-Do>, B<-Dc>, B<-DA>,
+B<-DC>, B<-DM>, B<-f>, B<-fcog>, B<-fno-cog>, B<-On>
+
+=item EXAMPLES
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 B::CC - Perl compiler's optimized C translation backend
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+B<-ofilename>, B<-v>, B<-->, B<-uPackname>, B<-mModulename>, B<-D>, B<-Dr>,
+B<-DO>, B<-Ds>, B<-Dp>, B<-Dq>, B<-Dl>, B<-Dt>, B<-f>,
+B<-ffreetmps-each-bblock>, B<-ffreetmps-each-loop>, B<-fomit-taint>, B<-On>
+
+=item EXAMPLES
+
+=item BUGS
+
+=item DIFFERENCES
+
+=over
+
+=item Loops
+
+=item Context of ".."
+
+=item Arithmetic
+
+=item Deprecated features
+
+=back
+
+=item AUTHOR
+
+=head2 B::Debug - Walk Perl syntax tree, printing debug info about ops
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Deparse - Perl compiler backend to produce perl code
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+B<-p>, B<-u>I<PACKAGE>, B<-l>, B<-s>I<LETTERS>, B<C>
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 B::Disassembler - Disassemble Perl bytecode
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Lint - Perl lint
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS AND LINT CHECKS
+
+B<context>, B<implicit-read> and B<implicit-write>, B<dollar-underscore>,
+B<private-names>, B<undefined-subs>, B<regexp-variables>, B<all>, B<none>
+
+=item NON LINT-CHECK OPTIONS
+
+B<-u Package>
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 B::O, O - Generic interface to Perl Compiler backends
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONVENTIONS
+
+=item IMPLEMENTATION
+
+=item AUTHOR
+
+=head2 B::Showlex - Show lexical variables used in functions or files
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Stackobj - Helper module for CC backend
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Terse - Walk Perl syntax tree, printing terse info about ops
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 B::Xref - Generates cross reference reports for Perl programs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPTIONS
+
+C<-oFILENAME>, C<-r>, C<-D[tO]>
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Benchmark - benchmark running times of code
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Methods
+
+new, debug
+
+=item Standard Exports
+
+timeit(COUNT, CODE), timethis ( COUNT, CODE, [ TITLE, [ STYLE ]] ),
+timethese ( COUNT, CODEHASHREF, [ STYLE ] ), timediff ( T1, T2 ), timestr (
+TIMEDIFF, [ STYLE, [ FORMAT ] ] )
+
+=item Optional Exports
+
+clearcache ( COUNT ), clearallcache ( ), disablecache ( ), enablecache ( )
+
+=back
+
+=item NOTES
+
+=item INHERITANCE
+
+=item CAVEATS
+
+=item AUTHORS
+
+=item MODIFICATION HISTORY
+
+=head2 CGI - Simple Common Gateway Interface Class
+
+=item SYNOPSIS
+
+=item ABSTRACT
+
+=item DESCRIPTION
+
+=over
+
+=item PROGRAMMING STYLE
+
+=item CALLING CGI.PM ROUTINES
+
+1. Use another name for the argument, if one is available. Forexample,
+-value is an alias for -values, 2. Change the capitalization, e.g. -Values,
+3. Put quotes around the argument name, e.g. '-values'
+
+=item CREATING A NEW QUERY OBJECT (OBJECT-ORIENTED STYLE):
+
+=item CREATING A NEW QUERY OBJECT FROM AN INPUT FILE
+
+=item FETCHING A LIST OF KEYWORDS FROM THE QUERY:
+
+=item FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR SCRIPT:
+
+=item FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER:
+
+=item SETTING THE VALUE(S) OF A NAMED PARAMETER:
+
+=item APPENDING ADDITIONAL VALUES TO A NAMED PARAMETER:
+
+=item IMPORTING ALL PARAMETERS INTO A NAMESPACE:
+
+=item DELETING A PARAMETER COMPLETELY:
+
+=item DELETING ALL PARAMETERS:
+
+=item DIRECT ACCESS TO THE PARAMETER LIST:
+
+=item SAVING THE STATE OF THE SCRIPT TO A FILE:
+
+=item USING THE FUNCTION-ORIENTED INTERFACE
+
+B<:cgi>, B<:form>, B<:html2>, B<:html3>, B<:netscape>, B<:html>,
+B<:standard>, B<:all>
+
+=item PRAGMAS
+
+-any, -compile, -nph, -autoload, -no_debug, -private_tempfiles
+
+=back
+
+=item GENERATING DYNAMIC DOCUMENTS
+
+=over
+
+=item CREATING A STANDARD HTTP HEADER:
+
+=item GENERATING A REDIRECTION HEADER
+
+=item CREATING THE HTML DOCUMENT HEADER
+
+B<Parameters:>, 4, 5, 6..
+
+=item ENDING THE HTML DOCUMENT:
+
+=item CREATING A SELF-REFERENCING URL THAT PRESERVES STATE INFORMATION:
+
+=item OBTAINING THE SCRIPT'S URL
+
+B<-absolute>, B<-relative>, B<-full>, B<-path> (B<-path_info>), B<-query>
+(B<-query_string>)
+
+=back
+
+=item CREATING STANDARD HTML ELEMENTS:
+
+=over
+
+=item PROVIDING ARGUMENTS TO HTML SHORTCUTS
+
+=item THE DISTRIBUTIVE PROPERTY OF HTML SHORTCUTS
+
+=item HTML SHORTCUTS AND LIST INTERPOLATION
+
+=item NON-STANDARD HTML SHORTCUTS
+
+=back
+
+=item CREATING FILL-OUT FORMS:
+
+=over
+
+=item CREATING AN ISINDEX TAG
+
+=item STARTING AND ENDING A FORM
+
+B<application/x-www-form-urlencoded>, B<multipart/form-data>
+
+=item CREATING A TEXT FIELD
+
+B<Parameters>
+
+=item CREATING A BIG TEXT FIELD
+
+=item CREATING A PASSWORD FIELD
+
+=item CREATING A FILE UPLOAD FIELD
+
+B<Parameters>
+
+=item CREATING A POPUP MENU
+
+=item CREATING A SCROLLING LIST
+
+B<Parameters:>
+
+=item CREATING A GROUP OF RELATED CHECKBOXES
+
+B<Parameters:>
+
+=item CREATING A STANDALONE CHECKBOX
+
+B<Parameters:>
+
+=item CREATING A RADIO BUTTON GROUP
+
+B<Parameters:>
+
+=item CREATING A SUBMIT BUTTON
+
+B<Parameters:>
+
+=item CREATING A RESET BUTTON
+
+=item CREATING A DEFAULT BUTTON
+
+=item CREATING A HIDDEN FIELD
+
+B<Parameters:>
+
+=item CREATING A CLICKABLE IMAGE BUTTON
+
+B<Parameters:>, 3.The third option (-align, optional) is an alignment type,
+and may be
+TOP, BOTTOM or MIDDLE
+
+=item CREATING A JAVASCRIPT ACTION BUTTON
+
+=back
+
+=item NETSCAPE COOKIES
+
+1. an expiration time, 2. a domain, 3. a path, 4. a "secure" flag,
+B<-name>, B<-value>, B<-path>, B<-domain>, B<-expires>, B<-secure>
+
+=item WORKING WITH NETSCAPE FRAMES
+
+1. Create a <Frameset> document, 2. Specify the destination for the
+document in the HTTP header, 3. Specify the destination for the document in
+the <FORM> tag
+
+=item LIMITED SUPPORT FOR CASCADING STYLE SHEETS
+
+=item DEBUGGING
+
+=over
+
+=item DUMPING OUT ALL THE NAME/VALUE PAIRS
+
+=back
+
+=item FETCHING ENVIRONMENT VARIABLES
+
+B<accept()>, B<raw_cookie()>, B<user_agent()>, B<path_info()>,
+B<path_translated()>, B<remote_host()>, B<script_name()>Return the script
+name as a partial URL, for self-refering
+scripts, B<referer()>, B<auth_type ()>, B<server_name ()>, B<virtual_host
+()>, B<server_software ()>, B<remote_user ()>, B<user_name ()>,
+B<request_method()>
+
+=item USING NPH SCRIPTS
+
+In the B<use> statement, By calling the B<nph()> method:, By using B<-nph>
+parameters in the B<header()> and B<redirect()> statements:
+
+=item Server Push
+
+multipart_init()
+multipart_init(-boundary=>$boundary);, multipart_start(), multipart_end()
+
+=item Avoiding Denial of Service Attacks
+
+B<$CGI::POST_MAX>, B<$CGI::DISABLE_UPLOADS>, B<1. On a script-by-script
+basis>, B<2. Globally for all scripts>
+
+=item COMPATIBILITY WITH CGI-LIB.PL
+
+=item AUTHOR INFORMATION
+
+=item CREDITS
+
+Matt Heffron (heffron@falstaff.css.beckman.com), James Taylor
+(james.taylor@srs.gov), Scott Anguish <sanguish@digifix.com>, Mike Jewell
+(mlj3u@virginia.edu), Timothy Shimmin (tes@kbs.citri.edu.au), Joergen Haegg
+(jh@axis.se), Laurent Delfosse (delfosse@csgrad1.cs.wvu.edu), Richard
+Resnick (applepi1@aol.com), Craig Bishop (csb@barwonwater.vic.gov.au), Tony
+Curtis (tc@vcpc.univie.ac.at), Tim Bunce (Tim.Bunce@ig.co.uk), Tom
+Christiansen (tchrist@convex.com), Andreas Koenig
+(k@franz.ww.TU-Berlin.DE), Tim MacKenzie (Tim.MacKenzie@fulcrum.com.au),
+Kevin B. Hendricks (kbhend@dogwood.tyler.wm.edu), Stephen Dahmen
+(joyfire@inxpress.net), Ed Jordan (ed@fidalgo.net), David Alan Pisoni
+(david@cnation.com), Doug MacEachern (dougm@opengroup.org), Robin Houston
+(robin@oneworld.org), ...and many many more..
+
+=item A COMPLETE EXAMPLE OF A SIMPLE FORM-BASED SCRIPT
+
+=item BUGS
+
+=item SEE ALSO
+
+=head2 CGI::Apache - Make things work with CGI.pm against Perl-Apache API
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE 1
+
+=item NOTE 2
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 CGI::Carp, B<CGI::Carp> - CGI routines for writing to the HTTPD (or
+other) error log
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item REDIRECTING ERROR MESSAGES
+
+=item MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW
+
+=over
+
+=item Changing the default message
+
+=back
+
+=item CHANGE LOG
+
+=item AUTHORS
+
+=item SEE ALSO
+
+=head2 CGI::Cookie - Interface to Netscape Cookies
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item USING CGI::Cookie
+
+B<1. expiration date>, B<2. domain>, B<3. path>, B<4. secure flag>
+
+=over
+
+=item Creating New Cookies
+
+=item Sending the Cookie to the Browser
+
+=item Recovering Previous Cookies
+
+=item Manipulating Cookies
+
+B<name()>, B<value()>, B<domain()>, B<path()>, B<expires()>
+
+=back
+
+=item AUTHOR INFORMATION
+
+=item BUGS
+
+=item SEE ALSO
+
+=head2 CGI::Fast - CGI Interface for Fast CGI
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OTHER PIECES OF THE PUZZLE
+
+=item WRITING FASTCGI PERL SCRIPTS
+
+=item INSTALLING FASTCGI SCRIPTS
+
+=item USING FASTCGI SCRIPTS AS CGI SCRIPTS
+
+=item CAVEATS
+
+=item AUTHOR INFORMATION
+
+=item BUGS
+
+=item SEE ALSO
+
+=head2 CGI::Push - Simple Interface to Server Push
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item USING CGI::Push
+
+-next_page, -last_page, -type, -delay, -cookie, -target, -expires
+
+=over
+
+=item Heterogeneous Pages
+
+=item Changing the Page Delay on the Fly
+
+=back
+
+=item INSTALLING CGI::Push SCRIPTS
+
+=item CAVEATS
+
+=item AUTHOR INFORMATION
+
+=item BUGS
+
+=item SEE ALSO
+
+=head2 CGI::Switch - Try more than one constructors and return the first
+object available
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 CPAN - query, download and build perl modules from CPAN sites
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Interactive Mode
+
+Searching for authors, bundles, distribution files and modules, make, test,
+install, clean modules or distributions, readme, look module or
+distribution, Signals
+
+=item CPAN::Shell
+
+=item autobundle
+
+=item recompile
+
+=item The four C<CPAN::*> Classes: Author, Bundle, Module, Distribution
+
+=item ProgrammerE<39>s interface
+
+expand($type,@things), Programming Examples
+
+=item Methods in the four
+
+=item Cache Manager
+
+=item Bundles
+
+=item Prerequisites
+
+=item Finding packages and VERSION
+
+=item Debugging
+
+=item Floppy, Zip, and all that Jazz
+
+=back
+
+=item CONFIGURATION
+
+o conf E<lt>scalar optionE<gt>, o conf E<lt>scalar optionE<gt>
+E<lt>valueE<gt>, o conf E<lt>list optionE<gt>, o conf E<lt>list optionE<gt>
+[shift|pop], o conf E<lt>list optionE<gt> [unshift|push|splice]
+E<lt>listE<gt>
+
+=over
+
+=item CD-ROM support
+
+=back
+
+=item SECURITY
+
+=item EXPORT
+
+=item BUGS
+
+=item AUTHOR
+
+=item SEE ALSO
+
+=head2 CPAN::FirstTime - Utility for CPAN::Config file Initialization
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 CPANox, CPAN::Nox - Wrapper around CPAN.pm without using any XS
+module
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=head2 Carp, carp - warn of errors (from perspective of caller)
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Forcing a Stack Trace
+
+=back
+
+=head2 Class::Struct - declare struct-like datatypes as Perl classes
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item The C<struct()> function
+
+=item Element Types and Accessor Methods
+
+Scalar (C<'$'> or C<'*$'>), Array (C<'@'> or C<'*@'>), Hash (C<'%'> or
+C<'*%'>), Class (C<'Class_Name'> or C<'*Class_Name'>)
+
+=back
+
+=item EXAMPLES
+
+Example 1, Example 2
+
+=item Author and Modification History
+
+=head2 Cwd, getcwd - get pathname of current working directory
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 DB_File - Perl5 access to Berkeley DB version 1.x
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+B<DB_HASH>, B<DB_BTREE>, B<DB_RECNO>
+
+=over
+
+=item Using DB_File with Berkeley DB version 2
+
+=item Interface to Berkeley DB
+
+=item Opening a Berkeley DB Database File
+
+=item Default Parameters
+
+=item In Memory Databases
+
+=back
+
+=item DB_HASH
+
+=over
+
+=item A Simple Example
+
+=back
+
+=item DB_BTREE
+
+=over
+
+=item Changing the BTREE sort order
+
+=item Handling Duplicate Keys
+
+=item The get_dup() Method
+
+=item Matching Partial Keys
+
+=back
+
+=item DB_RECNO
+
+=over
+
+=item The 'bval' Option
+
+=item A Simple Example
+
+=item Extra Methods
+
+B<$X-E<gt>push(list) ;>, B<$value = $X-E<gt>pop ;>, B<$X-E<gt>shift>,
+B<$X-E<gt>unshift(list) ;>, B<$X-E<gt>length>
+
+=item Another Example
+
+=back
+
+=item THE API INTERFACE
+
+B<$status = $X-E<gt>get($key, $value [, $flags]) ;>, B<$status =
+$X-E<gt>put($key, $value [, $flags]) ;>, B<$status = $X-E<gt>del($key [,
+$flags]) ;>, B<$status = $X-E<gt>fd ;>, B<$status = $X-E<gt>seq($key,
+$value, $flags) ;>, B<$status = $X-E<gt>sync([$flags]) ;>
+
+=item HINTS AND TIPS
+
+=over
+
+=item Locking Databases
+
+=item Sharing Databases With C Applications
+
+=item The untie() Gotcha
+
+=back
+
+=item COMMON QUESTIONS
+
+=over
+
+=item Why is there Perl source in my database?
+
+=item How do I store complex data structures with DB_File?
+
+=item What does "Invalid Argument" mean?
+
+=item What does "Bareword 'DB_File' not allowed" mean?
+
+=back
+
+=item HISTORY
+
+=item BUGS
+
+=item AVAILABILITY
+
+=item COPYRIGHT
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 Data::Dumper - stringified perl data structures, suitable for both
+printing and C<eval>
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Methods
+
+I<PACKAGE>->new(I<ARRAYREF [>, I<ARRAYREF]>), I<$OBJ>->Dump I<or>
+I<PACKAGE>->Dump(I<ARRAYREF [>, I<ARRAYREF]>), I<$OBJ>->Dumpxs I<or>
+I<PACKAGE>->Dumpxs(I<ARRAYREF [>, I<ARRAYREF]>),
+I<$OBJ>->Seen(I<[HASHREF]>), I<$OBJ>->Values(I<[ARRAYREF]>),
+I<$OBJ>->Names(I<[ARRAYREF]>), I<$OBJ>->Reset
+
+=item Functions
+
+Dumper(I<LIST>), DumperX(I<LIST>)
+
+=item Configuration Variables or Methods
+
+$Data::Dumper::Indent I<or> I<$OBJ>->Indent(I<[NEWVAL]>),
+$Data::Dumper::Purity I<or> I<$OBJ>->Purity(I<[NEWVAL]>),
+$Data::Dumper::Pad I<or> I<$OBJ>->Pad(I<[NEWVAL]>),
+$Data::Dumper::Varname I<or> I<$OBJ>->Varname(I<[NEWVAL]>),
+$Data::Dumper::Useqq I<or> I<$OBJ>->Useqq(I<[NEWVAL]>),
+$Data::Dumper::Terse I<or> I<$OBJ>->Terse(I<[NEWVAL]>),
+$Data::Dumper::Freezer I<or> $I<OBJ>->Freezer(I<[NEWVAL]>),
+$Data::Dumper::Toaster I<or> $I<OBJ>->Toaster(I<[NEWVAL]>),
+$Data::Dumper::Deepcopy I<or> $I<OBJ>->Deepcopy(I<[NEWVAL]>),
+$Data::Dumper::Quotekeys I<or> $I<OBJ>->Quotekeys(I<[NEWVAL]>),
+$Data::Dumper::Bless I<or> $I<OBJ>->Bless(I<[NEWVAL]>)
+
+=item Exports
+
+Dumper
+
+=back
+
+=item EXAMPLES
+
+=item BUGS
+
+=item AUTHOR
+
+=item VERSION
+
+=item SEE ALSO
+
+=head2 Devel::SelfStubber - generate stubs for a SelfLoading module
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 DirHandle - supply object methods for directory handles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 English - use nice English (or awk) names for ugly punctuation
+variables
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Env - perl module that imports environment variables
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 Exporter - Implements default import method for modules
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Selecting What To Export
+
+=item Specialised Import Lists
+
+=item Exporting without using Export's import method
+
+=item Module Version Checking
+
+=item Managing Unknown Symbols
+
+=item Tag Handling Utility Functions
+
+=back
+
+=head2 ExtUtils::Command - utilities to replace common UNIX commands in
+Makefiles etc.
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+cat, eqtime src dst, rm_f files..., rm_f files..., touch files .., mv
+source... destination, cp source... destination, chmod mode files.., mkpath
+directory.., test_f file
+
+=item BUGS
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item @EXPORT
+
+=item FUNCTIONS
+
+xsinit(), Examples, ldopts(), Examples, perl_inc(), ccflags(), ccdlflags(),
+ccopts(), xsi_header(), xsi_protos(@modules), xsi_body(@modules)
+
+=item EXAMPLES
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 ExtUtils::Install - install files from here to there
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 ExtUtils::Installed - Inventory management of installed modules
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item USAGE
+
+=item FUNCTIONS
+
+new(), modules(), files(), directories(), directory_tree(), validate(),
+packlist(), version()
+
+=item EXAMPLE
+
+=item AUTHOR
+
+=head2 ExtUtils::Liblist - determine libraries to use and how to use them
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+For static extensions, For dynamic extensions, For dynamic extensions
+
+=over
+
+=item EXTRALIBS
+
+=item LDLOADLIBS and LD_RUN_PATH
+
+=item BSLOADLIBS
+
+=back
+
+=item PORTABILITY
+
+=over
+
+=item VMS implementation
+
+=item Win32 implementation
+
+=back
+
+=item SEE ALSO
+
+=head2 ExtUtils::MM_OS2 - methods to override UN*X behaviour in
+ExtUtils::MakeMaker
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item METHODS
+
+=over
+
+=item Preloaded methods
+
+canonpath, catdir, catfile, curdir, rootdir, updir
+
+=item SelfLoaded methods
+
+c_o (o), cflags (o), clean (o), const_cccmd (o), const_config (o),
+const_loadlibs (o), constants (o), depend (o), dir_target (o), dist (o),
+dist_basics (o), dist_ci (o), dist_core (o), dist_dir (o), dist_test (o),
+dlsyms (o), dynamic (o), dynamic_bs (o), dynamic_lib (o), exescan,
+extliblist, file_name_is_absolute, find_perl
+
+=item Methods to actually produce chunks of text for the Makefile
+
+fixin, force (o), guess_name, has_link_code, init_dirscan, init_main,
+init_others, install (o), installbin (o), libscan (o), linkext (o), lsdir,
+macro (o), makeaperl (o), makefile (o), manifypods (o), maybe_command,
+maybe_command_in_dirs, needs_linking (o), nicetext, parse_version,
+parse_abstract, pasthru (o), path, perl_script, perldepend (o), ppd,
+perm_rw (o), perm_rwx (o), pm_to_blib, post_constants (o), post_initialize
+(o), postamble (o), prefixify, processPL (o), realclean (o),
+replace_manpage_separator, static (o), static_lib (o), staticmake (o),
+subdir_x (o), subdirs (o), test (o), test_via_harness (o), test_via_script
+(o), tool_autosplit (o), tools_other (o), tool_xsubpp (o), top_targets (o),
+writedoc, xs_c (o), xs_o (o), perl_archive, export_list
+
+=back
+
+=item SEE ALSO
+
+=head2 ExtUtils::MM_VMS - methods to override UN*X behaviour in
+ExtUtils::MakeMaker
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Methods always loaded
+
+eliminate_macros, fixpath, catdir, catfile, wraplist, curdir (override),
+rootdir (override), updir (override)
+
+=item SelfLoaded methods
+
+guess_name (override), find_perl (override), path (override), maybe_command
+(override), maybe_command_in_dirs (override), perl_script (override),
+file_name_is_absolute (override), replace_manpage_separator, init_others
+(override), constants (override), cflags (override), const_cccmd
+(override), pm_to_blib (override), tool_autosplit (override), tool_sxubpp
+(override), xsubpp_version (override), tools_other (override), dist
+(override), c_o (override), xs_c (override), xs_o (override), top_targets
+(override), dlsyms (override), dynamic_lib (override), dynamic_bs
+(override), static_lib (override), manifypods (override), processPL
+(override), installbin (override), subdir_x (override), clean (override),
+realclean (override), dist_basics (override), dist_core (override),
+dist_dir (override), dist_test (override), install (override), perldepend
+(override), makefile (override), test (override), test_via_harness
+(override), test_via_script (override), makeaperl (override), nicetext
+(override)
+
+=back
+
+=head2 ExtUtils::MM_Win32 - methods to override UN*X behaviour in
+ExtUtils::MakeMaker
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+catfile, constants (o), static_lib (o), dynamic_bs (o), dynamic_lib (o),
+canonpath, perl_script, pm_to_blib, test_via_harness (o), tool_autosplit
+(override), tools_other (o), xs_o (o), top_targets (o), manifypods (o),
+dist_ci (o), dist_core (o), pasthru (o)
+
+=head2 ExtUtils::MakeMaker - create an extension Makefile
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item How To Write A Makefile.PL
+
+=item Default Makefile Behaviour
+
+=item make test
+
+=item make testdb
+
+=item make install
+
+=item PREFIX and LIB attribute
+
+=item AFS users
+
+=item Static Linking of a new Perl Binary
+
+=item Determination of Perl Library and Installation Locations
+
+=item Which architecture dependent directory?
+
+=item Using Attributes and Parameters
+
+C, CCFLAGS, CONFIG, CONFIGURE, DEFINE, DIR, DISTNAME, DL_FUNCS, DL_VARS,
+EXCLUDE_EXT, EXE_FILES, NO_VC, FIRST_MAKEFILE, FULLPERL, H, IMPORTS, INC,
+INCLUDE_EXT, INSTALLARCHLIB, INSTALLBIN, INSTALLDIRS, INSTALLMAN1DIR,
+INSTALLMAN3DIR, INSTALLPRIVLIB, INSTALLSCRIPT, INSTALLSITELIB,
+INSTALLSITEARCH, INST_ARCHLIB, INST_BIN, INST_EXE, INST_LIB, INST_MAN1DIR,
+INST_MAN3DIR, INST_SCRIPT, LDFROM, LIBPERL_A, LIB, LIBS, LINKTYPE,
+MAKEAPERL, MAKEFILE, MAN1PODS, MAN3PODS, MAP_TARGET, MYEXTLIB, NAME,
+NEEDS_LINKING, NOECHO, NORECURS, OBJECT, OPTIMIZE, PERL, PERLMAINCC,
+PERL_ARCHLIB, PERL_LIB, PERL_SRC, PERM_RW, PERM_RWX, PL_FILES, PM,
+PMLIBDIRS, PREFIX, PREREQ_PM, SKIP, TYPEMAPS, VERSION, VERSION_FROM, XS,
+XSOPT, XSPROTOARG, XS_VERSION
+
+=item Additional lowercase attributes
+
+clean, depend, dist, dynamic_lib, installpm, linkext, macro, realclean,
+tool_autosplit
+
+=item Overriding MakeMaker Methods
+
+=item Hintsfile support
+
+=item Distribution Support
+
+make distcheck, make skipcheck, make distclean, make manifest,
+make distdir, make tardist, make dist, make uutardist, make
+shdist, make zipdist, make ci
+
+=item Disabling an extension
+
+=back
+
+=item SEE ALSO
+
+=item AUTHORS
+
+=head2 ExtUtils::Manifest - utilities to write and check a MANIFEST file
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item MANIFEST.SKIP
+
+=item EXPORT_OK
+
+=item GLOBAL VARIABLES
+
+=item DIAGNOSTICS
+
+C<Not in MANIFEST:> I<file>, C<No such file:> I<file>, C<MANIFEST:> I<$!>,
+C<Added to MANIFEST:> I<file>
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 ExtUtils::Mkbootstrap - make a bootstrap file for use by DynaLoader
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 ExtUtils::Mksymlists - write linker options files for dynamic
+extension
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+NAME, DL_FUNCS, DL_VARS, FILE, FUNCLIST, DLBASE
+
+=item AUTHOR
+
+=item REVISION
+
+=head2 ExtUtils::Packlist - manage .packlist files
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item USAGE
+
+=item FUNCTIONS
+
+new(), read(), write(), validate(), packlist_file()
+
+=item EXAMPLE
+
+=item AUTHOR
+
+=head2 ExtUtils::testlib - add blib/* directories to @INC
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Fatal - replace functions with equivalents which succeed or die
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 Fcntl - load the C Fcntl.h defines
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item EXPORTED SYMBOLS
+
+=head2 File::Basename, fileparse - split a pathname into pieces
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+fileparse_set_fstype, fileparse
+
+=item EXAMPLES
+
+C<basename>, C<dirname>
+
+=head2 File::CheckTree, validate - run many filetest checks on a tree
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 File::Compare - Compare files or filehandles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item RETURN
+
+=item AUTHOR
+
+=head2 File::Copy - Copy files or filehandles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Special behavior if C<syscopy> is defined (VMS and OS/2)
+
+rmscopy($from,$to[,$date_flag])
+
+=back
+
+=item RETURN
+
+=item AUTHOR
+
+=head2 File::DosGlob - DOS like globbing and then some
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXPORTS (by request only)
+
+=item BUGS
+
+=item AUTHOR
+
+=item HISTORY
+
+=item SEE ALSO
+
+=head2 File::Find, find - traverse a file tree
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item BUGS
+
+=head2 File::Path - create or remove a series of directories
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHORS
+
+=item REVISION
+
+=head2 File::Spec - portably perform operations on file names
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=item AUTHORS
+
+=head2 File::Spec::Mac - File::Spec for MacOS
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item METHODS
+
+canonpath, catdir, catfile, curdir, rootdir, updir, file_name_is_absolute,
+path
+
+=item SEE ALSO
+
+=head2 File::Spec::OS2 - methods for OS/2 file specs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 File::Spec::Unix - methods used by File::Spec
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item METHODS
+
+canonpath, catdir, catfile, curdir, rootdir, updir, no_upwards,
+file_name_is_absolute, path, join, nativename
+
+=item SEE ALSO
+
+=head2 File::Spec::VMS - methods for VMS file specs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Methods always loaded
+
+catdir, catfile, curdir (override), rootdir (override), updir (override),
+path (override), file_name_is_absolute (override)
+
+=back
+
+=head2 File::Spec::Win32 - methods for Win32 file specs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+catfile, canonpath
+
+=head2 File::stat - by-name interface to Perl's built-in stat() functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 FileCache - keep more files open than the system permits
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item BUGS
+
+=head2 FileHandle - supply object methods for filehandles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+$fh->print, $fh->printf, $fh->getline, $fh->getlines
+
+=item SEE ALSO
+
+=head2 FindBin - Locate directory of original perl script
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXPORTABLE VARIABLES
+
+=item KNOWN BUGS
+
+=item AUTHORS
+
+=item COPYRIGHT
+
+=item REVISION
+
+=head2 GDBM_File - Perl5 access to the gdbm library.
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AVAILABILITY
+
+=item BUGS
+
+=item SEE ALSO
+
+=head2 Getopt::Long, GetOptions - extended processing of command line
+options
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+!, +, :s, :i, :f
+
+=over
+
+=item Linkage specification
+
+=item Aliases and abbreviations
+
+=item Non-option call-back routine
+
+=item Option starters
+
+=item Return values and Errors
+
+=back
+
+=item COMPATIBILITY
+
+=item EXAMPLES
+
+=item CONFIGURATION OPTIONS
+
+default, auto_abbrev, getopt_compat, require_order, permute, bundling
+(default: reset), bundling_override (default: reset), ignore_case
+(default: set), ignore_case_always (default: reset), pass_through (default:
+reset), prefix, prefix_pattern, debug (default: reset)
+
+=item OTHER USEFUL VARIABLES
+
+$Getopt::Long::VERSION, $Getopt::Long::error
+
+=item AUTHOR
+
+=item COPYRIGHT AND DISCLAIMER
+
+=head2 Getopt::Std, getopt - Process single-character switches with switch
+clustering
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 I18N::Collate - compare 8-bit scalar data according to the current
+locale
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 IO - load various IO modules
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 IO::lib::IO::File, IO::File - supply object methods for filehandles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONSTRUCTOR
+
+new ([ ARGS ] ), new_tmpfile
+
+=item METHODS
+
+open( FILENAME [,MODE [,PERMS]] )
+
+=item SEE ALSO
+
+=item HISTORY
+
+=head2 IO::lib::IO::Handle, IO::Handle - supply object methods for I/O
+handles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONSTRUCTOR
+
+new (), new_from_fd ( FD, MODE )
+
+=item METHODS
+
+$fh->fdopen ( FD, MODE ), $fh->opened, $fh->getline, $fh->getlines,
+$fh->ungetc ( ORD ), $fh->write ( BUF, LEN [, OFFSET }\] ), $fh->flush,
+$fh->error, $fh->clearerr, $fh->untaint
+
+=item NOTE
+
+=item SEE ALSO
+
+=item BUGS
+
+=item HISTORY
+
+=head2 IO::lib::IO::Pipe, IO::pipe - supply object methods for pipes
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONSTRCUTOR
+
+new ( [READER, WRITER] )
+
+=item METHODS
+
+reader ([ARGS]), writer ([ARGS]), handles ()
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 IO::lib::IO::Seekable, IO::Seekable - supply seek based methods for
+I/O objects
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=item HISTORY
+
+=head2 IO::lib::IO::Select, IO::Select - OO interface to the select system
+call
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONSTRUCTOR
+
+new ( [ HANDLES ] )
+
+=item METHODS
+
+add ( HANDLES ), remove ( HANDLES ), exists ( HANDLE ), handles, can_read (
+[ TIMEOUT ] ), can_write ( [ TIMEOUT ] ), has_error ( [ TIMEOUT ] ), count
+(), bits(), bits(), select ( READ, WRITE, ERROR [, TIMEOUT ] )
+
+=item EXAMPLE
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 IO::lib::IO::Socket, IO::Socket - Object interface to socket
+communications
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CONSTRUCTOR
+
+new ( [ARGS] )
+
+=item METHODS
+
+accept([PKG]), timeout([VAL]), sockopt(OPT [, VAL]), sockdomain, socktype,
+protocol
+
+=item SUB-CLASSES
+
+=over
+
+=item IO::Socket::INET
+
+=item METHODS
+
+sockaddr (), sockport (), sockhost (), peeraddr (), peerport (), peerhost
+()
+
+=item IO::Socket::UNIX
+
+=item METHODS
+
+hostpath(), peerpath()
+
+=back
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 IPC::Open2, open2 - open a process for both reading and writing
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item WARNING
+
+=item SEE ALSO
+
+=head2 IPC::Open3, open3 - open a process for reading, writing, and error
+handling
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item WARNING
+
+=head2 IPC::SysV - SysV IPC constants
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+ftok( PATH, ID )
+
+=item SEE ALSO
+
+=item AUTHORS
+
+=item COPYRIGHT
+
+=head2 IPC::SysV::Msg, IPC::Msg - SysV Msg IPC object class
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item METHODS
+
+new ( KEY , FLAGS ), id, rcv ( BUF, LEN [, TYPE [, FLAGS ]] ), remove, set
+( STAT ), set ( NAME => VALUE [, NAME => VALUE ...] ), snd ( TYPE, MSG [,
+FLAGS ] ), stat
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 IPC::SysV::Semaphore, IPC::Semaphore - SysV Semaphore IPC object
+class
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item METHODS
+
+new ( KEY , NSEMS , FLAGS ), getall, getncnt ( SEM ), getpid ( SEM ),
+getval ( SEM ), getzcnt ( SEM ), id, op ( OPLIST ), remove, set ( STAT ),
+set ( NAME => VALUE [, NAME => VALUE ...] ), setall ( VALUES ), setval ( N
+, VALUE ), stat
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=item COPYRIGHT
+
+=head2 Math::BigFloat - Arbitrary length float math package
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+number format, Error returns 'NaN', Division is computed to
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Math::BigInt - Arbitrary size integer math package
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+Canonical notation, Input, Output
+
+=item EXAMPLES
+
+=item Autocreating constants
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Math::Complex - complex numbers and associated mathematical
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item OPERATIONS
+
+=item CREATION
+
+=item STRINGIFICATION
+
+=item USAGE
+
+=item ERRORS DUE TO DIVISION BY ZERO OR LOGARITHM OF ZERO
+
+=item ERRORS DUE TO INDIGESTIBLE ARGUMENTS
+
+=item BUGS
+
+=item AUTHORS
+
+=head2 Math::Trig - trigonometric functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item TRIGONOMETRIC FUNCTIONS
+
+B<tan>
+
+=over
+
+=item ERRORS DUE TO DIVISION BY ZERO
+
+=item SIMPLE (REAL) ARGUMENTS, COMPLEX RESULTS
+
+=back
+
+=item PLANE ANGLE CONVERSIONS
+
+=item RADIAL COORDINATE CONVERSIONS
+
+=over
+
+=item COORDINATE SYSTEMS
+
+=item 3-D ANGLE CONVERSIONS
+
+cartesian_to_cylindrical, cartesian_to_spherical, cylindrical_to_cartesian,
+cylindrical_to_spherical, spherical_to_cartesian, spherical_to_cylindrical
+
+=back
+
+=item GREAT CIRCLE DISTANCES
+
+=item EXAMPLES
+
+=item BUGS
+
+=item AUTHORS
+
+=head2 NDBM_File - Tied access to ndbm files
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Net::Ping - check a remote host for reachability
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item Functions
+
+Net::Ping->new([$proto [, $def_timeout [, $bytes]]]);, $p->ping($host [,
+$timeout]);, $p->close();, pingecho($host [, $timeout]);
+
+=back
+
+=item WARNING
+
+=item NOTES
+
+=head2 Net::hostent - by-name interface to Perl's built-in gethost*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 Net::netent - by-name interface to Perl's built-in getnet*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 Net::protoent - by-name interface to Perl's built-in getproto*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 Net::servent - by-name interface to Perl's built-in getserv*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 ODBM_File - Tied access to odbm files
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Opcode - Disable named opcodes when compiling perl code
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item WARNING
+
+=item Operator Names and Operator Lists
+
+an operator name (opname), an operator tag name (optag), a negated opname
+or optag, an operator set (opset)
+
+=item Opcode Functions
+
+opcodes, opset (OP, ...), opset_to_ops (OPSET), opset_to_hex (OPSET),
+full_opset, empty_opset, invert_opset (OPSET), verify_opset (OPSET, ...),
+define_optag (OPTAG, OPSET), opmask_add (OPSET), opmask, opdesc (OP, ...),
+opdump (PAT)
+
+=item Manipulating Opsets
+
+=item TO DO (maybe)
+
+=item Predefined Opcode Tags
+
+:base_core, :base_mem, :base_loop, :base_io, :base_orig, :base_math,
+:base_thread, :default, :filesys_read, :sys_db, :browse, :filesys_open,
+:filesys_write, :subprocess, :ownprocess, :others, :still_to_be_decided,
+:dangerous
+
+=item SEE ALSO
+
+=item AUTHORS
+
+=head2 Opcode::Safe, Safe - Compile and execute code in restricted
+compartments
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+a new namespace, an operator mask
+
+=item WARNING
+
+=over
+
+=item RECENT CHANGES
+
+=item Methods in class Safe
+
+permit (OP, ...), permit_only (OP, ...), deny (OP, ...), deny_only (OP,
+...), trap (OP, ...), untrap (OP, ...), share (NAME, ...), share_from
+(PACKAGE, ARRAYREF), varglob (VARNAME), reval (STRING), rdo (FILENAME),
+root (NAMESPACE), mask (MASK)
+
+=item Some Safety Issues
+
+Memory, CPU, Snooping, Signals, State Changes
+
+=item AUTHOR
+
+=back
+
+=head2 Opcode::ops, ops - Perl pragma to restrict unsafe operations when
+compiling
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item SEE ALSO
+
+=head2 POSIX - Perl interface to IEEE Std 1003.1
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item CAVEATS
+
+=item FUNCTIONS
+
+_exit, abort, abs, access, acos, alarm, asctime, asin, assert, atan, atan2,
+atexit, atof, atoi, atol, bsearch, calloc, ceil, chdir, chmod, chown,
+clearerr, clock, close, closedir, cos, cosh, creat, ctermid, ctime,
+cuserid, difftime, div, dup, dup2, errno, execl, execle, execlp, execv,
+execve, execvp, exit, exp, fabs, fclose, fcntl, fdopen, feof, ferror,
+fflush, fgetc, fgetpos, fgets, fileno, floor, fmod, fopen, fork, fpathconf,
+fprintf, fputc, fputs, fread, free, freopen, frexp, fscanf, fseek, fsetpos,
+fstat, ftell, fwrite, getc, getchar, getcwd, getegid, getenv, geteuid,
+getgid, getgrgid, getgrnam, getgroups, getlogin, getpgrp, getpid, getppid,
+getpwnam, getpwuid, gets, getuid, gmtime, isalnum, isalpha, isatty,
+iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper,
+isxdigit, kill, labs, ldexp, ldiv, link, localeconv, localtime, log, log10,
+longjmp, lseek, malloc, mblen, mbstowcs, mbtowc, memchr, memcmp, memcpy,
+memmove, memset, mkdir, mkfifo, mktime, modf, nice, offsetof, open,
+opendir, pathconf, pause, perror, pipe, pow, printf, putc, putchar, puts,
+qsort, raise, rand, read, readdir, realloc, remove, rename, rewind,
+rewinddir, rmdir, scanf, setgid, setjmp, setlocale, setpgid, setsid,
+setuid, sigaction, siglongjmp, sigpending, sigprocmask, sigsetjmp,
+sigsuspend, sin, sinh, sleep, sprintf, sqrt, srand, sscanf, stat, strcat,
+strchr, strcmp, strcoll, strcpy, strcspn, strerror, strftime, strlen,
+strncat, strncmp, strncpy, stroul, strpbrk, strrchr, strspn, strstr,
+strtod, strtok, strtol, strtoul, strxfrm, sysconf, system, tan, tanh,
+tcdrain, tcflow, tcflush, tcgetpgrp, tcsendbreak, tcsetpgrp, time, times,
+tmpfile, tmpnam, tolower, toupper, ttyname, tzname, tzset, umask, uname,
+ungetc, unlink, utime, vfprintf, vprintf, vsprintf, wait, waitpid,
+wcstombs, wctomb, write
+
+=item CLASSES
+
+=over
+
+=item POSIX::SigAction
+
+new
+
+=item POSIX::SigSet
+
+new, addset, delset, emptyset, fillset, ismember
+
+=item POSIX::Termios
+
+new, getattr, getcc, getcflag, getiflag, getispeed, getlflag, getoflag,
+getospeed, setattr, setcc, setcflag, setiflag, setispeed, setlflag,
+setoflag, setospeed, Baud rate values, Terminal interface values, c_cc
+field values, c_cflag field values, c_iflag field values, c_lflag field
+values, c_oflag field values
+
+=back
+
+=item PATHNAME CONSTANTS
+
+Constants
+
+=item POSIX CONSTANTS
+
+Constants
+
+=item SYSTEM CONFIGURATION
+
+Constants
+
+=item ERRNO
+
+Constants
+
+=item FCNTL
+
+Constants
+
+=item FLOAT
+
+Constants
+
+=item LIMITS
+
+Constants
+
+=item LOCALE
+
+Constants
+
+=item MATH
+
+Constants
+
+=item SIGNAL
+
+Constants
+
+=item STAT
+
+Constants, Macros
+
+=item STDLIB
+
+Constants
+
+=item STDIO
+
+Constants
+
+=item TIME
+
+Constants
+
+=item UNISTD
+
+Constants
+
+=item WAIT
+
+Constants, Macros
+
+=item CREATION
+
+=head2 Pod::Html - module to convert pod files to HTML
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item ARGUMENTS
+
+help, htmlroot, infile, outfile, podroot, podpath, libpods, netscape,
+nonetscape, index, noindex, recurse, norecurse, title, verbose
+
+=item EXAMPLE
+
+=item AUTHOR
+
+=item BUGS
+
+=item SEE ALSO
+
+=item COPYRIGHT
+
+=head2 Pod::Text - convert POD data to formatted ASCII text
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=item TODO
+
+=head2 SDBM_File - Tied access to sdbm files
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Search::Dict, look - search for key in dictionary file
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 SelectSaver - save and restore selected file handle
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 SelfLoader - load functions only on demand
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item The __DATA__ token
+
+=item SelfLoader autoloading
+
+=item Autoloading and package lexicals
+
+=item SelfLoader and AutoLoader
+
+=item __DATA__, __END__, and the FOOBAR::DATA filehandle.
+
+=item Classes and inherited methods.
+
+=back
+
+=item Multiple packages and fully qualified subroutine names
+
+=head2 Shell - run shell commands transparently within perl
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 Socket, sockaddr_in, sockaddr_un, inet_aton, inet_ntoa - load the C
+socket.h defines and structure manipulators
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+inet_aton HOSTNAME, inet_ntoa IP_ADDRESS, INADDR_ANY, INADDR_BROADCAST,
+INADDR_LOOPBACK, INADDR_NONE, sockaddr_in PORT, ADDRESS, sockaddr_in
+SOCKADDR_IN, pack_sockaddr_in PORT, IP_ADDRESS, unpack_sockaddr_in
+SOCKADDR_IN, sockaddr_un PATHNAME, sockaddr_un SOCKADDR_UN,
+pack_sockaddr_un PATH, unpack_sockaddr_un SOCKADDR_UN
+
+=head2 Symbol - manipulate Perl symbols and their names
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Sys::Hostname - Try every conceivable way to get hostname
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 Syslog, Sys::Syslog, openlog, closelog, setlogmask, syslog - Perl
+interface to the UNIX syslog(3) calls
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+openlog $ident, $logopt, $facility, syslog $priority, $format, @args,
+setlogmask $mask_priority, setlogsock $sock_type (added in 5.004_02),
+closelog
+
+=item EXAMPLES
+
+=item DEPENDENCIES
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 Term::Cap - Perl termcap interface
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+=head2 Term::Complete - Perl word completion module
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+E<lt>tabE<gt>, ^D, ^U, E<lt>delE<gt>, E<lt>bsE<gt>
+
+=item DIAGNOSTICS
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Term::ReadLine - Perl interface to various C<readline> packages. If
+no real package is found, substitutes stubs instead of basic functions.
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item Minimal set of supported functions
+
+C<ReadLine>, C<new>, C<readline>, C<addhistory>, C<IN>, $C<OUT>,
+C<MinLine>, C<findConsole>, Attribs, C<Features>
+
+=item Additional supported functions
+
+C<tkRunning>, C<ornaments>, C<newTTY>
+
+=item EXPORTS
+
+=item ENVIRONMENT
+
+=head2 Test - provides a simple framework for writing test scripts
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item TEST TYPES
+
+NORMAL TESTS, SKIPPED TESTS, TODO TESTS
+
+=item ONFAIL
+
+=item SEE ALSO
+
+=item AUTHOR
+
+=head2 Test::Harness - run perl standard test scripts with statistics
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=over
+
+=item The test script output
+
+=back
+
+=item EXPORT
+
+=item DIAGNOSTICS
+
+C<All tests successful.\nFiles=%d, Tests=%d, %s>, C<FAILED tests
+%s\n\tFailed %d/%d tests, %.2f%% okay.>, C<Test returned status %d (wstat
+%d)>, C<Failed 1 test, %.2f%% okay. %s>, C<Failed %d/%d tests, %.2f%% okay.
+%s>
+
+=item ENVIRONMENT
+
+=item SEE ALSO
+
+=item AUTHORS
+
+=item BUGS
+
+=head2 Text::Abbrev, abbrev - create an abbreviation table from a list
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLE
+
+=head2 Text::ParseWords - parse text into an array of tokens or array of
+arrays
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+0a simple word, 1multiple spaces are skipped because of our $delim, 2use of
+quotes to include a space in a word, 3use of a backslash to include a space
+in a word, 4use of a backslash to remove the special meaning of a
+double-quote, 5another simple word (note the lack of effect of the
+backslashed double-quote)
+
+=item AUTHORS
+
+=head2 Text::Soundex - Implementation of the Soundex Algorithm as Described
+by Knuth
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLES
+
+=item LIMITATIONS
+
+=item AUTHOR
+
+=head2 Text::Tabs -- expand and unexpand tabs per the unix expand(1) and
+unexpand(1)
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Text::Wrap - line wrapping to form simple paragraphs
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLE
+
+=item BUGS
+
+=item AUTHOR
+
+=head2 Thread - multithreading
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item FUNCTIONS
+
+new \&start_sub, new \&start_sub, LIST, lock VARIABLE, async BLOCK;,
+Thread->self, Thread->list, cond_wait VARIABLE, cond_signal VARIABLE,
+cond_broadcast VARIABLE
+
+=item METHODS
+
+join, eval, tid
+
+=item LIMITATIONS
+
+=item SEE ALSO
+
+=head2 Thread::Queue - thread-safe queues
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item FUNCTIONS AND METHODS
+
+new, enqueue LIST, dequeue, dequeue_nb, pending
+
+=item SEE ALSO
+
+=head2 Thread::Semaphore - thread-safe semaphores
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item FUNCTIONS AND METHODS
+
+new, new NUMBER, down, down NUMBER, up, up NUMBER
+
+=head2 Thread::Signal - Start a thread which runs signal handlers reliably
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item BUGS
+
+=head2 Thread::Specific - thread-specific keys
+
+=item SYNOPSIS
+
+=head2 Tie::Array - base class for tied arrays
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+TIEARRAY classname, LIST, STORE this, index, value, FETCH this, index,
+FETCHSIZE this, STORESIZE this, count, EXTEND this, count, CLEAR this,
+DESTROY this, PUSH this, LIST, POP this, SHIFT this, UNSHIFT this, LIST,
+SPLICE this, offset, length, LIST
+
+=item CAVEATS
+
+=item AUTHOR
+
+=head2 Tie::Handle - base class definitions for tied handles
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+TIEHANDLE classname, LIST, WRITE this, scalar, length, offset, PRINT this,
+LIST, PRINTF this, format, LIST, READ this, scalar, length, offset,
+READLINE this, GETC this, DESTROY this
+
+=item MORE INFORMATION
+
+=head2 Tie::Hash, Tie::StdHash - base class definitions for tied hashes
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+TIEHASH classname, LIST, STORE this, key, value, FETCH this, key, FIRSTKEY
+this, NEXTKEY this, lastkey, EXISTS this, key, DELETE this, key, CLEAR this
+
+=item CAVEATS
+
+=item MORE INFORMATION
+
+=head2 Tie::RefHash - use references as hash keys
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item EXAMPLE
+
+=item AUTHOR
+
+=item VERSION
+
+=item SEE ALSO
+
+=head2 Tie::Scalar, Tie::StdScalar - base class definitions for tied
+scalars
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+TIESCALAR classname, LIST, FETCH this, STORE this, value, DESTROY this
+
+=item MORE INFORMATION
+
+=head2 Tie::SubstrHash - Fixed-table-size, fixed-key-length hashing
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item CAVEATS
+
+=head2 Time::Local - efficiently compute time from local and GMT time
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=head2 Time::gmtime - by-name interface to Perl's built-in gmtime()
+function
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 Time::localtime - by-name interface to Perl's built-in localtime()
+function
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 Time::tm - internal object used by Time::gmtime and Time::localtime
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item AUTHOR
+
+=head2 UNIVERSAL - base class for ALL classes (blessed references)
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+isa ( TYPE ), can ( METHOD ), VERSION ( [ REQUIRE ] ), UNIVERSAL::isa (
+VAL, TYPE ), UNIVERSAL::can ( VAL, METHOD )
+
+=head2 User::grent - by-name interface to Perl's built-in getgr*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head2 User::pwent - by-name interface to Perl's built-in getpw*()
+functions
+
+=item SYNOPSIS
+
+=item DESCRIPTION
+
+=item NOTE
+
+=item AUTHOR
+
+=head1 AUXILIARY DOCUMENTATION
+
+Here should be listed all the extra programs' documentation, but they
+don't all have manual pages yet:
+
+=item a2p
+
+=item s2p
+
+=item find2perl
+
+=item h2ph
+
+=item c2ph
+
+=item h2xs
+
+=item xsubpp
+
+=item pod2man
+
+=item wrapsuid
+
+=head1 AUTHOR
+
+Larry Wall <F<larry@wall.org>>, with the help of oodles
+of other folks.
+
diff --git a/contrib/perl5/pod/perltoot.pod b/contrib/perl5/pod/perltoot.pod
new file mode 100644
index 0000000..c77a971
--- /dev/null
+++ b/contrib/perl5/pod/perltoot.pod
@@ -0,0 +1,1787 @@
+=head1 NAME
+
+perltoot - Tom's object-oriented tutorial for perl
+
+=head1 DESCRIPTION
+
+Object-oriented programming is a big seller these days. Some managers
+would rather have objects than sliced bread. Why is that? What's so
+special about an object? Just what I<is> an object anyway?
+
+An object is nothing but a way of tucking away complex behaviours into
+a neat little easy-to-use bundle. (This is what professors call
+abstraction.) Smart people who have nothing to do but sit around for
+weeks on end figuring out really hard problems make these nifty
+objects that even regular people can use. (This is what professors call
+software reuse.) Users (well, programmers) can play with this little
+bundle all they want, but they aren't to open it up and mess with the
+insides. Just like an expensive piece of hardware, the contract says
+that you void the warranty if you muck with the cover. So don't do that.
+
+The heart of objects is the class, a protected little private namespace
+full of data and functions. A class is a set of related routines that
+addresses some problem area. You can think of it as a user-defined type.
+The Perl package mechanism, also used for more traditional modules,
+is used for class modules as well. Objects "live" in a class, meaning
+that they belong to some package.
+
+More often than not, the class provides the user with little bundles.
+These bundles are objects. They know whose class they belong to,
+and how to behave. Users ask the class to do something, like "give
+me an object." Or they can ask one of these objects to do something.
+Asking a class to do something for you is calling a I<class method>.
+Asking an object to do something for you is calling an I<object method>.
+Asking either a class (usually) or an object (sometimes) to give you
+back an object is calling a I<constructor>, which is just a
+kind of method.
+
+That's all well and good, but how is an object different from any other
+Perl data type? Just what is an object I<really>; that is, what's its
+fundamental type? The answer to the first question is easy. An object
+is different from any other data type in Perl in one and only one way:
+you may dereference it using not merely string or numeric subscripts
+as with simple arrays and hashes, but with named subroutine calls.
+In a word, with I<methods>.
+
+The answer to the second question is that it's a reference, and not just
+any reference, mind you, but one whose referent has been I<bless>()ed
+into a particular class (read: package). What kind of reference? Well,
+the answer to that one is a bit less concrete. That's because in Perl
+the designer of the class can employ any sort of reference they'd like
+as the underlying intrinsic data type. It could be a scalar, an array,
+or a hash reference. It could even be a code reference. But because
+of its inherent flexibility, an object is usually a hash reference.
+
+=head1 Creating a Class
+
+Before you create a class, you need to decide what to name it. That's
+because the class (package) name governs the name of the file used to
+house it, just as with regular modules. Then, that class (package)
+should provide one or more ways to generate objects. Finally, it should
+provide mechanisms to allow users of its objects to indirectly manipulate
+these objects from a distance.
+
+For example, let's make a simple Person class module. It gets stored in
+the file Person.pm. If it were called a Happy::Person class, it would
+be stored in the file Happy/Person.pm, and its package would become
+Happy::Person instead of just Person. (On a personal computer not
+running Unix or Plan 9, but something like MacOS or VMS, the directory
+separator may be different, but the principle is the same.) Do not assume
+any formal relationship between modules based on their directory names.
+This is merely a grouping convenience, and has no effect on inheritance,
+variable accessibility, or anything else.
+
+For this module we aren't going to use Exporter, because we're
+a well-behaved class module that doesn't export anything at all.
+In order to manufacture objects, a class needs to have a I<constructor
+method>. A constructor gives you back not just a regular data type,
+but a brand-new object in that class. This magic is taken care of by
+the bless() function, whose sole purpose is to enable its referent to
+be used as an object. Remember: being an object really means nothing
+more than that methods may now be called against it.
+
+While a constructor may be named anything you'd like, most Perl
+programmers seem to like to call theirs new(). However, new() is not
+a reserved word, and a class is under no obligation to supply such.
+Some programmers have also been known to use a function with
+the same name as the class as the constructor.
+
+=head2 Object Representation
+
+By far the most common mechanism used in Perl to represent a Pascal
+record, a C struct, or a C++ class is an anonymous hash. That's because a
+hash has an arbitrary number of data fields, each conveniently accessed by
+an arbitrary name of your own devising.
+
+If you were just doing a simple
+struct-like emulation, you would likely go about it something like this:
+
+ $rec = {
+ name => "Jason",
+ age => 23,
+ peers => [ "Norbert", "Rhys", "Phineas"],
+ };
+
+If you felt like it, you could add a bit of visual distinction
+by up-casing the hash keys:
+
+ $rec = {
+ NAME => "Jason",
+ AGE => 23,
+ PEERS => [ "Norbert", "Rhys", "Phineas"],
+ };
+
+And so you could get at C<$rec-E<gt>{NAME}> to find "Jason", or
+C<@{ $rec-E<gt>{PEERS} }> to get at "Norbert", "Rhys", and "Phineas".
+(Have you ever noticed how many 23-year-old programmers seem to
+be named "Jason" these days? :-)
+
+This same model is often used for classes, although it is not considered
+the pinnacle of programming propriety for folks from outside the
+class to come waltzing into an object, brazenly accessing its data
+members directly. Generally speaking, an object should be considered
+an opaque cookie that you use I<object methods> to access. Visually,
+methods look like you're dereffing a reference using a function name
+instead of brackets or braces.
+
+=head2 Class Interface
+
+Some languages provide a formal syntactic interface to a class's methods,
+but Perl does not. It relies on you to read the documentation of each
+class. If you try to call an undefined method on an object, Perl won't
+complain, but the program will trigger an exception while it's running.
+Likewise, if you call a method expecting a prime number as its argument
+with a non-prime one instead, you can't expect the compiler to catch this.
+(Well, you can expect it all you like, but it's not going to happen.)
+
+Let's suppose you have a well-educated user of your Person class,
+someone who has read the docs that explain the prescribed
+interface. Here's how they might use the Person class:
+
+ use Person;
+
+ $him = Person->new();
+ $him->name("Jason");
+ $him->age(23);
+ $him->peers( "Norbert", "Rhys", "Phineas" );
+
+ push @All_Recs, $him; # save object in array for later
+
+ printf "%s is %d years old.\n", $him->name, $him->age;
+ print "His peers are: ", join(", ", $him->peers), "\n";
+
+ printf "Last rec's name is %s\n", $All_Recs[-1]->name;
+
+As you can see, the user of the class doesn't know (or at least, has no
+business paying attention to the fact) that the object has one particular
+implementation or another. The interface to the class and its objects
+is exclusively via methods, and that's all the user of the class should
+ever play with.
+
+=head2 Constructors and Instance Methods
+
+Still, I<someone> has to know what's in the object. And that someone is
+the class. It implements methods that the programmer uses to access
+the object. Here's how to implement the Person class using the standard
+hash-ref-as-an-object idiom. We'll make a class method called new() to
+act as the constructor, and three object methods called name(), age(), and
+peers() to get at per-object data hidden away in our anonymous hash.
+
+ package Person;
+ use strict;
+
+ ##################################################
+ ## the object constructor (simplistic version) ##
+ ##################################################
+ sub new {
+ my $self = {};
+ $self->{NAME} = undef;
+ $self->{AGE} = undef;
+ $self->{PEERS} = [];
+ bless($self); # but see below
+ return $self;
+ }
+
+ ##############################################
+ ## methods to access per-object data ##
+ ## ##
+ ## With args, they set the value. Without ##
+ ## any, they only retrieve it/them. ##
+ ##############################################
+
+ sub name {
+ my $self = shift;
+ if (@_) { $self->{NAME} = shift }
+ return $self->{NAME};
+ }
+
+ sub age {
+ my $self = shift;
+ if (@_) { $self->{AGE} = shift }
+ return $self->{AGE};
+ }
+
+ sub peers {
+ my $self = shift;
+ if (@_) { @{ $self->{PEERS} } = @_ }
+ return @{ $self->{PEERS} };
+ }
+
+ 1; # so the require or use succeeds
+
+We've created three methods to access an object's data, name(), age(),
+and peers(). These are all substantially similar. If called with an
+argument, they set the appropriate field; otherwise they return the
+value held by that field, meaning the value of that hash key.
+
+=head2 Planning for the Future: Better Constructors
+
+Even though at this point you may not even know what it means, someday
+you're going to worry about inheritance. (You can safely ignore this
+for now and worry about it later if you'd like.) To ensure that this
+all works out smoothly, you must use the double-argument form of bless().
+The second argument is the class into which the referent will be blessed.
+By not assuming our own class as the default second argument and instead
+using the class passed into us, we make our constructor inheritable.
+
+While we're at it, let's make our constructor a bit more flexible.
+Rather than being uniquely a class method, we'll set it up so that
+it can be called as either a class method I<or> an object
+method. That way you can say:
+
+ $me = Person->new();
+ $him = $me->new();
+
+To do this, all we have to do is check whether what was passed in
+was a reference or not. If so, we were invoked as an object method,
+and we need to extract the package (class) using the ref() function.
+If not, we just use the string passed in as the package name
+for blessing our referent.
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {};
+ $self->{NAME} = undef;
+ $self->{AGE} = undef;
+ $self->{PEERS} = [];
+ bless ($self, $class);
+ return $self;
+ }
+
+That's about all there is for constructors. These methods bring objects
+to life, returning neat little opaque bundles to the user to be used in
+subsequent method calls.
+
+=head2 Destructors
+
+Every story has a beginning and an end. The beginning of the object's
+story is its constructor, explicitly called when the object comes into
+existence. But the ending of its story is the I<destructor>, a method
+implicitly called when an object leaves this life. Any per-object
+clean-up code is placed in the destructor, which must (in Perl) be called
+DESTROY.
+
+If constructors can have arbitrary names, then why not destructors?
+Because while a constructor is explicitly called, a destructor is not.
+Destruction happens automatically via Perl's garbage collection (GC)
+system, which is a quick but somewhat lazy reference-based GC system.
+To know what to call, Perl insists that the destructor be named DESTROY.
+Perl's notion of the right time to call a destructor is not well-defined
+currently, which is why your destructors should not rely on when they are
+called.
+
+Why is DESTROY in all caps? Perl on occasion uses purely uppercase
+function names as a convention to indicate that the function will
+be automatically called by Perl in some way. Others that are called
+implicitly include BEGIN, END, AUTOLOAD, plus all methods used by
+tied objects, described in L<perltie>.
+
+In really good object-oriented programming languages, the user doesn't
+care when the destructor is called. It just happens when it's supposed
+to. In low-level languages without any GC at all, there's no way to
+depend on this happening at the right time, so the programmer must
+explicitly call the destructor to clean up memory and state, crossing
+their fingers that it's the right time to do so. Unlike C++, an
+object destructor is nearly never needed in Perl, and even when it is,
+explicit invocation is uncalled for. In the case of our Person class,
+we don't need a destructor because Perl takes care of simple matters
+like memory deallocation.
+
+The only situation where Perl's reference-based GC won't work is
+when there's a circularity in the data structure, such as:
+
+ $this->{WHATEVER} = $this;
+
+In that case, you must delete the self-reference manually if you expect
+your program not to leak memory. While admittedly error-prone, this is
+the best we can do right now. Nonetheless, rest assured that when your
+program is finished, its objects' destructors are all duly called.
+So you are guaranteed that an object I<eventually> gets properly
+destroyed, except in the unique case of a program that never exits.
+(If you're running Perl embedded in another application, this full GC
+pass happens a bit more frequently--whenever a thread shuts down.)
+
+=head2 Other Object Methods
+
+The methods we've talked about so far have either been constructors or
+else simple "data methods", interfaces to data stored in the object.
+These are a bit like an object's data members in the C++ world, except
+that strangers don't access them as data. Instead, they should only
+access the object's data indirectly via its methods. This is an
+important rule: in Perl, access to an object's data should I<only>
+be made through methods.
+
+Perl doesn't impose restrictions on who gets to use which methods.
+The public-versus-private distinction is by convention, not syntax.
+(Well, unless you use the Alias module described below in
+L<Data Members as Variables>.) Occasionally you'll see method names beginning or ending
+with an underscore or two. This marking is a convention indicating
+that the methods are private to that class alone and sometimes to its
+closest acquaintances, its immediate subclasses. But this distinction
+is not enforced by Perl itself. It's up to the programmer to behave.
+
+There's no reason to limit methods to those that simply access data.
+Methods can do anything at all. The key point is that they're invoked
+against an object or a class. Let's say we'd like object methods that
+do more than fetch or set one particular field.
+
+ sub exclaim {
+ my $self = shift;
+ return sprintf "Hi, I'm %s, age %d, working with %s",
+ $self->{NAME}, $self->{AGE}, join(", ", $self->{PEERS});
+ }
+
+Or maybe even one like this:
+
+ sub happy_birthday {
+ my $self = shift;
+ return ++$self->{AGE};
+ }
+
+Some might argue that one should go at these this way:
+
+ sub exclaim {
+ my $self = shift;
+ return sprintf "Hi, I'm %s, age %d, working with %s",
+ $self->name, $self->age, join(", ", $self->peers);
+ }
+
+ sub happy_birthday {
+ my $self = shift;
+ return $self->age( $self->age() + 1 );
+ }
+
+But since these methods are all executing in the class itself, this
+may not be critical. There are tradeoffs to be made. Using direct
+hash access is faster (about an order of magnitude faster, in fact), and
+it's more convenient when you want to interpolate in strings. But using
+methods (the external interface) internally shields not just the users of
+your class but even you yourself from changes in your data representation.
+
+=head1 Class Data
+
+What about "class data", data items common to each object in a class?
+What would you want that for? Well, in your Person class, you might
+like to keep track of the total people alive. How do you implement that?
+
+You I<could> make it a global variable called $Person::Census. But about
+only reason you'd do that would be if you I<wanted> people to be able to
+get at your class data directly. They could just say $Person::Census
+and play around with it. Maybe this is ok in your design scheme.
+You might even conceivably want to make it an exported variable. To be
+exportable, a variable must be a (package) global. If this were a
+traditional module rather than an object-oriented one, you might do that.
+
+While this approach is expected in most traditional modules, it's
+generally considered rather poor form in most object modules. In an
+object module, you should set up a protective veil to separate interface
+from implementation. So provide a class method to access class data
+just as you provide object methods to access object data.
+
+So, you I<could> still keep $Census as a package global and rely upon
+others to honor the contract of the module and therefore not play around
+with its implementation. You could even be supertricky and make $Census a
+tied object as described in L<perltie>, thereby intercepting all accesses.
+
+But more often than not, you just want to make your class data a
+file-scoped lexical. To do so, simply put this at the top of the file:
+
+ my $Census = 0;
+
+Even though the scope of a my() normally expires when the block in which
+it was declared is done (in this case the whole file being required or
+used), Perl's deep binding of lexical variables guarantees that the
+variable will not be deallocated, remaining accessible to functions
+declared within that scope. This doesn't work with global variables
+given temporary values via local(), though.
+
+Irrespective of whether you leave $Census a package global or make
+it instead a file-scoped lexical, you should make these
+changes to your Person::new() constructor:
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {};
+ $Census++;
+ $self->{NAME} = undef;
+ $self->{AGE} = undef;
+ $self->{PEERS} = [];
+ bless ($self, $class);
+ return $self;
+ }
+
+ sub population {
+ return $Census;
+ }
+
+Now that we've done this, we certainly do need a destructor so that
+when Person is destroyed, the $Census goes down. Here's how
+this could be done:
+
+ sub DESTROY { --$Census }
+
+Notice how there's no memory to deallocate in the destructor? That's
+something that Perl takes care of for you all by itself.
+
+=head2 Accessing Class Data
+
+It turns out that this is not really a good way to go about handling
+class data. A good scalable rule is that I<you must never reference class
+data directly from an object method>. Otherwise you aren't building a
+scalable, inheritable class. The object must be the rendezvous point
+for all operations, especially from an object method. The globals
+(class data) would in some sense be in the "wrong" package in your
+derived classes. In Perl, methods execute in the context of the class
+they were defined in, I<not> that of the object that triggered them.
+Therefore, namespace visibility of package globals in methods is unrelated
+to inheritance.
+
+Got that? Maybe not. Ok, let's say that some other class "borrowed"
+(well, inherited) the DESTROY method as it was defined above. When those
+objects are destroyed, the original $Census variable will be altered,
+not the one in the new class's package namespace. Perhaps this is what
+you want, but probably it isn't.
+
+Here's how to fix this. We'll store a reference to the data in the
+value accessed by the hash key "_CENSUS". Why the underscore? Well,
+mostly because an initial underscore already conveys strong feelings
+of magicalness to a C programmer. It's really just a mnemonic device
+to remind ourselves that this field is special and not to be used as
+a public data member in the same way that NAME, AGE, and PEERS are.
+(Because we've been developing this code under the strict pragma, prior
+to perl version 5.004 we'll have to quote the field name.)
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {};
+ $self->{NAME} = undef;
+ $self->{AGE} = undef;
+ $self->{PEERS} = [];
+ # "private" data
+ $self->{"_CENSUS"} = \$Census;
+ bless ($self, $class);
+ ++ ${ $self->{"_CENSUS"} };
+ return $self;
+ }
+
+ sub population {
+ my $self = shift;
+ if (ref $self) {
+ return ${ $self->{"_CENSUS"} };
+ } else {
+ return $Census;
+ }
+ }
+
+ sub DESTROY {
+ my $self = shift;
+ -- ${ $self->{"_CENSUS"} };
+ }
+
+=head2 Debugging Methods
+
+It's common for a class to have a debugging mechanism. For example,
+you might want to see when objects are created or destroyed. To do that,
+add a debugging variable as a file-scoped lexical. For this, we'll pull
+in the standard Carp module to emit our warnings and fatal messages.
+That way messages will come out with the caller's filename and
+line number instead of our own; if we wanted them to be from our own
+perspective, we'd just use die() and warn() directly instead of croak()
+and carp() respectively.
+
+ use Carp;
+ my $Debugging = 0;
+
+Now add a new class method to access the variable.
+
+ sub debug {
+ my $class = shift;
+ if (ref $class) { confess "Class method called as object method" }
+ unless (@_ == 1) { confess "usage: CLASSNAME->debug(level)" }
+ $Debugging = shift;
+ }
+
+Now fix up DESTROY to murmur a bit as the moribund object expires:
+
+ sub DESTROY {
+ my $self = shift;
+ if ($Debugging) { carp "Destroying $self " . $self->name }
+ -- ${ $self->{"_CENSUS"} };
+ }
+
+One could conceivably make a per-object debug state. That
+way you could call both of these:
+
+ Person->debug(1); # entire class
+ $him->debug(1); # just this object
+
+To do so, we need our debugging method to be a "bimodal" one, one that
+works on both classes I<and> objects. Therefore, adjust the debug()
+and DESTROY methods as follows:
+
+ sub debug {
+ my $self = shift;
+ confess "usage: thing->debug(level)" unless @_ == 1;
+ my $level = shift;
+ if (ref($self)) {
+ $self->{"_DEBUG"} = $level; # just myself
+ } else {
+ $Debugging = $level; # whole class
+ }
+ }
+
+ sub DESTROY {
+ my $self = shift;
+ if ($Debugging || $self->{"_DEBUG"}) {
+ carp "Destroying $self " . $self->name;
+ }
+ -- ${ $self->{"_CENSUS"} };
+ }
+
+What happens if a derived class (which we'll call Employee) inherits
+methods from this Person base class? Then C<Employee-E<gt>debug()>, when called
+as a class method, manipulates $Person::Debugging not $Employee::Debugging.
+
+=head2 Class Destructors
+
+The object destructor handles the death of each distinct object. But sometimes
+you want a bit of cleanup when the entire class is shut down, which
+currently only happens when the program exits. To make such a
+I<class destructor>, create a function in that class's package named
+END. This works just like the END function in traditional modules,
+meaning that it gets called whenever your program exits unless it execs
+or dies of an uncaught signal. For example,
+
+ sub END {
+ if ($Debugging) {
+ print "All persons are going away now.\n";
+ }
+ }
+
+When the program exits, all the class destructors (END functions) are
+be called in the opposite order that they were loaded in (LIFO order).
+
+=head2 Documenting the Interface
+
+And there you have it: we've just shown you the I<implementation> of this
+Person class. Its I<interface> would be its documentation. Usually this
+means putting it in pod ("plain old documentation") format right there
+in the same file. In our Person example, we would place the following
+docs anywhere in the Person.pm file. Even though it looks mostly like
+code, it's not. It's embedded documentation such as would be used by
+the pod2man, pod2html, or pod2text programs. The Perl compiler ignores
+pods entirely, just as the translators ignore code. Here's an example of
+some pods describing the informal interface:
+
+ =head1 NAME
+
+ Person - class to implement people
+
+ =head1 SYNOPSIS
+
+ use Person;
+
+ #################
+ # class methods #
+ #################
+ $ob = Person->new;
+ $count = Person->population;
+
+ #######################
+ # object data methods #
+ #######################
+
+ ### get versions ###
+ $who = $ob->name;
+ $years = $ob->age;
+ @pals = $ob->peers;
+
+ ### set versions ###
+ $ob->name("Jason");
+ $ob->age(23);
+ $ob->peers( "Norbert", "Rhys", "Phineas" );
+
+ ########################
+ # other object methods #
+ ########################
+
+ $phrase = $ob->exclaim;
+ $ob->happy_birthday;
+
+ =head1 DESCRIPTION
+
+ The Person class implements dah dee dah dee dah....
+
+That's all there is to the matter of interface versus implementation.
+A programmer who opens up the module and plays around with all the private
+little shiny bits that were safely locked up behind the interface contract
+has voided the warranty, and you shouldn't worry about their fate.
+
+=head1 Aggregation
+
+Suppose you later want to change the class to implement better names.
+Perhaps you'd like to support both given names (called Christian names,
+irrespective of one's religion) and family names (called surnames), plus
+nicknames and titles. If users of your Person class have been properly
+accessing it through its documented interface, then you can easily change
+the underlying implementation. If they haven't, then they lose and
+it's their fault for breaking the contract and voiding their warranty.
+
+To do this, we'll make another class, this one called Fullname. What's
+the Fullname class look like? To answer that question, you have to
+first figure out how you want to use it. How about we use it this way:
+
+ $him = Person->new();
+ $him->fullname->title("St");
+ $him->fullname->christian("Thomas");
+ $him->fullname->surname("Aquinas");
+ $him->fullname->nickname("Tommy");
+ printf "His normal name is %s\n", $him->name;
+ printf "But his real name is %s\n", $him->fullname->as_string;
+
+Ok. To do this, we'll change Person::new() so that it supports
+a full name field this way:
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {};
+ $self->{FULLNAME} = Fullname->new();
+ $self->{AGE} = undef;
+ $self->{PEERS} = [];
+ $self->{"_CENSUS"} = \$Census;
+ bless ($self, $class);
+ ++ ${ $self->{"_CENSUS"} };
+ return $self;
+ }
+
+ sub fullname {
+ my $self = shift;
+ return $self->{FULLNAME};
+ }
+
+Then to support old code, define Person::name() this way:
+
+ sub name {
+ my $self = shift;
+ return $self->{FULLNAME}->nickname(@_)
+ || $self->{FULLNAME}->christian(@_);
+ }
+
+Here's the Fullname class. We'll use the same technique
+of using a hash reference to hold data fields, and methods
+by the appropriate name to access them:
+
+ package Fullname;
+ use strict;
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = {
+ TITLE => undef,
+ CHRISTIAN => undef,
+ SURNAME => undef,
+ NICK => undef,
+ };
+ bless ($self, $class);
+ return $self;
+ }
+
+ sub christian {
+ my $self = shift;
+ if (@_) { $self->{CHRISTIAN} = shift }
+ return $self->{CHRISTIAN};
+ }
+
+ sub surname {
+ my $self = shift;
+ if (@_) { $self->{SURNAME} = shift }
+ return $self->{SURNAME};
+ }
+
+ sub nickname {
+ my $self = shift;
+ if (@_) { $self->{NICK} = shift }
+ return $self->{NICK};
+ }
+
+ sub title {
+ my $self = shift;
+ if (@_) { $self->{TITLE} = shift }
+ return $self->{TITLE};
+ }
+
+ sub as_string {
+ my $self = shift;
+ my $name = join(" ", @$self{'CHRISTIAN', 'SURNAME'});
+ if ($self->{TITLE}) {
+ $name = $self->{TITLE} . " " . $name;
+ }
+ return $name;
+ }
+
+ 1;
+
+Finally, here's the test program:
+
+ #!/usr/bin/perl -w
+ use strict;
+ use Person;
+ sub END { show_census() }
+
+ sub show_census () {
+ printf "Current population: %d\n", Person->population;
+ }
+
+ Person->debug(1);
+
+ show_census();
+
+ my $him = Person->new();
+
+ $him->fullname->christian("Thomas");
+ $him->fullname->surname("Aquinas");
+ $him->fullname->nickname("Tommy");
+ $him->fullname->title("St");
+ $him->age(1);
+
+ printf "%s is really %s.\n", $him->name, $him->fullname;
+ printf "%s's age: %d.\n", $him->name, $him->age;
+ $him->happy_birthday;
+ printf "%s's age: %d.\n", $him->name, $him->age;
+
+ show_census();
+
+=head1 Inheritance
+
+Object-oriented programming systems all support some notion of
+inheritance. Inheritance means allowing one class to piggy-back on
+top of another one so you don't have to write the same code again and
+again. It's about software reuse, and therefore related to Laziness,
+the principal virtue of a programmer. (The import/export mechanisms in
+traditional modules are also a form of code reuse, but a simpler one than
+the true inheritance that you find in object modules.)
+
+Sometimes the syntax of inheritance is built into the core of the
+language, and sometimes it's not. Perl has no special syntax for
+specifying the class (or classes) to inherit from. Instead, it's all
+strictly in the semantics. Each package can have a variable called @ISA,
+which governs (method) inheritance. If you try to call a method on an
+object or class, and that method is not found in that object's package,
+Perl then looks to @ISA for other packages to go looking through in
+search of the missing method.
+
+Like the special per-package variables recognized by Exporter (such as
+@EXPORT, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, and $VERSION), the @ISA
+array I<must> be a package-scoped global and not a file-scoped lexical
+created via my(). Most classes have just one item in their @ISA array.
+In this case, we have what's called "single inheritance", or SI for short.
+
+Consider this class:
+
+ package Employee;
+ use Person;
+ @ISA = ("Person");
+ 1;
+
+Not a lot to it, eh? All it's doing so far is loading in another
+class and stating that this one will inherit methods from that
+other class if need be. We have given it none of its own methods.
+We rely upon an Employee to behave just like a Person.
+
+Setting up an empty class like this is called the "empty subclass test";
+that is, making a derived class that does nothing but inherit from a
+base class. If the original base class has been designed properly,
+then the new derived class can be used as a drop-in replacement for the
+old one. This means you should be able to write a program like this:
+
+ use Employee;
+ my $empl = Employee->new();
+ $empl->name("Jason");
+ $empl->age(23);
+ printf "%s is age %d.\n", $empl->name, $empl->age;
+
+By proper design, we mean always using the two-argument form of bless(),
+avoiding direct access of global data, and not exporting anything. If you
+look back at the Person::new() function we defined above, we were careful
+to do that. There's a bit of package data used in the constructor,
+but the reference to this is stored on the object itself and all other
+methods access package data via that reference, so we should be ok.
+
+What do we mean by the Person::new() function -- isn't that actually
+a method? Well, in principle, yes. A method is just a function that
+expects as its first argument a class name (package) or object
+(blessed reference). Person::new() is the function that both the
+C<Person-E<gt>new()> method and the C<Employee-E<gt>new()> method end
+up calling. Understand that while a method call looks a lot like a
+function call, they aren't really quite the same, and if you treat them
+as the same, you'll very soon be left with nothing but broken programs.
+First, the actual underlying calling conventions are different: method
+calls get an extra argument. Second, function calls don't do inheritance,
+but methods do.
+
+ Method Call Resulting Function Call
+ ----------- ------------------------
+ Person->new() Person::new("Person")
+ Employee->new() Person::new("Employee")
+
+So don't use function calls when you mean to call a method.
+
+If an employee is just a Person, that's not all too very interesting.
+So let's add some other methods. We'll give our employee
+data fields to access their salary, their employee ID, and their
+start date.
+
+If you're getting a little tired of creating all these nearly identical
+methods just to get at the object's data, do not despair. Later,
+we'll describe several different convenience mechanisms for shortening
+this up. Meanwhile, here's the straight-forward way:
+
+ sub salary {
+ my $self = shift;
+ if (@_) { $self->{SALARY} = shift }
+ return $self->{SALARY};
+ }
+
+ sub id_number {
+ my $self = shift;
+ if (@_) { $self->{ID} = shift }
+ return $self->{ID};
+ }
+
+ sub start_date {
+ my $self = shift;
+ if (@_) { $self->{START_DATE} = shift }
+ return $self->{START_DATE};
+ }
+
+=head2 Overridden Methods
+
+What happens when both a derived class and its base class have the same
+method defined? Well, then you get the derived class's version of that
+method. For example, let's say that we want the peers() method called on
+an employee to act a bit differently. Instead of just returning the list
+of peer names, let's return slightly different strings. So doing this:
+
+ $empl->peers("Peter", "Paul", "Mary");
+ printf "His peers are: %s\n", join(", ", $empl->peers);
+
+will produce:
+
+ His peers are: PEON=PETER, PEON=PAUL, PEON=MARY
+
+To do this, merely add this definition into the Employee.pm file:
+
+ sub peers {
+ my $self = shift;
+ if (@_) { @{ $self->{PEERS} } = @_ }
+ return map { "PEON=\U$_" } @{ $self->{PEERS} };
+ }
+
+There, we've just demonstrated the high-falutin' concept known in certain
+circles as I<polymorphism>. We've taken on the form and behaviour of
+an existing object, and then we've altered it to suit our own purposes.
+This is a form of Laziness. (Getting polymorphed is also what happens
+when the wizard decides you'd look better as a frog.)
+
+Every now and then you'll want to have a method call trigger both its
+derived class (also known as "subclass") version as well as its base class
+(also known as "superclass") version. In practice, constructors and
+destructors are likely to want to do this, and it probably also makes
+sense in the debug() method we showed previously.
+
+To do this, add this to Employee.pm:
+
+ use Carp;
+ my $Debugging = 0;
+
+ sub debug {
+ my $self = shift;
+ confess "usage: thing->debug(level)" unless @_ == 1;
+ my $level = shift;
+ if (ref($self)) {
+ $self->{"_DEBUG"} = $level;
+ } else {
+ $Debugging = $level; # whole class
+ }
+ Person::debug($self, $Debugging); # don't really do this
+ }
+
+As you see, we turn around and call the Person package's debug() function.
+But this is far too fragile for good design. What if Person doesn't
+have a debug() function, but is inheriting I<its> debug() method
+from elsewhere? It would have been slightly better to say
+
+ Person->debug($Debugging);
+
+But even that's got too much hard-coded. It's somewhat better to say
+
+ $self->Person::debug($Debugging);
+
+Which is a funny way to say to start looking for a debug() method up
+in Person. This strategy is more often seen on overridden object methods
+than on overridden class methods.
+
+There is still something a bit off here. We've hard-coded our
+superclass's name. This in particular is bad if you change which classes
+you inherit from, or add others. Fortunately, the pseudoclass SUPER
+comes to the rescue here.
+
+ $self->SUPER::debug($Debugging);
+
+This way it starts looking in my class's @ISA. This only makes sense
+from I<within> a method call, though. Don't try to access anything
+in SUPER:: from anywhere else, because it doesn't exist outside
+an overridden method call.
+
+Things are getting a bit complicated here. Have we done anything
+we shouldn't? As before, one way to test whether we're designing
+a decent class is via the empty subclass test. Since we already have
+an Employee class that we're trying to check, we'd better get a new
+empty subclass that can derive from Employee. Here's one:
+
+ package Boss;
+ use Employee; # :-)
+ @ISA = qw(Employee);
+
+And here's the test program:
+
+ #!/usr/bin/perl -w
+ use strict;
+ use Boss;
+ Boss->debug(1);
+
+ my $boss = Boss->new();
+
+ $boss->fullname->title("Don");
+ $boss->fullname->surname("Pichon Alvarez");
+ $boss->fullname->christian("Federico Jesus");
+ $boss->fullname->nickname("Fred");
+
+ $boss->age(47);
+ $boss->peers("Frank", "Felipe", "Faust");
+
+ printf "%s is age %d.\n", $boss->fullname, $boss->age;
+ printf "His peers are: %s\n", join(", ", $boss->peers);
+
+Running it, we see that we're still ok. If you'd like to dump out your
+object in a nice format, somewhat like the way the 'x' command works in
+the debugger, you could use the Data::Dumper module from CPAN this way:
+
+ use Data::Dumper;
+ print "Here's the boss:\n";
+ print Dumper($boss);
+
+Which shows us something like this:
+
+ Here's the boss:
+ $VAR1 = bless( {
+ _CENSUS => \1,
+ FULLNAME => bless( {
+ TITLE => 'Don',
+ SURNAME => 'Pichon Alvarez',
+ NICK => 'Fred',
+ CHRISTIAN => 'Federico Jesus'
+ }, 'Fullname' ),
+ AGE => 47,
+ PEERS => [
+ 'Frank',
+ 'Felipe',
+ 'Faust'
+ ]
+ }, 'Boss' );
+
+Hm.... something's missing there. What about the salary, start date,
+and ID fields? Well, we never set them to anything, even undef, so they
+don't show up in the hash's keys. The Employee class has no new() method
+of its own, and the new() method in Person doesn't know about Employees.
+(Nor should it: proper OO design dictates that a subclass be allowed to
+know about its immediate superclass, but never vice-versa.) So let's
+fix up Employee::new() this way:
+
+ sub new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ $self->{SALARY} = undef;
+ $self->{ID} = undef;
+ $self->{START_DATE} = undef;
+ bless ($self, $class); # reconsecrate
+ return $self;
+ }
+
+Now if you dump out an Employee or Boss object, you'll find
+that new fields show up there now.
+
+=head2 Multiple Inheritance
+
+Ok, at the risk of confusing beginners and annoying OO gurus, it's
+time to confess that Perl's object system includes that controversial
+notion known as multiple inheritance, or MI for short. All this means
+is that rather than having just one parent class who in turn might
+itself have a parent class, etc., that you can directly inherit from
+two or more parents. It's true that some uses of MI can get you into
+trouble, although hopefully not quite so much trouble with Perl as with
+dubiously-OO languages like C++.
+
+The way it works is actually pretty simple: just put more than one package
+name in your @ISA array. When it comes time for Perl to go finding
+methods for your object, it looks at each of these packages in order.
+Well, kinda. It's actually a fully recursive, depth-first order.
+Consider a bunch of @ISA arrays like this:
+
+ @First::ISA = qw( Alpha );
+ @Second::ISA = qw( Beta );
+ @Third::ISA = qw( First Second );
+
+If you have an object of class Third:
+
+ my $ob = Third->new();
+ $ob->spin();
+
+How do we find a spin() method (or a new() method for that matter)?
+Because the search is depth-first, classes will be looked up
+in the following order: Third, First, Alpha, Second, and Beta.
+
+In practice, few class modules have been seen that actually
+make use of MI. One nearly always chooses simple containership of
+one class within another over MI. That's why our Person
+object I<contained> a Fullname object. That doesn't mean
+it I<was> one.
+
+However, there is one particular area where MI in Perl is rampant:
+borrowing another class's class methods. This is rather common,
+especially with some bundled "objectless" classes,
+like Exporter, DynaLoader, AutoLoader, and SelfLoader. These classes
+do not provide constructors; they exist only so you may inherit their
+class methods. (It's not entirely clear why inheritance was done
+here rather than traditional module importation.)
+
+For example, here is the POSIX module's @ISA:
+
+ package POSIX;
+ @ISA = qw(Exporter DynaLoader);
+
+The POSIX module isn't really an object module, but then,
+neither are Exporter or DynaLoader. They're just lending their
+classes' behaviours to POSIX.
+
+Why don't people use MI for object methods much? One reason is that
+it can have complicated side-effects. For one thing, your inheritance
+graph (no longer a tree) might converge back to the same base class.
+Although Perl guards against recursive inheritance, merely having parents
+who are related to each other via a common ancestor, incestuous though
+it sounds, is not forbidden. What if in our Third class shown above we
+wanted its new() method to also call both overridden constructors in its
+two parent classes? The SUPER notation would only find the first one.
+Also, what about if the Alpha and Beta classes both had a common ancestor,
+like Nought? If you kept climbing up the inheritance tree calling
+overridden methods, you'd end up calling Nought::new() twice,
+which might well be a bad idea.
+
+=head2 UNIVERSAL: The Root of All Objects
+
+Wouldn't it be convenient if all objects were rooted at some ultimate
+base class? That way you could give every object common methods without
+having to go and add it to each and every @ISA. Well, it turns out that
+you can. You don't see it, but Perl tacitly and irrevocably assumes
+that there's an extra element at the end of @ISA: the class UNIVERSAL.
+In version 5.003, there were no predefined methods there, but you could put
+whatever you felt like into it.
+
+However, as of version 5.004 (or some subversive releases, like 5.003_08),
+UNIVERSAL has some methods in it already. These are builtin to your Perl
+binary, so they don't take any extra time to load. Predefined methods
+include isa(), can(), and VERSION(). isa() tells you whether an object or
+class "is" another one without having to traverse the hierarchy yourself:
+
+ $has_io = $fd->isa("IO::Handle");
+ $itza_handle = IO::Socket->isa("IO::Handle");
+
+The can() method, called against that object or class, reports back
+whether its string argument is a callable method name in that class.
+In fact, it gives you back a function reference to that method:
+
+ $his_print_method = $obj->can('as_string');
+
+Finally, the VERSION method checks whether the class (or the object's
+class) has a package global called $VERSION that's high enough, as in:
+
+ Some_Module->VERSION(3.0);
+ $his_vers = $ob->VERSION();
+
+However, we don't usually call VERSION ourselves. (Remember that an all
+uppercase function name is a Perl convention that indicates that the
+function will be automatically used by Perl in some way.) In this case,
+it happens when you say
+
+ use Some_Module 3.0;
+
+If you wanted to add version checking to your Person class explained
+above, just add this to Person.pm:
+
+ use vars qw($VERSION);
+ $VERSION = '1.1';
+
+and then in Employee.pm could you can say
+
+ use Employee 1.1;
+
+And it would make sure that you have at least that version number or
+higher available. This is not the same as loading in that exact version
+number. No mechanism currently exists for concurrent installation of
+multiple versions of a module. Lamentably.
+
+=head1 Alternate Object Representations
+
+Nothing requires objects to be implemented as hash references. An object
+can be any sort of reference so long as its referent has been suitably
+blessed. That means scalar, array, and code references are also fair
+game.
+
+A scalar would work if the object has only one datum to hold. An array
+would work for most cases, but makes inheritance a bit dodgy because
+you have to invent new indices for the derived classes.
+
+=head2 Arrays as Objects
+
+If the user of your class honors the contract and sticks to the advertised
+interface, then you can change its underlying interface if you feel
+like it. Here's another implementation that conforms to the same
+interface specification. This time we'll use an array reference
+instead of a hash reference to represent the object.
+
+ package Person;
+ use strict;
+
+ my($NAME, $AGE, $PEERS) = ( 0 .. 2 );
+
+ ############################################
+ ## the object constructor (array version) ##
+ ############################################
+ sub new {
+ my $self = [];
+ $self->[$NAME] = undef; # this is unnecessary
+ $self->[$AGE] = undef; # as is this
+ $self->[$PEERS] = []; # but this isn't, really
+ bless($self);
+ return $self;
+ }
+
+ sub name {
+ my $self = shift;
+ if (@_) { $self->[$NAME] = shift }
+ return $self->[$NAME];
+ }
+
+ sub age {
+ my $self = shift;
+ if (@_) { $self->[$AGE] = shift }
+ return $self->[$AGE];
+ }
+
+ sub peers {
+ my $self = shift;
+ if (@_) { @{ $self->[$PEERS] } = @_ }
+ return @{ $self->[$PEERS] };
+ }
+
+ 1; # so the require or use succeeds
+
+You might guess that the array access would be a lot faster than the
+hash access, but they're actually comparable. The array is a I<little>
+bit faster, but not more than ten or fifteen percent, even when you
+replace the variables above like $AGE with literal numbers, like 1.
+A bigger difference between the two approaches can be found in memory use.
+A hash representation takes up more memory than an array representation
+because you have to allocate memory for the keys as well as for the values.
+However, it really isn't that bad, especially since as of version 5.004,
+memory is only allocated once for a given hash key, no matter how many
+hashes have that key. It's expected that sometime in the future, even
+these differences will fade into obscurity as more efficient underlying
+representations are devised.
+
+Still, the tiny edge in speed (and somewhat larger one in memory)
+is enough to make some programmers choose an array representation
+for simple classes. There's still a little problem with
+scalability, though, because later in life when you feel
+like creating subclasses, you'll find that hashes just work
+out better.
+
+=head2 Closures as Objects
+
+Using a code reference to represent an object offers some fascinating
+possibilities. We can create a new anonymous function (closure) who
+alone in all the world can see the object's data. This is because we
+put the data into an anonymous hash that's lexically visible only to
+the closure we create, bless, and return as the object. This object's
+methods turn around and call the closure as a regular subroutine call,
+passing it the field we want to affect. (Yes,
+the double-function call is slow, but if you wanted fast, you wouldn't
+be using objects at all, eh? :-)
+
+Use would be similar to before:
+
+ use Person;
+ $him = Person->new();
+ $him->name("Jason");
+ $him->age(23);
+ $him->peers( [ "Norbert", "Rhys", "Phineas" ] );
+ printf "%s is %d years old.\n", $him->name, $him->age;
+ print "His peers are: ", join(", ", @{$him->peers}), "\n";
+
+but the implementation would be radically, perhaps even sublimely
+different:
+
+ package Person;
+
+ sub new {
+ my $that = shift;
+ my $class = ref($that) || $that;
+ my $self = {
+ NAME => undef,
+ AGE => undef,
+ PEERS => [],
+ };
+ my $closure = sub {
+ my $field = shift;
+ if (@_) { $self->{$field} = shift }
+ return $self->{$field};
+ };
+ bless($closure, $class);
+ return $closure;
+ }
+
+ sub name { &{ $_[0] }("NAME", @_[ 1 .. $#_ ] ) }
+ sub age { &{ $_[0] }("AGE", @_[ 1 .. $#_ ] ) }
+ sub peers { &{ $_[0] }("PEERS", @_[ 1 .. $#_ ] ) }
+
+ 1;
+
+Because this object is hidden behind a code reference, it's probably a bit
+mysterious to those whose background is more firmly rooted in standard
+procedural or object-based programming languages than in functional
+programming languages whence closures derive. The object
+created and returned by the new() method is itself not a data reference
+as we've seen before. It's an anonymous code reference that has within
+it access to a specific version (lexical binding and instantiation)
+of the object's data, which are stored in the private variable $self.
+Although this is the same function each time, it contains a different
+version of $self.
+
+When a method like C<$him-E<gt>name("Jason")> is called, its implicit
+zeroth argument is the invoking object--just as it is with all method
+calls. But in this case, it's our code reference (something like a
+function pointer in C++, but with deep binding of lexical variables).
+There's not a lot to be done with a code reference beyond calling it, so
+that's just what we do when we say C<&{$_[0]}>. This is just a regular
+function call, not a method call. The initial argument is the string
+"NAME", and any remaining arguments are whatever had been passed to the
+method itself.
+
+Once we're executing inside the closure that had been created in new(),
+the $self hash reference suddenly becomes visible. The closure grabs
+its first argument ("NAME" in this case because that's what the name()
+method passed it), and uses that string to subscript into the private
+hash hidden in its unique version of $self.
+
+Nothing under the sun will allow anyone outside the executing method to
+be able to get at this hidden data. Well, nearly nothing. You I<could>
+single step through the program using the debugger and find out the
+pieces while you're in the method, but everyone else is out of luck.
+
+There, if that doesn't excite the Scheme folks, then I just don't know
+what will. Translation of this technique into C++, Java, or any other
+braindead-static language is left as a futile exercise for aficionados
+of those camps.
+
+You could even add a bit of nosiness via the caller() function and
+make the closure refuse to operate unless called via its own package.
+This would no doubt satisfy certain fastidious concerns of programming
+police and related puritans.
+
+If you were wondering when Hubris, the third principle virtue of a
+programmer, would come into play, here you have it. (More seriously,
+Hubris is just the pride in craftsmanship that comes from having written
+a sound bit of well-designed code.)
+
+=head1 AUTOLOAD: Proxy Methods
+
+Autoloading is a way to intercept calls to undefined methods. An autoload
+routine may choose to create a new function on the fly, either loaded
+from disk or perhaps just eval()ed right there. This define-on-the-fly
+strategy is why it's called autoloading.
+
+But that's only one possible approach. Another one is to just
+have the autoloaded method itself directly provide the
+requested service. When used in this way, you may think
+of autoloaded methods as "proxy" methods.
+
+When Perl tries to call an undefined function in a particular package
+and that function is not defined, it looks for a function in
+that same package called AUTOLOAD. If one exists, it's called
+with the same arguments as the original function would have had.
+The fully-qualified name of the function is stored in that package's
+global variable $AUTOLOAD. Once called, the function can do anything
+it would like, including defining a new function by the right name, and
+then doing a really fancy kind of C<goto> right to it, erasing itself
+from the call stack.
+
+What does this have to do with objects? After all, we keep talking about
+functions, not methods. Well, since a method is just a function with
+an extra argument and some fancier semantics about where it's found,
+we can use autoloading for methods, too. Perl doesn't start looking
+for an AUTOLOAD method until it has exhausted the recursive hunt up
+through @ISA, though. Some programmers have even been known to define
+a UNIVERSAL::AUTOLOAD method to trap unresolved method calls to any
+kind of object.
+
+=head2 Autoloaded Data Methods
+
+You probably began to get a little suspicious about the duplicated
+code way back earlier when we first showed you the Person class, and
+then later the Employee class. Each method used to access the
+hash fields looked virtually identical. This should have tickled
+that great programming virtue, Impatience, but for the time,
+we let Laziness win out, and so did nothing. Proxy methods can cure
+this.
+
+Instead of writing a new function every time we want a new data field,
+we'll use the autoload mechanism to generate (actually, mimic) methods on
+the fly. To verify that we're accessing a valid member, we will check
+against an C<_permitted> (pronounced "under-permitted") field, which
+is a reference to a file-scoped lexical (like a C file static) hash of permitted fields in this record
+called %fields. Why the underscore? For the same reason as the _CENSUS
+field we once used: as a marker that means "for internal use only".
+
+Here's what the module initialization code and class
+constructor will look like when taking this approach:
+
+ package Person;
+ use Carp;
+ use vars qw($AUTOLOAD); # it's a package global
+
+ my %fields = (
+ name => undef,
+ age => undef,
+ peers => undef,
+ );
+
+ sub new {
+ my $that = shift;
+ my $class = ref($that) || $that;
+ my $self = {
+ _permitted => \%fields,
+ %fields,
+ };
+ bless $self, $class;
+ return $self;
+ }
+
+If we wanted our record to have default values, we could fill those in
+where current we have C<undef> in the %fields hash.
+
+Notice how we saved a reference to our class data on the object itself?
+Remember that it's important to access class data through the object
+itself instead of having any method reference %fields directly, or else
+you won't have a decent inheritance.
+
+The real magic, though, is going to reside in our proxy method, which
+will handle all calls to undefined methods for objects of class Person
+(or subclasses of Person). It has to be called AUTOLOAD. Again, it's
+all caps because it's called for us implicitly by Perl itself, not by
+a user directly.
+
+ sub AUTOLOAD {
+ my $self = shift;
+ my $type = ref($self)
+ or croak "$self is not an object";
+
+ my $name = $AUTOLOAD;
+ $name =~ s/.*://; # strip fully-qualified portion
+
+ unless (exists $self->{_permitted}->{$name} ) {
+ croak "Can't access `$name' field in class $type";
+ }
+
+ if (@_) {
+ return $self->{$name} = shift;
+ } else {
+ return $self->{$name};
+ }
+ }
+
+Pretty nifty, eh? All we have to do to add new data fields
+is modify %fields. No new functions need be written.
+
+I could have avoided the C<_permitted> field entirely, but I
+wanted to demonstrate how to store a reference to class data on the
+object so you wouldn't have to access that class data
+directly from an object method.
+
+=head2 Inherited Autoloaded Data Methods
+
+But what about inheritance? Can we define our Employee
+class similarly? Yes, so long as we're careful enough.
+
+Here's how to be careful:
+
+ package Employee;
+ use Person;
+ use strict;
+ use vars qw(@ISA);
+ @ISA = qw(Person);
+
+ my %fields = (
+ id => undef,
+ salary => undef,
+ );
+
+ sub new {
+ my $that = shift;
+ my $class = ref($that) || $that;
+ my $self = bless $that->SUPER::new(), $class;
+ my($element);
+ foreach $element (keys %fields) {
+ $self->{_permitted}->{$element} = $fields{$element};
+ }
+ @{$self}{keys %fields} = values %fields;
+ return $self;
+ }
+
+Once we've done this, we don't even need to have an
+AUTOLOAD function in the Employee package, because
+we'll grab Person's version of that via inheritance,
+and it will all work out just fine.
+
+=head1 Metaclassical Tools
+
+Even though proxy methods can provide a more convenient approach to making
+more struct-like classes than tediously coding up data methods as
+functions, it still leaves a bit to be desired. For one thing, it means
+you have to handle bogus calls that you don't mean to trap via your proxy.
+It also means you have to be quite careful when dealing with inheritance,
+as detailed above.
+
+Perl programmers have responded to this by creating several different
+class construction classes. These metaclasses are classes
+that create other classes. A couple worth looking at are
+Class::Struct and Alias. These and other related metaclasses can be
+found in the modules directory on CPAN.
+
+=head2 Class::Struct
+
+One of the older ones is Class::Struct. In fact, its syntax and
+interface were sketched out long before perl5 even solidified into a
+real thing. What it does is provide you a way to "declare" a class
+as having objects whose fields are of a specific type. The function
+that does this is called, not surprisingly enough, struct(). Because
+structures or records are not base types in Perl, each time you want to
+create a class to provide a record-like data object, you yourself have
+to define a new() method, plus separate data-access methods for each of
+that record's fields. You'll quickly become bored with this process.
+The Class::Struct::struct() function alleviates this tedium.
+
+Here's a simple example of using it:
+
+ use Class::Struct qw(struct);
+ use Jobbie; # user-defined; see below
+
+ struct 'Fred' => {
+ one => '$',
+ many => '@',
+ profession => Jobbie, # calls Jobbie->new()
+ };
+
+ $ob = Fred->new;
+ $ob->one("hmmmm");
+
+ $ob->many(0, "here");
+ $ob->many(1, "you");
+ $ob->many(2, "go");
+ print "Just set: ", $ob->many(2), "\n";
+
+ $ob->profession->salary(10_000);
+
+You can declare types in the struct to be basic Perl types, or
+user-defined types (classes). User types will be initialized by calling
+that class's new() method.
+
+Here's a real-world example of using struct generation. Let's say you
+wanted to override Perl's idea of gethostbyname() and gethostbyaddr() so
+that they would return objects that acted like C structures. We don't
+care about high-falutin' OO gunk. All we want is for these objects to
+act like structs in the C sense.
+
+ use Socket;
+ use Net::hostent;
+ $h = gethostbyname("perl.com"); # object return
+ printf "perl.com's real name is %s, address %s\n",
+ $h->name, inet_ntoa($h->addr);
+
+Here's how to do this using the Class::Struct module.
+The crux is going to be this call:
+
+ struct 'Net::hostent' => [ # note bracket
+ name => '$',
+ aliases => '@',
+ addrtype => '$',
+ 'length' => '$',
+ addr_list => '@',
+ ];
+
+Which creates object methods of those names and types.
+It even creates a new() method for us.
+
+We could also have implemented our object this way:
+
+ struct 'Net::hostent' => { # note brace
+ name => '$',
+ aliases => '@',
+ addrtype => '$',
+ 'length' => '$',
+ addr_list => '@',
+ };
+
+and then Class::Struct would have used an anonymous hash as the object
+type, instead of an anonymous array. The array is faster and smaller,
+but the hash works out better if you eventually want to do inheritance.
+Since for this struct-like object we aren't planning on inheritance,
+this time we'll opt for better speed and size over better flexibility.
+
+Here's the whole implementation:
+
+ package Net::hostent;
+ use strict;
+
+ BEGIN {
+ use Exporter ();
+ use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS);
+ @EXPORT = qw(gethostbyname gethostbyaddr gethost);
+ @EXPORT_OK = qw(
+ $h_name @h_aliases
+ $h_addrtype $h_length
+ @h_addr_list $h_addr
+ );
+ %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] );
+ }
+ use vars @EXPORT_OK;
+
+ # Class::Struct forbids use of @ISA
+ sub import { goto &Exporter::import }
+
+ use Class::Struct qw(struct);
+ struct 'Net::hostent' => [
+ name => '$',
+ aliases => '@',
+ addrtype => '$',
+ 'length' => '$',
+ addr_list => '@',
+ ];
+
+ sub addr { shift->addr_list->[0] }
+
+ sub populate (@) {
+ return unless @_;
+ my $hob = new(); # Class::Struct made this!
+ $h_name = $hob->[0] = $_[0];
+ @h_aliases = @{ $hob->[1] } = split ' ', $_[1];
+ $h_addrtype = $hob->[2] = $_[2];
+ $h_length = $hob->[3] = $_[3];
+ $h_addr = $_[4];
+ @h_addr_list = @{ $hob->[4] } = @_[ (4 .. $#_) ];
+ return $hob;
+ }
+
+ sub gethostbyname ($) { populate(CORE::gethostbyname(shift)) }
+
+ sub gethostbyaddr ($;$) {
+ my ($addr, $addrtype);
+ $addr = shift;
+ require Socket unless @_;
+ $addrtype = @_ ? shift : Socket::AF_INET();
+ populate(CORE::gethostbyaddr($addr, $addrtype))
+ }
+
+ sub gethost($) {
+ if ($_[0] =~ /^\d+(?:\.\d+(?:\.\d+(?:\.\d+)?)?)?$/) {
+ require Socket;
+ &gethostbyaddr(Socket::inet_aton(shift));
+ } else {
+ &gethostbyname;
+ }
+ }
+
+ 1;
+
+We've snuck in quite a fair bit of other concepts besides just dynamic
+class creation, like overriding core functions, import/export bits,
+function prototyping, short-cut function call via C<&whatever>, and
+function replacement with C<goto &whatever>. These all mostly make
+sense from the perspective of a traditional module, but as you can see,
+we can also use them in an object module.
+
+You can look at other object-based, struct-like overrides of core
+functions in the 5.004 release of Perl in File::stat, Net::hostent,
+Net::netent, Net::protoent, Net::servent, Time::gmtime, Time::localtime,
+User::grent, and User::pwent. These modules have a final component
+that's all lowercase, by convention reserved for compiler pragmas,
+because they affect the compilation and change a builtin function.
+They also have the type names that a C programmer would most expect.
+
+=head2 Data Members as Variables
+
+If you're used to C++ objects, then you're accustomed to being able to
+get at an object's data members as simple variables from within a method.
+The Alias module provides for this, as well as a good bit more, such
+as the possibility of private methods that the object can call but folks
+outside the class cannot.
+
+Here's an example of creating a Person using the Alias module.
+When you update these magical instance variables, you automatically
+update value fields in the hash. Convenient, eh?
+
+ package Person;
+
+ # this is the same as before...
+ sub new {
+ my $that = shift;
+ my $class = ref($that) || $that;
+ my $self = {
+ NAME => undef,
+ AGE => undef,
+ PEERS => [],
+ };
+ bless($self, $class);
+ return $self;
+ }
+
+ use Alias qw(attr);
+ use vars qw($NAME $AGE $PEERS);
+
+ sub name {
+ my $self = attr shift;
+ if (@_) { $NAME = shift; }
+ return $NAME;
+ }
+
+ sub age {
+ my $self = attr shift;
+ if (@_) { $AGE = shift; }
+ return $AGE;
+ }
+
+ sub peers {
+ my $self = attr shift;
+ if (@_) { @PEERS = @_; }
+ return @PEERS;
+ }
+
+ sub exclaim {
+ my $self = attr shift;
+ return sprintf "Hi, I'm %s, age %d, working with %s",
+ $NAME, $AGE, join(", ", @PEERS);
+ }
+
+ sub happy_birthday {
+ my $self = attr shift;
+ return ++$AGE;
+ }
+
+The need for the C<use vars> declaration is because what Alias does
+is play with package globals with the same name as the fields. To use
+globals while C<use strict> is in effect, you have to predeclare them.
+These package variables are localized to the block enclosing the attr()
+call just as if you'd used a local() on them. However, that means that
+they're still considered global variables with temporary values, just
+as with any other local().
+
+It would be nice to combine Alias with
+something like Class::Struct or Class::MethodMaker.
+
+=head2 NOTES
+
+=head2 Object Terminology
+
+In the various OO literature, it seems that a lot of different words
+are used to describe only a few different concepts. If you're not
+already an object programmer, then you don't need to worry about all
+these fancy words. But if you are, then you might like to know how to
+get at the same concepts in Perl.
+
+For example, it's common to call an object an I<instance> of a class
+and to call those objects' methods I<instance methods>. Data fields
+peculiar to each object are often called I<instance data> or I<object
+attributes>, and data fields common to all members of that class are
+I<class data>, I<class attributes>, or I<static data members>.
+
+Also, I<base class>, I<generic class>, and I<superclass> all describe
+the same notion, whereas I<derived class>, I<specific class>, and
+I<subclass> describe the other related one.
+
+C++ programmers have I<static methods> and I<virtual methods>,
+but Perl only has I<class methods> and I<object methods>.
+Actually, Perl only has methods. Whether a method gets used
+as a class or object method is by usage only. You could accidentally
+call a class method (one expecting a string argument) on an
+object (one expecting a reference), or vice versa.
+
+Z<>From the C++ perspective, all methods in Perl are virtual.
+This, by the way, is why they are never checked for function
+prototypes in the argument list as regular builtin and user-defined
+functions can be.
+
+Because a class is itself something of an object, Perl's classes can be
+taken as describing both a "class as meta-object" (also called I<object
+factory>) philosophy and the "class as type definition" (I<declaring>
+behaviour, not I<defining> mechanism) idea. C++ supports the latter
+notion, but not the former.
+
+=head1 SEE ALSO
+
+The following manpages will doubtless provide more
+background for this one:
+L<perlmod>,
+L<perlref>,
+L<perlobj>,
+L<perlbot>,
+L<perltie>,
+and
+L<overload>.
+
+=head1 AUTHOR AND COPYRIGHT
+
+Copyright (c) 1997, 1998 Tom Christiansen
+All rights reserved.
+
+When included as part of the Standard Version of Perl, or as part of
+its complete documentation whether printed or otherwise, this work
+may be distributed only under the terms of Perl's Artistic License.
+Any distribution of this file or derivatives thereof I<outside>
+of that package require that special arrangements be made with
+copyright holder.
+
+Irrespective of its distribution, all code examples in this file
+are hereby placed into the public domain. You are permitted and
+encouraged to use this code in your own programs for fun
+or for profit as you see fit. A simple comment in the code giving
+credit would be courteous but is not required.
+
+=head1 COPYRIGHT
+
+=head2 Acknowledgments
+
+Thanks to
+Larry Wall,
+Roderick Schertler,
+Gurusamy Sarathy,
+Dean Roehrich,
+Raphael Manfredi,
+Brent Halsey,
+Greg Bacon,
+Brad Appleton,
+and many others for their helpful comments.
diff --git a/contrib/perl5/pod/perltrap.pod b/contrib/perl5/pod/perltrap.pod
new file mode 100644
index 0000000..852d8e9
--- /dev/null
+++ b/contrib/perl5/pod/perltrap.pod
@@ -0,0 +1,1505 @@
+=head1 NAME
+
+perltrap - Perl traps for the unwary
+
+=head1 DESCRIPTION
+
+The biggest trap of all is forgetting to use the B<-w> switch; see
+L<perlrun>. The second biggest trap is not making your entire program
+runnable under C<use strict>. The third biggest trap is not reading
+the list of changes in this version of Perl; see L<perldelta>.
+
+=head2 Awk Traps
+
+Accustomed B<awk> users should take special note of the following:
+
+=over 4
+
+=item *
+
+The English module, loaded via
+
+ use English;
+
+allows you to refer to special variables (like C<$/>) with names (like
+C<$RS>), as though they were in B<awk>; see L<perlvar> for details.
+
+=item *
+
+Semicolons are required after all simple statements in Perl (except
+at the end of a block). Newline is not a statement delimiter.
+
+=item *
+
+Curly brackets are required on C<if>s and C<while>s.
+
+=item *
+
+Variables begin with "$", "@" or "%" in Perl.
+
+=item *
+
+Arrays index from 0. Likewise string positions in substr() and
+index().
+
+=item *
+
+You have to decide whether your array has numeric or string indices.
+
+=item *
+
+Hash values do not spring into existence upon mere reference.
+
+=item *
+
+You have to decide whether you want to use string or numeric
+comparisons.
+
+=item *
+
+Reading an input line does not split it for you. You get to split it
+to an array yourself. And the split() operator has different
+arguments than B<awk>'s.
+
+=item *
+
+The current input line is normally in $_, not $0. It generally does
+not have the newline stripped. ($0 is the name of the program
+executed.) See L<perlvar>.
+
+=item *
+
+$E<lt>I<digit>E<gt> does not refer to fields--it refers to substrings matched
+by the last match pattern.
+
+=item *
+
+The print() statement does not add field and record separators unless
+you set C<$,> and C<$\>. You can set $OFS and $ORS if you're using
+the English module.
+
+=item *
+
+You must open your files before you print to them.
+
+=item *
+
+The range operator is "..", not comma. The comma operator works as in
+C.
+
+=item *
+
+The match operator is "=~", not "~". ("~" is the one's complement
+operator, as in C.)
+
+=item *
+
+The exponentiation operator is "**", not "^". "^" is the XOR
+operator, as in C. (You know, one could get the feeling that B<awk> is
+basically incompatible with C.)
+
+=item *
+
+The concatenation operator is ".", not the null string. (Using the
+null string would render C</pat/ /pat/> unparsable, because the third slash
+would be interpreted as a division operator--the tokenizer is in fact
+slightly context sensitive for operators like "/", "?", and "E<gt>".
+And in fact, "." itself can be the beginning of a number.)
+
+=item *
+
+The C<next>, C<exit>, and C<continue> keywords work differently.
+
+=item *
+
+
+The following variables work differently:
+
+ Awk Perl
+ ARGC $#ARGV or scalar @ARGV
+ ARGV[0] $0
+ FILENAME $ARGV
+ FNR $. - something
+ FS (whatever you like)
+ NF $#Fld, or some such
+ NR $.
+ OFMT $#
+ OFS $,
+ ORS $\
+ RLENGTH length($&)
+ RS $/
+ RSTART length($`)
+ SUBSEP $;
+
+=item *
+
+You cannot set $RS to a pattern, only a string.
+
+=item *
+
+When in doubt, run the B<awk> construct through B<a2p> and see what it
+gives you.
+
+=back
+
+=head2 C Traps
+
+Cerebral C programmers should take note of the following:
+
+=over 4
+
+=item *
+
+Curly brackets are required on C<if>'s and C<while>'s.
+
+=item *
+
+You must use C<elsif> rather than C<else if>.
+
+=item *
+
+The C<break> and C<continue> keywords from C become in
+Perl C<last> and C<next>, respectively.
+Unlike in C, these do I<NOT> work within a C<do { } while> construct.
+
+=item *
+
+There's no switch statement. (But it's easy to build one on the fly.)
+
+=item *
+
+Variables begin with "$", "@" or "%" in Perl.
+
+=item *
+
+C<printf()> does not implement the "*" format for interpolating
+field widths, but it's trivial to use interpolation of double-quoted
+strings to achieve the same effect.
+
+=item *
+
+Comments begin with "#", not "/*".
+
+=item *
+
+You can't take the address of anything, although a similar operator
+in Perl is the backslash, which creates a reference.
+
+=item *
+
+C<ARGV> must be capitalized. C<$ARGV[0]> is C's C<argv[1]>, and C<argv[0]>
+ends up in C<$0>.
+
+=item *
+
+System calls such as link(), unlink(), rename(), etc. return nonzero for
+success, not 0.
+
+=item *
+
+Signal handlers deal with signal names, not numbers. Use C<kill -l>
+to find their names on your system.
+
+=back
+
+=head2 Sed Traps
+
+Seasoned B<sed> programmers should take note of the following:
+
+=over 4
+
+=item *
+
+Backreferences in substitutions use "$" rather than "\".
+
+=item *
+
+The pattern matching metacharacters "(", ")", and "|" do not have backslashes
+in front.
+
+=item *
+
+The range operator is C<...>, rather than comma.
+
+=back
+
+=head2 Shell Traps
+
+Sharp shell programmers should take note of the following:
+
+=over 4
+
+=item *
+
+The backtick operator does variable interpolation without regard to
+the presence of single quotes in the command.
+
+=item *
+
+The backtick operator does no translation of the return value, unlike B<csh>.
+
+=item *
+
+Shells (especially B<csh>) do several levels of substitution on each
+command line. Perl does substitution in only certain constructs
+such as double quotes, backticks, angle brackets, and search patterns.
+
+=item *
+
+Shells interpret scripts a little bit at a time. Perl compiles the
+entire program before executing it (except for C<BEGIN> blocks, which
+execute at compile time).
+
+=item *
+
+The arguments are available via @ARGV, not $1, $2, etc.
+
+=item *
+
+The environment is not automatically made available as separate scalar
+variables.
+
+=back
+
+=head2 Perl Traps
+
+Practicing Perl Programmers should take note of the following:
+
+=over 4
+
+=item *
+
+Remember that many operations behave differently in a list
+context than they do in a scalar one. See L<perldata> for details.
+
+=item *
+
+Avoid barewords if you can, especially all lowercase ones.
+You can't tell by just looking at it whether a bareword is
+a function or a string. By using quotes on strings and
+parentheses on function calls, you won't ever get them confused.
+
+=item *
+
+You cannot discern from mere inspection which builtins
+are unary operators (like chop() and chdir())
+and which are list operators (like print() and unlink()).
+(User-defined subroutines can be B<only> list operators, never
+unary ones.) See L<perlop>.
+
+=item *
+
+People have a hard time remembering that some functions
+default to $_, or @ARGV, or whatever, but that others which
+you might expect to do not.
+
+=item *
+
+The E<lt>FHE<gt> construct is not the name of the filehandle, it is a readline
+operation on that handle. The data read is assigned to $_ only if the
+file read is the sole condition in a while loop:
+
+ while (<FH>) { }
+ while (defined($_ = <FH>)) { }..
+ <FH>; # data discarded!
+
+=item *
+
+Remember not to use "C<=>" when you need "C<=~>";
+these two constructs are quite different:
+
+ $x = /foo/;
+ $x =~ /foo/;
+
+=item *
+
+The C<do {}> construct isn't a real loop that you can use
+loop control on.
+
+=item *
+
+Use C<my()> for local variables whenever you can get away with
+it (but see L<perlform> for where you can't).
+Using C<local()> actually gives a local value to a global
+variable, which leaves you open to unforeseen side-effects
+of dynamic scoping.
+
+=item *
+
+If you localize an exported variable in a module, its exported value will
+not change. The local name becomes an alias to a new value but the
+external name is still an alias for the original.
+
+=back
+
+=head2 Perl4 to Perl5 Traps
+
+Practicing Perl4 Programmers should take note of the following
+Perl4-to-Perl5 specific traps.
+
+They're crudely ordered according to the following list:
+
+=over 4
+
+=item Discontinuance, Deprecation, and BugFix traps
+
+Anything that's been fixed as a perl4 bug, removed as a perl4 feature
+or deprecated as a perl4 feature with the intent to encourage usage of
+some other perl5 feature.
+
+=item Parsing Traps
+
+Traps that appear to stem from the new parser.
+
+=item Numerical Traps
+
+Traps having to do with numerical or mathematical operators.
+
+=item General data type traps
+
+Traps involving perl standard data types.
+
+=item Context Traps - scalar, list contexts
+
+Traps related to context within lists, scalar statements/declarations.
+
+=item Precedence Traps
+
+Traps related to the precedence of parsing, evaluation, and execution of
+code.
+
+=item General Regular Expression Traps using s///, etc.
+
+Traps related to the use of pattern matching.
+
+=item Subroutine, Signal, Sorting Traps
+
+Traps related to the use of signals and signal handlers, general subroutines,
+and sorting, along with sorting subroutines.
+
+=item OS Traps
+
+OS-specific traps.
+
+=item DBM Traps
+
+Traps specific to the use of C<dbmopen()>, and specific dbm implementations.
+
+=item Unclassified Traps
+
+Everything else.
+
+=back
+
+If you find an example of a conversion trap that is not listed here,
+please submit it to Bill Middleton <F<wjm@best.com>> for inclusion.
+Also note that at least some of these can be caught with B<-w>.
+
+=head2 Discontinuance, Deprecation, and BugFix traps
+
+Anything that has been discontinued, deprecated, or fixed as
+a bug from perl4.
+
+=over 4
+
+=item * Discontinuance
+
+Symbols starting with "_" are no longer forced into package main, except
+for C<$_> itself (and C<@_>, etc.).
+
+ package test;
+ $_legacy = 1;
+
+ package main;
+ print "\$_legacy is ",$_legacy,"\n";
+
+ # perl4 prints: $_legacy is 1
+ # perl5 prints: $_legacy is
+
+=item * Deprecation
+
+Double-colon is now a valid package separator in a variable name. Thus these
+behave differently in perl4 vs. perl5, because the packages don't exist.
+
+ $a=1;$b=2;$c=3;$var=4;
+ print "$a::$b::$c ";
+ print "$var::abc::xyz\n";
+
+ # perl4 prints: 1::2::3 4::abc::xyz
+ # perl5 prints: 3
+
+Given that C<::> is now the preferred package delimiter, it is debatable
+whether this should be classed as a bug or not.
+(The older package delimiter, ' ,is used here)
+
+ $x = 10 ;
+ print "x=${'x}\n" ;
+
+ # perl4 prints: x=10
+ # perl5 prints: Can't find string terminator "'" anywhere before EOF
+
+You can avoid this problem, and remain compatible with perl4, if you
+always explicitly include the package name:
+
+ $x = 10 ;
+ print "x=${main'x}\n" ;
+
+Also see precedence traps, for parsing C<$:>.
+
+=item * BugFix
+
+The second and third arguments of C<splice()> are now evaluated in scalar
+context (as the Camel says) rather than list context.
+
+ sub sub1{return(0,2) } # return a 2-element list
+ sub sub2{ return(1,2,3)} # return a 3-element list
+ @a1 = ("a","b","c","d","e");
+ @a2 = splice(@a1,&sub1,&sub2);
+ print join(' ',@a2),"\n";
+
+ # perl4 prints: a b
+ # perl5 prints: c d e
+
+=item * Discontinuance
+
+You can't do a C<goto> into a block that is optimized away. Darn.
+
+ goto marker1;
+
+ for(1){
+ marker1:
+ print "Here I is!\n";
+ }
+
+ # perl4 prints: Here I is!
+ # perl5 dumps core (SEGV)
+
+=item * Discontinuance
+
+It is no longer syntactically legal to use whitespace as the name
+of a variable, or as a delimiter for any kind of quote construct.
+Double darn.
+
+ $a = ("foo bar");
+ $b = q baz ;
+ print "a is $a, b is $b\n";
+
+ # perl4 prints: a is foo bar, b is baz
+ # perl5 errors: Bareword found where operator expected
+
+=item * Discontinuance
+
+The archaic while/if BLOCK BLOCK syntax is no longer supported.
+
+ if { 1 } {
+ print "True!";
+ }
+ else {
+ print "False!";
+ }
+
+ # perl4 prints: True!
+ # perl5 errors: syntax error at test.pl line 1, near "if {"
+
+=item * BugFix
+
+The C<**> operator now binds more tightly than unary minus.
+It was documented to work this way before, but didn't.
+
+ print -4**2,"\n";
+
+ # perl4 prints: 16
+ # perl5 prints: -16
+
+=item * Discontinuance
+
+The meaning of C<foreach{}> has changed slightly when it is iterating over a
+list which is not an array. This used to assign the list to a
+temporary array, but no longer does so (for efficiency). This means
+that you'll now be iterating over the actual values, not over copies of
+the values. Modifications to the loop variable can change the original
+values.
+
+ @list = ('ab','abc','bcd','def');
+ foreach $var (grep(/ab/,@list)){
+ $var = 1;
+ }
+ print (join(':',@list));
+
+ # perl4 prints: ab:abc:bcd:def
+ # perl5 prints: 1:1:bcd:def
+
+To retain Perl4 semantics you need to assign your list
+explicitly to a temporary array and then iterate over that. For
+example, you might need to change
+
+ foreach $var (grep(/ab/,@list)){
+
+to
+
+ foreach $var (@tmp = grep(/ab/,@list)){
+
+Otherwise changing $var will clobber the values of @list. (This most often
+happens when you use C<$_> for the loop variable, and call subroutines in
+the loop that don't properly localize C<$_>.)
+
+=item * Discontinuance
+
+C<split> with no arguments now behaves like C<split ' '> (which doesn't
+return an initial null field if $_ starts with whitespace), it used to
+behave like C<split /\s+/> (which does).
+
+ $_ = ' hi mom';
+ print join(':', split);
+
+ # perl4 prints: :hi:mom
+ # perl5 prints: hi:mom
+
+=item * BugFix
+
+Perl 4 would ignore any text which was attached to an B<-e> switch,
+always taking the code snippet from the following arg. Additionally, it
+would silently accept an B<-e> switch without a following arg. Both of
+these behaviors have been fixed.
+
+ perl -e'print "attached to -e"' 'print "separate arg"'
+
+ # perl4 prints: separate arg
+ # perl5 prints: attached to -e
+
+ perl -e
+
+ # perl4 prints:
+ # perl5 dies: No code specified for -e.
+
+=item * Discontinuance
+
+In Perl 4 the return value of C<push> was undocumented, but it was
+actually the last value being pushed onto the target list. In Perl 5
+the return value of C<push> is documented, but has changed, it is the
+number of elements in the resulting list.
+
+ @x = ('existing');
+ print push(@x, 'first new', 'second new');
+
+ # perl4 prints: second new
+ # perl5 prints: 3
+
+=item * Discontinuance
+
+In Perl 4 (and versions of Perl 5 before 5.004), C<'\r'> characters in
+Perl code were silently allowed, although they could cause (mysterious!)
+failures in certain constructs, particularly here documents. Now,
+C<'\r'> characters cause an immediate fatal error. (Note: In this
+example, the notation B<\015> represents the incorrect line
+ending. Depending upon your text viewer, it will look different.)
+
+ print "foo";\015
+ print "bar";
+
+ # perl4 prints: foobar
+ # perl5.003 prints: foobar
+ # perl5.004 dies: Illegal character \015 (carriage return)
+
+See L<perldiag> for full details.
+
+=item * Deprecation
+
+Some error messages will be different.
+
+=item * Discontinuance
+
+Some bugs may have been inadvertently removed. :-)
+
+=back
+
+=head2 Parsing Traps
+
+Perl4-to-Perl5 traps from having to do with parsing.
+
+=over 4
+
+=item * Parsing
+
+Note the space between . and =
+
+ $string . = "more string";
+ print $string;
+
+ # perl4 prints: more string
+ # perl5 prints: syntax error at - line 1, near ". ="
+
+=item * Parsing
+
+Better parsing in perl 5
+
+ sub foo {}
+ &foo
+ print("hello, world\n");
+
+ # perl4 prints: hello, world
+ # perl5 prints: syntax error
+
+=item * Parsing
+
+"if it looks like a function, it is a function" rule.
+
+ print
+ ($foo == 1) ? "is one\n" : "is zero\n";
+
+ # perl4 prints: is zero
+ # perl5 warns: "Useless use of a constant in void context" if using -w
+
+=item * Parsing
+
+String interpolation of the C<$#array> construct differs when braces
+are to used around the name.
+
+ @ = (1..3);
+ print "${#a}";
+
+ # perl4 prints: 2
+ # perl5 fails with syntax error
+
+ @ = (1..3);
+ print "$#{a}";
+
+ # perl4 prints: {a}
+ # perl5 prints: 2
+
+=back
+
+=head2 Numerical Traps
+
+Perl4-to-Perl5 traps having to do with numerical operators,
+operands, or output from same.
+
+=over 5
+
+=item * Numerical
+
+Formatted output and significant digits
+
+ print 7.373504 - 0, "\n";
+ printf "%20.18f\n", 7.373504 - 0;
+
+ # Perl4 prints:
+ 7.375039999999996141
+ 7.37503999999999614
+
+ # Perl5 prints:
+ 7.373504
+ 7.37503999999999614
+
+=item * Numerical
+
+This specific item has been deleted. It demonstrated how the auto-increment
+operator would not catch when a number went over the signed int limit. Fixed
+in version 5.003_04. But always be wary when using large integers.
+If in doubt:
+
+ use Math::BigInt;
+
+=item * Numerical
+
+Assignment of return values from numeric equality tests
+does not work in perl5 when the test evaluates to false (0).
+Logical tests now return an null, instead of 0
+
+ $p = ($test == 1);
+ print $p,"\n";
+
+ # perl4 prints: 0
+ # perl5 prints:
+
+Also see L<"General Regular Expression Traps using s///, etc.">
+for another example of this new feature...
+
+=back
+
+=head2 General data type traps
+
+Perl4-to-Perl5 traps involving most data-types, and their usage
+within certain expressions and/or context.
+
+=over 5
+
+=item * (Arrays)
+
+Negative array subscripts now count from the end of the array.
+
+ @a = (1, 2, 3, 4, 5);
+ print "The third element of the array is $a[3] also expressed as $a[-2] \n";
+
+ # perl4 prints: The third element of the array is 4 also expressed as
+ # perl5 prints: The third element of the array is 4 also expressed as 4
+
+=item * (Arrays)
+
+Setting C<$#array> lower now discards array elements, and makes them
+impossible to recover.
+
+ @a = (a,b,c,d,e);
+ print "Before: ",join('',@a);
+ $#a =1;
+ print ", After: ",join('',@a);
+ $#a =3;
+ print ", Recovered: ",join('',@a),"\n";
+
+ # perl4 prints: Before: abcde, After: ab, Recovered: abcd
+ # perl5 prints: Before: abcde, After: ab, Recovered: ab
+
+=item * (Hashes)
+
+Hashes get defined before use
+
+ local($s,@a,%h);
+ die "scalar \$s defined" if defined($s);
+ die "array \@a defined" if defined(@a);
+ die "hash \%h defined" if defined(%h);
+
+ # perl4 prints:
+ # perl5 dies: hash %h defined
+
+=item * (Globs)
+
+glob assignment from variable to variable will fail if the assigned
+variable is localized subsequent to the assignment
+
+ @a = ("This is Perl 4");
+ *b = *a;
+ local(@a);
+ print @b,"\n";
+
+ # perl4 prints: This is Perl 4
+ # perl5 prints:
+
+=item * (Globs)
+
+Assigning C<undef> to a glob has no effect in Perl 5. In Perl 4
+it undefines the associated scalar (but may have other side effects
+including SEGVs).
+
+=item * (Scalar String)
+
+Changes in unary negation (of strings)
+This change effects both the return value and what it
+does to auto(magic)increment.
+
+ $x = "aaa";
+ print ++$x," : ";
+ print -$x," : ";
+ print ++$x,"\n";
+
+ # perl4 prints: aab : -0 : 1
+ # perl5 prints: aab : -aab : aac
+
+=item * (Constants)
+
+perl 4 lets you modify constants:
+
+ $foo = "x";
+ &mod($foo);
+ for ($x = 0; $x < 3; $x++) {
+ &mod("a");
+ }
+ sub mod {
+ print "before: $_[0]";
+ $_[0] = "m";
+ print " after: $_[0]\n";
+ }
+
+ # perl4:
+ # before: x after: m
+ # before: a after: m
+ # before: m after: m
+ # before: m after: m
+
+ # Perl5:
+ # before: x after: m
+ # Modification of a read-only value attempted at foo.pl line 12.
+ # before: a
+
+=item * (Scalars)
+
+The behavior is slightly different for:
+
+ print "$x", defined $x
+
+ # perl 4: 1
+ # perl 5: <no output, $x is not called into existence>
+
+=item * (Variable Suicide)
+
+Variable suicide behavior is more consistent under Perl 5.
+Perl5 exhibits the same behavior for hashes and scalars,
+that perl4 exhibits for only scalars.
+
+ $aGlobal{ "aKey" } = "global value";
+ print "MAIN:", $aGlobal{"aKey"}, "\n";
+ $GlobalLevel = 0;
+ &test( *aGlobal );
+
+ sub test {
+ local( *theArgument ) = @_;
+ local( %aNewLocal ); # perl 4 != 5.001l,m
+ $aNewLocal{"aKey"} = "this should never appear";
+ print "SUB: ", $theArgument{"aKey"}, "\n";
+ $aNewLocal{"aKey"} = "level $GlobalLevel"; # what should print
+ $GlobalLevel++;
+ if( $GlobalLevel<4 ) {
+ &test( *aNewLocal );
+ }
+ }
+
+ # Perl4:
+ # MAIN:global value
+ # SUB: global value
+ # SUB: level 0
+ # SUB: level 1
+ # SUB: level 2
+
+ # Perl5:
+ # MAIN:global value
+ # SUB: global value
+ # SUB: this should never appear
+ # SUB: this should never appear
+ # SUB: this should never appear
+
+=back
+
+=head2 Context Traps - scalar, list contexts
+
+=over 5
+
+=item * (list context)
+
+The elements of argument lists for formats are now evaluated in list
+context. This means you can interpolate list values now.
+
+ @fmt = ("foo","bar","baz");
+ format STDOUT=
+ @<<<<< @||||| @>>>>>
+ @fmt;
+ .
+ write;
+
+ # perl4 errors: Please use commas to separate fields in file
+ # perl5 prints: foo bar baz
+
+=item * (scalar context)
+
+The C<caller()> function now returns a false value in a scalar context
+if there is no caller. This lets library files determine if they're
+being required.
+
+ caller() ? (print "You rang?\n") : (print "Got a 0\n");
+
+ # perl4 errors: There is no caller
+ # perl5 prints: Got a 0
+
+=item * (scalar context)
+
+The comma operator in a scalar context is now guaranteed to give a
+scalar context to its arguments.
+
+ @y= ('a','b','c');
+ $x = (1, 2, @y);
+ print "x = $x\n";
+
+ # Perl4 prints: x = c # Thinks list context interpolates list
+ # Perl5 prints: x = 3 # Knows scalar uses length of list
+
+=item * (list, builtin)
+
+C<sprintf()> funkiness (array argument converted to scalar array count)
+This test could be added to t/op/sprintf.t
+
+ @z = ('%s%s', 'foo', 'bar');
+ $x = sprintf(@z);
+ if ($x eq 'foobar') {print "ok 2\n";} else {print "not ok 2 '$x'\n";}
+
+ # perl4 prints: ok 2
+ # perl5 prints: not ok 2
+
+C<printf()> works fine, though:
+
+ printf STDOUT (@z);
+ print "\n";
+
+ # perl4 prints: foobar
+ # perl5 prints: foobar
+
+Probably a bug.
+
+=back
+
+=head2 Precedence Traps
+
+Perl4-to-Perl5 traps involving precedence order.
+
+Perl 4 has almost the same precedence rules as Perl 5 for the operators
+that they both have. Perl 4 however, seems to have had some
+inconsistencies that made the behavior differ from what was documented.
+
+=over 5
+
+=item * Precedence
+
+LHS vs. RHS of any assignment operator. LHS is evaluated first
+in perl4, second in perl5; this can affect the relationship
+between side-effects in sub-expressions.
+
+ @arr = ( 'left', 'right' );
+ $a{shift @arr} = shift @arr;
+ print join( ' ', keys %a );
+
+ # perl4 prints: left
+ # perl5 prints: right
+
+=item * Precedence
+
+These are now semantic errors because of precedence:
+
+ @list = (1,2,3,4,5);
+ %map = ("a",1,"b",2,"c",3,"d",4);
+ $n = shift @list + 2; # first item in list plus 2
+ print "n is $n, ";
+ $m = keys %map + 2; # number of items in hash plus 2
+ print "m is $m\n";
+
+ # perl4 prints: n is 3, m is 6
+ # perl5 errors and fails to compile
+
+=item * Precedence
+
+The precedence of assignment operators is now the same as the precedence
+of assignment. Perl 4 mistakenly gave them the precedence of the associated
+operator. So you now must parenthesize them in expressions like
+
+ /foo/ ? ($a += 2) : ($a -= 2);
+
+Otherwise
+
+ /foo/ ? $a += 2 : $a -= 2
+
+would be erroneously parsed as
+
+ (/foo/ ? $a += 2 : $a) -= 2;
+
+On the other hand,
+
+ $a += /foo/ ? 1 : 2;
+
+now works as a C programmer would expect.
+
+=item * Precedence
+
+ open FOO || die;
+
+is now incorrect. You need parentheses around the filehandle.
+Otherwise, perl5 leaves the statement as its default precedence:
+
+ open(FOO || die);
+
+ # perl4 opens or dies
+ # perl5 errors: Precedence problem: open FOO should be open(FOO)
+
+=item * Precedence
+
+perl4 gives the special variable, C<$:> precedence, where perl5
+treats C<$::> as main C<package>
+
+ $a = "x"; print "$::a";
+
+ # perl 4 prints: -:a
+ # perl 5 prints: x
+
+=item * Precedence
+
+perl4 had buggy precedence for the file test operators vis-a-vis
+the assignment operators. Thus, although the precedence table
+for perl4 leads one to believe C<-e $foo .= "q"> should parse as
+C<((-e $foo) .= "q")>, it actually parses as C<(-e ($foo .= "q"))>.
+In perl5, the precedence is as documented.
+
+ -e $foo .= "q"
+
+ # perl4 prints: no output
+ # perl5 prints: Can't modify -e in concatenation
+
+=item * Precedence
+
+In perl4, keys(), each() and values() were special high-precedence operators
+that operated on a single hash, but in perl5, they are regular named unary
+operators. As documented, named unary operators have lower precedence
+than the arithmetic and concatenation operators C<+ - .>, but the perl4
+variants of these operators actually bind tighter than C<+ - .>.
+Thus, for:
+
+ %foo = 1..10;
+ print keys %foo - 1
+
+ # perl4 prints: 4
+ # perl5 prints: Type of arg 1 to keys must be hash (not subtraction)
+
+The perl4 behavior was probably more useful, if less consistent.
+
+=back
+
+=head2 General Regular Expression Traps using s///, etc.
+
+All types of RE traps.
+
+=over 5
+
+=item * Regular Expression
+
+C<s'$lhs'$rhs'> now does no interpolation on either side. It used to
+interpolate C<$lhs> but not C<$rhs>. (And still does not match a literal
+'$' in string)
+
+ $a=1;$b=2;
+ $string = '1 2 $a $b';
+ $string =~ s'$a'$b';
+ print $string,"\n";
+
+ # perl4 prints: $b 2 $a $b
+ # perl5 prints: 1 2 $a $b
+
+=item * Regular Expression
+
+C<m//g> now attaches its state to the searched string rather than the
+regular expression. (Once the scope of a block is left for the sub, the
+state of the searched string is lost)
+
+ $_ = "ababab";
+ while(m/ab/g){
+ &doit("blah");
+ }
+ sub doit{local($_) = shift; print "Got $_ "}
+
+ # perl4 prints: blah blah blah
+ # perl5 prints: infinite loop blah...
+
+=item * Regular Expression
+
+Currently, if you use the C<m//o> qualifier on a regular expression
+within an anonymous sub, I<all> closures generated from that anonymous
+sub will use the regular expression as it was compiled when it was used
+the very first time in any such closure. For instance, if you say
+
+ sub build_match {
+ my($left,$right) = @_;
+ return sub { $_[0] =~ /$left stuff $right/o; };
+ }
+
+build_match() will always return a sub which matches the contents of
+C<$left> and C<$right> as they were the I<first> time that build_match()
+was called, not as they are in the current call.
+
+This is probably a bug, and may change in future versions of Perl.
+
+=item * Regular Expression
+
+If no parentheses are used in a match, Perl4 sets C<$+> to
+the whole match, just like C<$&>. Perl5 does not.
+
+ "abcdef" =~ /b.*e/;
+ print "\$+ = $+\n";
+
+ # perl4 prints: bcde
+ # perl5 prints:
+
+=item * Regular Expression
+
+substitution now returns the null string if it fails
+
+ $string = "test";
+ $value = ($string =~ s/foo//);
+ print $value, "\n";
+
+ # perl4 prints: 0
+ # perl5 prints:
+
+Also see L<Numerical Traps> for another example of this new feature.
+
+=item * Regular Expression
+
+C<s`lhs`rhs`> (using backticks) is now a normal substitution, with no
+backtick expansion
+
+ $string = "";
+ $string =~ s`^`hostname`;
+ print $string, "\n";
+
+ # perl4 prints: <the local hostname>
+ # perl5 prints: hostname
+
+=item * Regular Expression
+
+Stricter parsing of variables used in regular expressions
+
+ s/^([^$grpc]*$grpc[$opt$plus$rep]?)//o;
+
+ # perl4: compiles w/o error
+ # perl5: with Scalar found where operator expected ..., near "$opt$plus"
+
+an added component of this example, apparently from the same script, is
+the actual value of the s'd string after the substitution.
+C<[$opt]> is a character class in perl4 and an array subscript in perl5
+
+ $grpc = 'a';
+ $opt = 'r';
+ $_ = 'bar';
+ s/^([^$grpc]*$grpc[$opt]?)/foo/;
+ print ;
+
+ # perl4 prints: foo
+ # perl5 prints: foobar
+
+=item * Regular Expression
+
+Under perl5, C<m?x?> matches only once, like C<?x?>. Under perl4, it matched
+repeatedly, like C</x/> or C<m!x!>.
+
+ $test = "once";
+ sub match { $test =~ m?once?; }
+ &match();
+ if( &match() ) {
+ # m?x? matches more then once
+ print "perl4\n";
+ } else {
+ # m?x? matches only once
+ print "perl5\n";
+ }
+
+ # perl4 prints: perl4
+ # perl5 prints: perl5
+
+
+=back
+
+=head2 Subroutine, Signal, Sorting Traps
+
+The general group of Perl4-to-Perl5 traps having to do with
+Signals, Sorting, and their related subroutines, as well as
+general subroutine traps. Includes some OS-Specific traps.
+
+=over 5
+
+=item * (Signals)
+
+Barewords that used to look like strings to Perl will now look like subroutine
+calls if a subroutine by that name is defined before the compiler sees them.
+
+ sub SeeYa { warn"Hasta la vista, baby!" }
+ $SIG{'TERM'} = SeeYa;
+ print "SIGTERM is now $SIG{'TERM'}\n";
+
+ # perl4 prints: SIGTERM is main'SeeYa
+ # perl5 prints: SIGTERM is now main::1
+
+Use B<-w> to catch this one
+
+=item * (Sort Subroutine)
+
+reverse is no longer allowed as the name of a sort subroutine.
+
+ sub reverse{ print "yup "; $a <=> $b }
+ print sort reverse a,b,c;
+
+ # perl4 prints: yup yup yup yup abc
+ # perl5 prints: abc
+
+=item * warn() won't let you specify a filehandle.
+
+Although it _always_ printed to STDERR, warn() would let you specify a
+filehandle in perl4. With perl5 it does not.
+
+ warn STDERR "Foo!";
+
+ # perl4 prints: Foo!
+ # perl5 prints: String found where operator expected
+
+=back
+
+=head2 OS Traps
+
+=over 5
+
+=item * (SysV)
+
+Under HPUX, and some other SysV OSes, one had to reset any signal handler,
+within the signal handler function, each time a signal was handled with
+perl4. With perl5, the reset is now done correctly. Any code relying
+on the handler _not_ being reset will have to be reworked.
+
+Since version 5.002, Perl uses sigaction() under SysV.
+
+ sub gotit {
+ print "Got @_... ";
+ }
+ $SIG{'INT'} = 'gotit';
+
+ $| = 1;
+ $pid = fork;
+ if ($pid) {
+ kill('INT', $pid);
+ sleep(1);
+ kill('INT', $pid);
+ } else {
+ while (1) {sleep(10);}
+ }
+
+ # perl4 (HPUX) prints: Got INT...
+ # perl5 (HPUX) prints: Got INT... Got INT...
+
+=item * (SysV)
+
+Under SysV OSes, C<seek()> on a file opened to append C<E<gt>E<gt>> now does
+the right thing w.r.t. the fopen() manpage. e.g., - When a file is opened
+for append, it is impossible to overwrite information already in
+the file.
+
+ open(TEST,">>seek.test");
+ $start = tell TEST ;
+ foreach(1 .. 9){
+ print TEST "$_ ";
+ }
+ $end = tell TEST ;
+ seek(TEST,$start,0);
+ print TEST "18 characters here";
+
+ # perl4 (solaris) seek.test has: 18 characters here
+ # perl5 (solaris) seek.test has: 1 2 3 4 5 6 7 8 9 18 characters here
+
+
+
+=back
+
+=head2 Interpolation Traps
+
+Perl4-to-Perl5 traps having to do with how things get interpolated
+within certain expressions, statements, contexts, or whatever.
+
+=over 5
+
+=item * Interpolation
+
+@ now always interpolates an array in double-quotish strings.
+
+ print "To: someone@somewhere.com\n";
+
+ # perl4 prints: To:someone@somewhere.com
+ # perl5 errors : In string, @somewhere now must be written as \@somewhere
+
+=item * Interpolation
+
+Double-quoted strings may no longer end with an unescaped $ or @.
+
+ $foo = "foo$";
+ $bar = "bar@";
+ print "foo is $foo, bar is $bar\n";
+
+ # perl4 prints: foo is foo$, bar is bar@
+ # perl5 errors: Final $ should be \$ or $name
+
+Note: perl5 DOES NOT error on the terminating @ in $bar
+
+=item * Interpolation
+
+Perl now sometimes evaluates arbitrary expressions inside braces that occur
+within double quotes (usually when the opening brace is preceded by C<$>
+or C<@>).
+
+ @www = "buz";
+ $foo = "foo";
+ $bar = "bar";
+ sub foo { return "bar" };
+ print "|@{w.w.w}|${main'foo}|";
+
+ # perl4 prints: |@{w.w.w}|foo|
+ # perl5 prints: |buz|bar|
+
+Note that you can C<use strict;> to ward off such trappiness under perl5.
+
+=item * Interpolation
+
+The construct "this is $$x" used to interpolate the pid at that
+point, but now apparently tries to dereference C<$x>. C<$$> by itself still
+works fine, however.
+
+ print "this is $$x\n";
+
+ # perl4 prints: this is XXXx (XXX is the current pid)
+ # perl5 prints: this is
+
+=item * Interpolation
+
+Creation of hashes on the fly with C<eval "EXPR"> now requires either both
+C<$>'s to be protected in the specification of the hash name, or both curlies
+to be protected. If both curlies are protected, the result will be compatible
+with perl4 and perl5. This is a very common practice, and should be changed
+to use the block form of C<eval{}> if possible.
+
+ $hashname = "foobar";
+ $key = "baz";
+ $value = 1234;
+ eval "\$$hashname{'$key'} = q|$value|";
+ (defined($foobar{'baz'})) ? (print "Yup") : (print "Nope");
+
+ # perl4 prints: Yup
+ # perl5 prints: Nope
+
+Changing
+
+ eval "\$$hashname{'$key'} = q|$value|";
+
+to
+
+ eval "\$\$hashname{'$key'} = q|$value|";
+
+causes the following result:
+
+ # perl4 prints: Nope
+ # perl5 prints: Yup
+
+or, changing to
+
+ eval "\$$hashname\{'$key'\} = q|$value|";
+
+causes the following result:
+
+ # perl4 prints: Yup
+ # perl5 prints: Yup
+ # and is compatible for both versions
+
+
+=item * Interpolation
+
+perl4 programs which unconsciously rely on the bugs in earlier perl versions.
+
+ perl -e '$bar=q/not/; print "This is $foo{$bar} perl5"'
+
+ # perl4 prints: This is not perl5
+ # perl5 prints: This is perl5
+
+=item * Interpolation
+
+You also have to be careful about array references.
+
+ print "$foo{"
+
+ perl 4 prints: {
+ perl 5 prints: syntax error
+
+=item * Interpolation
+
+Similarly, watch out for:
+
+ $foo = "array";
+ print "\$$foo{bar}\n";
+
+ # perl4 prints: $array{bar}
+ # perl5 prints: $
+
+Perl 5 is looking for C<$array{bar}> which doesn't exist, but perl 4 is
+happy just to expand $foo to "array" by itself. Watch out for this
+especially in C<eval>'s.
+
+=item * Interpolation
+
+C<qq()> string passed to C<eval>
+
+ eval qq(
+ foreach \$y (keys %\$x\) {
+ \$count++;
+ }
+ );
+
+ # perl4 runs this ok
+ # perl5 prints: Can't find string terminator ")"
+
+=back
+
+=head2 DBM Traps
+
+General DBM traps.
+
+=over 5
+
+=item * DBM
+
+Existing dbm databases created under perl4 (or any other dbm/ndbm tool)
+may cause the same script, run under perl5, to fail. The build of perl5
+must have been linked with the same dbm/ndbm as the default for C<dbmopen()>
+to function properly without C<tie>'ing to an extension dbm implementation.
+
+ dbmopen (%dbm, "file", undef);
+ print "ok\n";
+
+ # perl4 prints: ok
+ # perl5 prints: ok (IFF linked with -ldbm or -lndbm)
+
+
+=item * DBM
+
+Existing dbm databases created under perl4 (or any other dbm/ndbm tool)
+may cause the same script, run under perl5, to fail. The error generated
+when exceeding the limit on the key/value size will cause perl5 to exit
+immediately.
+
+ dbmopen(DB, "testdb",0600) || die "couldn't open db! $!";
+ $DB{'trap'} = "x" x 1024; # value too large for most dbm/ndbm
+ print "YUP\n";
+
+ # perl4 prints:
+ dbm store returned -1, errno 28, key "trap" at - line 3.
+ YUP
+
+ # perl5 prints:
+ dbm store returned -1, errno 28, key "trap" at - line 3.
+
+=back
+
+=head2 Unclassified Traps
+
+Everything else.
+
+=over 5
+
+=item * C<require>/C<do> trap using returned value
+
+If the file doit.pl has:
+
+ sub foo {
+ $rc = do "./do.pl";
+ return 8;
+ }
+ print &foo, "\n";
+
+And the do.pl file has the following single line:
+
+ return 3;
+
+Running doit.pl gives the following:
+
+ # perl 4 prints: 3 (aborts the subroutine early)
+ # perl 5 prints: 8
+
+Same behavior if you replace C<do> with C<require>.
+
+=item * C<split> on empty string with LIMIT specified
+
+ $string = '';
+ @list = split(/foo/, $string, 2)
+
+Perl4 returns a one element list containing the empty string but Perl5
+returns an empty list.
+
+=back
+
+As always, if any of these are ever officially declared as bugs,
+they'll be fixed and removed.
+
diff --git a/contrib/perl5/pod/perlvar.pod b/contrib/perl5/pod/perlvar.pod
new file mode 100644
index 0000000..2ed3e97
--- /dev/null
+++ b/contrib/perl5/pod/perlvar.pod
@@ -0,0 +1,936 @@
+=head1 NAME
+
+perlvar - Perl predefined variables
+
+=head1 DESCRIPTION
+
+=head2 Predefined Names
+
+The following names have special meaning to Perl. Most
+punctuation names have reasonable mnemonics, or analogues in one of
+the shells. Nevertheless, if you wish to use long variable names,
+you just need to say
+
+ use English;
+
+at the top of your program. This will alias all the short names to the
+long names in the current package. Some even have medium names,
+generally borrowed from B<awk>.
+
+To go a step further, those variables that depend on the currently
+selected filehandle may instead (and preferably) be set by calling an
+object method on the FileHandle object. (Summary lines below for this
+contain the word HANDLE.) First you must say
+
+ use FileHandle;
+
+after which you may use either
+
+ method HANDLE EXPR
+
+or more safely,
+
+ HANDLE->method(EXPR)
+
+Each of the methods returns the old value of the FileHandle attribute.
+The methods each take an optional EXPR, which if supplied specifies the
+new value for the FileHandle attribute in question. If not supplied,
+most of the methods do nothing to the current value, except for
+autoflush(), which will assume a 1 for you, just to be different.
+
+A few of these variables are considered "read-only". This means that if
+you try to assign to this variable, either directly or indirectly through
+a reference, you'll raise a run-time exception.
+
+The following list is ordered by scalar variables first, then the
+arrays, then the hashes (except $^M was added in the wrong place).
+This is somewhat obscured by the fact that %ENV and %SIG are listed as
+$ENV{expr} and $SIG{expr}.
+
+
+=over 8
+
+=item $ARG
+
+=item $_
+
+The default input and pattern-searching space. The following pairs are
+equivalent:
+
+ while (<>) {...} # equivalent in only while!
+ while (defined($_ = <>)) {...}
+
+ /^Subject:/
+ $_ =~ /^Subject:/
+
+ tr/a-z/A-Z/
+ $_ =~ tr/a-z/A-Z/
+
+ chop
+ chop($_)
+
+Here are the places where Perl will assume $_ even if you
+don't use it:
+
+=over 3
+
+=item *
+
+Various unary functions, including functions like ord() and int(), as well
+as the all file tests (C<-f>, C<-d>) except for C<-t>, which defaults to
+STDIN.
+
+=item *
+
+Various list functions like print() and unlink().
+
+=item *
+
+The pattern matching operations C<m//>, C<s///>, and C<tr///> when used
+without an C<=~> operator.
+
+=item *
+
+The default iterator variable in a C<foreach> loop if no other
+variable is supplied.
+
+=item *
+
+The implicit iterator variable in the grep() and map() functions.
+
+=item *
+
+The default place to put an input record when a C<E<lt>FHE<gt>>
+operation's result is tested by itself as the sole criterion of a C<while>
+test. Note that outside of a C<while> test, this will not happen.
+
+=back
+
+(Mnemonic: underline is understood in certain operations.)
+
+=back
+
+=over 8
+
+=item $E<lt>I<digits>E<gt>
+
+Contains the subpattern from the corresponding set of parentheses in
+the last pattern matched, not counting patterns matched in nested
+blocks that have been exited already. (Mnemonic: like \digits.)
+These variables are all read-only.
+
+=item $MATCH
+
+=item $&
+
+The string matched by the last successful pattern match (not counting
+any matches hidden within a BLOCK or eval() enclosed by the current
+BLOCK). (Mnemonic: like & in some editors.) This variable is read-only.
+
+=item $PREMATCH
+
+=item $`
+
+The string preceding whatever was matched by the last successful
+pattern match (not counting any matches hidden within a BLOCK or eval
+enclosed by the current BLOCK). (Mnemonic: C<`> often precedes a quoted
+string.) This variable is read-only.
+
+=item $POSTMATCH
+
+=item $'
+
+The string following whatever was matched by the last successful
+pattern match (not counting any matches hidden within a BLOCK or eval()
+enclosed by the current BLOCK). (Mnemonic: C<'> often follows a quoted
+string.) Example:
+
+ $_ = 'abcdefghi';
+ /def/;
+ print "$`:$&:$'\n"; # prints abc:def:ghi
+
+This variable is read-only.
+
+=item $LAST_PAREN_MATCH
+
+=item $+
+
+The last bracket matched by the last search pattern. This is useful if
+you don't know which of a set of alternative patterns matched. For
+example:
+
+ /Version: (.*)|Revision: (.*)/ && ($rev = $+);
+
+(Mnemonic: be positive and forward looking.)
+This variable is read-only.
+
+=item $MULTILINE_MATCHING
+
+=item $*
+
+Set to 1 to do multi-line matching within a string, 0 to tell Perl
+that it can assume that strings contain a single line, for the purpose
+of optimizing pattern matches. Pattern matches on strings containing
+multiple newlines can produce confusing results when "C<$*>" is 0. Default
+is 0. (Mnemonic: * matches multiple things.) Note that this variable
+influences the interpretation of only "C<^>" and "C<$>". A literal newline can
+be searched for even when C<$* == 0>.
+
+Use of "C<$*>" is deprecated in modern Perls, supplanted by
+the C</s> and C</m> modifiers on pattern matching.
+
+=item input_line_number HANDLE EXPR
+
+=item $INPUT_LINE_NUMBER
+
+=item $NR
+
+=item $.
+
+The current input line number for the last file handle from
+which you read (or performed a C<seek> or C<tell> on). An
+explicit close on a filehandle resets the line number. Because
+"C<E<lt>E<gt>>" never does an explicit close, line numbers increase
+across ARGV files (but see examples under eof()). Localizing C<$.> has
+the effect of also localizing Perl's notion of "the last read
+filehandle". (Mnemonic: many programs use "." to mean the current line
+number.)
+
+=item input_record_separator HANDLE EXPR
+
+=item $INPUT_RECORD_SEPARATOR
+
+=item $RS
+
+=item $/
+
+The input record separator, newline by default. Works like B<awk>'s RS
+variable, including treating empty lines as delimiters if set to the
+null string. (Note: An empty line cannot contain any spaces or tabs.)
+You may set it to a multi-character string to match a multi-character
+delimiter, or to C<undef> to read to end of file. Note that setting it
+to C<"\n\n"> means something slightly different than setting it to
+C<"">, if the file contains consecutive empty lines. Setting it to
+C<""> will treat two or more consecutive empty lines as a single empty
+line. Setting it to C<"\n\n"> will blindly assume that the next input
+character belongs to the next paragraph, even if it's a newline.
+(Mnemonic: / is used to delimit line boundaries when quoting poetry.)
+
+ undef $/;
+ $_ = <FH>; # whole file now here
+ s/\n[ \t]+/ /g;
+
+Remember: the value of $/ is a string, not a regexp. AWK has to be
+better for something :-)
+
+Setting $/ to a reference to an integer, scalar containing an integer, or
+scalar that's convertable to an integer will attempt to read records
+instead of lines, with the maximum record size being the referenced
+integer. So this:
+
+ $/ = \32768; # or \"32768", or \$var_containing_32768
+ open(FILE, $myfile);
+ $_ = <FILE>;
+
+will read a record of no more than 32768 bytes from FILE. If you're not
+reading from a record-oriented file (or your OS doesn't have
+record-oriented files), then you'll likely get a full chunk of data with
+every read. If a record is larger than the record size you've set, you'll
+get the record back in pieces.
+
+On VMS, record reads are done with the equivalent of C<sysread>, so it's
+best not to mix record and non-record reads on the same file. (This is
+likely not a problem, as any file you'd want to read in record mode is
+proably usable in line mode) Non-VMS systems perform normal I/O, so
+it's safe to mix record and non-record reads of a file.
+
+=item autoflush HANDLE EXPR
+
+=item $OUTPUT_AUTOFLUSH
+
+=item $|
+
+If set to nonzero, forces a flush right away and after every write or print on the
+currently selected output channel. Default is 0 (regardless of whether
+the channel is actually buffered by the system or not; C<$|> tells you
+only whether you've asked Perl explicitly to flush after each write).
+Note that STDOUT will typically be line buffered if output is to the
+terminal and block buffered otherwise. Setting this variable is useful
+primarily when you are outputting to a pipe, such as when you are running
+a Perl script under rsh and want to see the output as it's happening. This
+has no effect on input buffering.
+(Mnemonic: when you want your pipes to be piping hot.)
+
+=item output_field_separator HANDLE EXPR
+
+=item $OUTPUT_FIELD_SEPARATOR
+
+=item $OFS
+
+=item $,
+
+The output field separator for the print operator. Ordinarily the
+print operator simply prints out the comma-separated fields you
+specify. To get behavior more like B<awk>, set this variable
+as you would set B<awk>'s OFS variable to specify what is printed
+between fields. (Mnemonic: what is printed when there is a , in your
+print statement.)
+
+=item output_record_separator HANDLE EXPR
+
+=item $OUTPUT_RECORD_SEPARATOR
+
+=item $ORS
+
+=item $\
+
+The output record separator for the print operator. Ordinarily the
+print operator simply prints out the comma-separated fields you
+specify, with no trailing newline or record separator assumed.
+To get behavior more like B<awk>, set this variable as you would
+set B<awk>'s ORS variable to specify what is printed at the end of the
+print. (Mnemonic: you set "C<$\>" instead of adding \n at the end of the
+print. Also, it's just like C<$/>, but it's what you get "back" from
+Perl.)
+
+=item $LIST_SEPARATOR
+
+=item $"
+
+This is like "C<$,>" except that it applies to array values interpolated
+into a double-quoted string (or similar interpreted string). Default
+is a space. (Mnemonic: obvious, I think.)
+
+=item $SUBSCRIPT_SEPARATOR
+
+=item $SUBSEP
+
+=item $;
+
+The subscript separator for multidimensional array emulation. If you
+refer to a hash element as
+
+ $foo{$a,$b,$c}
+
+it really means
+
+ $foo{join($;, $a, $b, $c)}
+
+But don't put
+
+ @foo{$a,$b,$c} # a slice--note the @
+
+which means
+
+ ($foo{$a},$foo{$b},$foo{$c})
+
+Default is "\034", the same as SUBSEP in B<awk>. Note that if your
+keys contain binary data there might not be any safe value for "C<$;>".
+(Mnemonic: comma (the syntactic subscript separator) is a
+semi-semicolon. Yeah, I know, it's pretty lame, but "C<$,>" is already
+taken for something more important.)
+
+Consider using "real" multidimensional arrays.
+
+=item $OFMT
+
+=item $#
+
+The output format for printed numbers. This variable is a half-hearted
+attempt to emulate B<awk>'s OFMT variable. There are times, however,
+when B<awk> and Perl have differing notions of what is in fact
+numeric. The initial value is %.I<n>g, where I<n> is the value
+of the macro DBL_DIG from your system's F<float.h>. This is different from
+B<awk>'s default OFMT setting of %.6g, so you need to set "C<$#>"
+explicitly to get B<awk>'s value. (Mnemonic: # is the number sign.)
+
+Use of "C<$#>" is deprecated.
+
+=item format_page_number HANDLE EXPR
+
+=item $FORMAT_PAGE_NUMBER
+
+=item $%
+
+The current page number of the currently selected output channel.
+(Mnemonic: % is page number in B<nroff>.)
+
+=item format_lines_per_page HANDLE EXPR
+
+=item $FORMAT_LINES_PER_PAGE
+
+=item $=
+
+The current page length (printable lines) of the currently selected
+output channel. Default is 60. (Mnemonic: = has horizontal lines.)
+
+=item format_lines_left HANDLE EXPR
+
+=item $FORMAT_LINES_LEFT
+
+=item $-
+
+The number of lines left on the page of the currently selected output
+channel. (Mnemonic: lines_on_page - lines_printed.)
+
+=item format_name HANDLE EXPR
+
+=item $FORMAT_NAME
+
+=item $~
+
+The name of the current report format for the currently selected output
+channel. Default is name of the filehandle. (Mnemonic: brother to
+"C<$^>".)
+
+=item format_top_name HANDLE EXPR
+
+=item $FORMAT_TOP_NAME
+
+=item $^
+
+The name of the current top-of-page format for the currently selected
+output channel. Default is name of the filehandle with _TOP
+appended. (Mnemonic: points to top of page.)
+
+=item format_line_break_characters HANDLE EXPR
+
+=item $FORMAT_LINE_BREAK_CHARACTERS
+
+=item $:
+
+The current set of characters after which a string may be broken to
+fill continuation fields (starting with ^) in a format. Default is
+S<" \n-">, to break on whitespace or hyphens. (Mnemonic: a "colon" in
+poetry is a part of a line.)
+
+=item format_formfeed HANDLE EXPR
+
+=item $FORMAT_FORMFEED
+
+=item $^L
+
+What formats output to perform a form feed. Default is \f.
+
+=item $ACCUMULATOR
+
+=item $^A
+
+The current value of the write() accumulator for format() lines. A format
+contains formline() commands that put their result into C<$^A>. After
+calling its format, write() prints out the contents of C<$^A> and empties.
+So you never actually see the contents of C<$^A> unless you call
+formline() yourself and then look at it. See L<perlform> and
+L<perlfunc/formline()>.
+
+=item $CHILD_ERROR
+
+=item $?
+
+The status returned by the last pipe close, backtick (C<``>) command,
+or system() operator. Note that this is the status word returned by the
+wait() system call (or else is made up to look like it). Thus, the exit
+value of the subprocess is actually (C<$? E<gt>E<gt> 8>), and C<$? & 127>
+gives which signal, if any, the process died from, and C<$? & 128> reports
+whether there was a core dump. (Mnemonic: similar to B<sh> and B<ksh>.)
+
+Additionally, if the C<h_errno> variable is supported in C, its value
+is returned via $? if any of the C<gethost*()> functions fail.
+
+Note that if you have installed a signal handler for C<SIGCHLD>, the
+value of C<$?> will usually be wrong outside that handler.
+
+Inside an C<END> subroutine C<$?> contains the value that is going to be
+given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
+change the exit status of the script.
+
+Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
+actual VMS exit status, instead of the default emulation of POSIX
+status.
+
+Also see L<Error Indicators>.
+
+=item $OS_ERROR
+
+=item $ERRNO
+
+=item $!
+
+If used in a numeric context, yields the current value of errno, with
+all the usual caveats. (This means that you shouldn't depend on the
+value of C<$!> to be anything in particular unless you've gotten a
+specific error return indicating a system error.) If used in a string
+context, yields the corresponding system error string. You can assign
+to C<$!> to set I<errno> if, for instance, you want C<"$!"> to return the
+string for error I<n>, or you want to set the exit value for the die()
+operator. (Mnemonic: What just went bang?)
+
+Also see L<Error Indicators>.
+
+=item $EXTENDED_OS_ERROR
+
+=item $^E
+
+Error information specific to the current operating system. At
+the moment, this differs from C<$!> under only VMS, OS/2, and Win32
+(and for MacPerl). On all other platforms, C<$^E> is always just
+the same as C<$!>.
+
+Under VMS, C<$^E> provides the VMS status value from the last
+system error. This is more specific information about the last
+system error than that provided by C<$!>. This is particularly
+important when C<$!> is set to B<EVMSERR>.
+
+Under OS/2, C<$^E> is set to the error code of the last call to
+OS/2 API either via CRT, or directly from perl.
+
+Under Win32, C<$^E> always returns the last error information
+reported by the Win32 call C<GetLastError()> which describes
+the last error from within the Win32 API. Most Win32-specific
+code will report errors via C<$^E>. ANSI C and UNIX-like calls
+set C<errno> and so most portable Perl code will report errors
+via C<$!>.
+
+Caveats mentioned in the description of C<$!> generally apply to
+C<$^E>, also. (Mnemonic: Extra error explanation.)
+
+Also see L<Error Indicators>.
+
+=item $EVAL_ERROR
+
+=item $@
+
+The Perl syntax error message from the last eval() command. If null, the
+last eval() parsed and executed correctly (although the operations you
+invoked may have failed in the normal fashion). (Mnemonic: Where was
+the syntax error "at"?)
+
+Note that warning messages are not collected in this variable. You can,
+however, set up a routine to process warnings by setting C<$SIG{__WARN__}>
+as described below.
+
+Also see L<Error Indicators>.
+
+=item $PROCESS_ID
+
+=item $PID
+
+=item $$
+
+The process number of the Perl running this script. (Mnemonic: same
+as shells.)
+
+=item $REAL_USER_ID
+
+=item $UID
+
+=item $<
+
+The real uid of this process. (Mnemonic: it's the uid you came I<FROM>,
+if you're running setuid.)
+
+=item $EFFECTIVE_USER_ID
+
+=item $EUID
+
+=item $>
+
+The effective uid of this process. Example:
+
+ $< = $>; # set real to effective uid
+ ($<,$>) = ($>,$<); # swap real and effective uid
+
+(Mnemonic: it's the uid you went I<TO>, if you're running setuid.)
+Note: "C<$E<lt>>" and "C<$E<gt>>" can be swapped only on machines
+supporting setreuid().
+
+=item $REAL_GROUP_ID
+
+=item $GID
+
+=item $(
+
+The real gid of this process. If you are on a machine that supports
+membership in multiple groups simultaneously, gives a space separated
+list of groups you are in. The first number is the one returned by
+getgid(), and the subsequent ones by getgroups(), one of which may be
+the same as the first number.
+
+However, a value assigned to "C<$(>" must be a single number used to
+set the real gid. So the value given by "C<$(>" should I<not> be assigned
+back to "C<$(>" without being forced numeric, such as by adding zero.
+
+(Mnemonic: parentheses are used to I<GROUP> things. The real gid is the
+group you I<LEFT>, if you're running setgid.)
+
+=item $EFFECTIVE_GROUP_ID
+
+=item $EGID
+
+=item $)
+
+The effective gid of this process. If you are on a machine that
+supports membership in multiple groups simultaneously, gives a space
+separated list of groups you are in. The first number is the one
+returned by getegid(), and the subsequent ones by getgroups(), one of
+which may be the same as the first number.
+
+Similarly, a value assigned to "C<$)>" must also be a space-separated
+list of numbers. The first number is used to set the effective gid, and
+the rest (if any) are passed to setgroups(). To get the effect of an
+empty list for setgroups(), just repeat the new effective gid; that is,
+to force an effective gid of 5 and an effectively empty setgroups()
+list, say C< $) = "5 5" >.
+
+(Mnemonic: parentheses are used to I<GROUP> things. The effective gid
+is the group that's I<RIGHT> for you, if you're running setgid.)
+
+Note: "C<$E<lt>>", "C<$E<gt>>", "C<$(>" and "C<$)>" can be set only on
+machines that support the corresponding I<set[re][ug]id()> routine. "C<$(>"
+and "C<$)>" can be swapped only on machines supporting setregid().
+
+=item $PROGRAM_NAME
+
+=item $0
+
+Contains the name of the file containing the Perl script being
+executed. On some operating systems
+assigning to "C<$0>" modifies the argument area that the ps(1)
+program sees. This is more useful as a way of indicating the
+current program state than it is for hiding the program you're running.
+(Mnemonic: same as B<sh> and B<ksh>.)
+
+=item $[
+
+The index of the first element in an array, and of the first character
+in a substring. Default is 0, but you could set it to 1 to make
+Perl behave more like B<awk> (or Fortran) when subscripting and when
+evaluating the index() and substr() functions. (Mnemonic: [ begins
+subscripts.)
+
+As of Perl 5, assignment to "C<$[>" is treated as a compiler directive,
+and cannot influence the behavior of any other file. Its use is
+discouraged.
+
+=item $PERL_VERSION
+
+=item $]
+
+The version + patchlevel / 1000 of the Perl interpreter. This variable
+can be used to determine whether the Perl interpreter executing a
+script is in the right range of versions. (Mnemonic: Is this version
+of perl in the right bracket?) Example:
+
+ warn "No checksumming!\n" if $] < 3.019;
+
+See also the documentation of C<use VERSION> and C<require VERSION>
+for a convenient way to fail if the Perl interpreter is too old.
+
+=item $DEBUGGING
+
+=item $^D
+
+The current value of the debugging flags. (Mnemonic: value of B<-D>
+switch.)
+
+=item $SYSTEM_FD_MAX
+
+=item $^F
+
+The maximum system file descriptor, ordinarily 2. System file
+descriptors are passed to exec()ed processes, while higher file
+descriptors are not. Also, during an open(), system file descriptors are
+preserved even if the open() fails. (Ordinary file descriptors are
+closed before the open() is attempted.) Note that the close-on-exec
+status of a file descriptor will be decided according to the value of
+C<$^F> at the time of the open, not the time of the exec.
+
+=item $^H
+
+The current set of syntax checks enabled by C<use strict> and other block
+scoped compiler hints. See the documentation of C<strict> for more details.
+
+=item $INPLACE_EDIT
+
+=item $^I
+
+The current value of the inplace-edit extension. Use C<undef> to disable
+inplace editing. (Mnemonic: value of B<-i> switch.)
+
+=item $^M
+
+By default, running out of memory it is not trappable. However, if
+compiled for this, Perl may use the contents of C<$^M> as an emergency
+pool after die()ing with this message. Suppose that your Perl were
+compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. Then
+
+ $^M = 'a' x (1<<16);
+
+would allocate a 64K buffer for use when in emergency. See the F<INSTALL>
+file for information on how to enable this option. As a disincentive to
+casual use of this advanced feature, there is no L<English> long name for
+this variable.
+
+=item $OSNAME
+
+=item $^O
+
+The name of the operating system under which this copy of Perl was
+built, as determined during the configuration process. The value
+is identical to C<$Config{'osname'}>.
+
+=item $PERLDB
+
+=item $^P
+
+The internal variable for debugging support. Different bits mean the
+following (subject to change):
+
+=over 6
+
+=item 0x01
+
+Debug subroutine enter/exit.
+
+=item 0x02
+
+Line-by-line debugging.
+
+=item 0x04
+
+Switch off optimizations.
+
+=item 0x08
+
+Preserve more data for future interactive inspections.
+
+=item 0x10
+
+Keep info about source lines on which a subroutine is defined.
+
+=item 0x20
+
+Start with single-step on.
+
+=back
+
+Note that some bits may be relevent at compile-time only, some at
+run-time only. This is a new mechanism and the details may change.
+
+=item $^R
+
+The result of evaluation of the last successful L<perlre/C<(?{ code })>>
+regular expression assertion. (Excluding those used as switches.) May
+be written to.
+
+=item $^S
+
+Current state of the interpreter. Undefined if parsing of the current
+module/eval is not finished (may happen in $SIG{__DIE__} and
+$SIG{__WARN__} handlers). True if inside an eval, otherwise false.
+
+=item $BASETIME
+
+=item $^T
+
+The time at which the script began running, in seconds since the
+epoch (beginning of 1970). The values returned by the B<-M>, B<-A>,
+and B<-C> filetests are
+based on this value.
+
+=item $WARNING
+
+=item $^W
+
+The current value of the warning switch, either TRUE or FALSE.
+(Mnemonic: related to the B<-w> switch.)
+
+=item $EXECUTABLE_NAME
+
+=item $^X
+
+The name that the Perl binary itself was executed as, from C's C<argv[0]>.
+
+=item $ARGV
+
+contains the name of the current file when reading from E<lt>E<gt>.
+
+=item @ARGV
+
+The array @ARGV contains the command line arguments intended for the
+script. Note that C<$#ARGV> is the generally number of arguments minus
+one, because C<$ARGV[0]> is the first argument, I<NOT> the command name. See
+"C<$0>" for the command name.
+
+=item @INC
+
+The array @INC contains the list of places to look for Perl scripts to
+be evaluated by the C<do EXPR>, C<require>, or C<use> constructs. It
+initially consists of the arguments to any B<-I> command line switches,
+followed by the default Perl library, probably F</usr/local/lib/perl>,
+followed by ".", to represent the current directory. If you need to
+modify this at runtime, you should use the C<use lib> pragma
+to get the machine-dependent library properly loaded also:
+
+ use lib '/mypath/libdir/';
+ use SomeMod;
+
+=item @_
+
+Within a subroutine the array @_ contains the parameters passed to that
+subroutine. See L<perlsub>.
+
+=item %INC
+
+The hash %INC contains entries for each filename that has
+been included via C<do> or C<require>. The key is the filename you
+specified, and the value is the location of the file actually found.
+The C<require> command uses this array to determine whether a given file
+has already been included.
+
+=item %ENV $ENV{expr}
+
+The hash %ENV contains your current environment. Setting a
+value in C<ENV> changes the environment for child processes.
+
+=item %SIG $SIG{expr}
+
+The hash %SIG is used to set signal handlers for various
+signals. Example:
+
+ sub handler { # 1st argument is signal name
+ my($sig) = @_;
+ print "Caught a SIG$sig--shutting down\n";
+ close(LOG);
+ exit(0);
+ }
+
+ $SIG{'INT'} = \&handler;
+ $SIG{'QUIT'} = \&handler;
+ ...
+ $SIG{'INT'} = 'DEFAULT'; # restore default action
+ $SIG{'QUIT'} = 'IGNORE'; # ignore SIGQUIT
+
+The %SIG array contains values for only the signals actually set within
+the Perl script. Here are some other examples:
+
+ $SIG{"PIPE"} = Plumber; # SCARY!!
+ $SIG{"PIPE"} = "Plumber"; # assumes main::Plumber (not recommended)
+ $SIG{"PIPE"} = \&Plumber; # just fine; assume current Plumber
+ $SIG{"PIPE"} = Plumber(); # oops, what did Plumber() return??
+
+The one marked scary is problematic because it's a bareword, which means
+sometimes it's a string representing the function, and sometimes it's
+going to call the subroutine call right then and there! Best to be sure
+and quote it or take a reference to it. *Plumber works too. See L<perlsub>.
+
+If your system has the sigaction() function then signal handlers are
+installed using it. This means you get reliable signal handling. If
+your system has the SA_RESTART flag it is used when signals handlers are
+installed. This means that system calls for which it is supported
+continue rather than returning when a signal arrives. If you want your
+system calls to be interrupted by signal delivery then do something like
+this:
+
+ use POSIX ':signal_h';
+
+ my $alarm = 0;
+ sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 }
+ or die "Error setting SIGALRM handler: $!\n";
+
+See L<POSIX>.
+
+Certain internal hooks can be also set using the %SIG hash. The
+routine indicated by C<$SIG{__WARN__}> is called when a warning message is
+about to be printed. The warning message is passed as the first
+argument. The presence of a __WARN__ hook causes the ordinary printing
+of warnings to STDERR to be suppressed. You can use this to save warnings
+in a variable, or turn warnings into fatal errors, like this:
+
+ local $SIG{__WARN__} = sub { die $_[0] };
+ eval $proggie;
+
+The routine indicated by C<$SIG{__DIE__}> is called when a fatal exception
+is about to be thrown. The error message is passed as the first
+argument. When a __DIE__ hook routine returns, the exception
+processing continues as it would have in the absence of the hook,
+unless the hook routine itself exits via a C<goto>, a loop exit, or a die().
+The C<__DIE__> handler is explicitly disabled during the call, so that you
+can die from a C<__DIE__> handler. Similarly for C<__WARN__>.
+
+Note that the C<$SIG{__DIE__}> hook is called even inside eval()ed
+blocks/strings. See L<perlfunc/die> and L<perlvar/$^S> for how to
+circumvent this.
+
+Note that C<__DIE__>/C<__WARN__> handlers are very special in one
+respect: they may be called to report (probable) errors found by the
+parser. In such a case the parser may be in inconsistent state, so
+any attempt to evaluate Perl code from such a handler will probably
+result in a segfault. This means that calls which result/may-result
+in parsing Perl should be used with extreme causion, like this:
+
+ require Carp if defined $^S;
+ Carp::confess("Something wrong") if defined &Carp::confess;
+ die "Something wrong, but could not load Carp to give backtrace...
+ To see backtrace try starting Perl with -MCarp switch";
+
+Here the first line will load Carp I<unless> it is the parser who
+called the handler. The second line will print backtrace and die if
+Carp was available. The third line will be executed only if Carp was
+not available.
+
+See L<perlfunc/die>, L<perlfunc/warn> and L<perlfunc/eval> for
+additional info.
+
+=back
+
+=head2 Error Indicators
+
+The variables L<$@>, L<$!>, L<$^E>, and L<$?> contain information about
+different types of error conditions that may appear during execution of
+Perl script. The variables are shown ordered by the "distance" between
+the subsystem which reported the error and the Perl process, and
+correspond to errors detected by the Perl interpreter, C library,
+operating system, or an external program, respectively.
+
+To illustrate the differences between these variables, consider the
+following Perl expression:
+
+ eval '
+ open PIPE, "/cdrom/install |";
+ @res = <PIPE>;
+ close PIPE or die "bad pipe: $?, $!";
+ ';
+
+After execution of this statement all 4 variables may have been set.
+
+$@ is set if the string to be C<eval>-ed did not compile (this may happen if
+C<open> or C<close> were imported with bad prototypes), or if Perl
+code executed during evaluation die()d (either implicitly, say,
+if C<open> was imported from module L<Fatal>, or the C<die> after
+C<close> was triggered). In these cases the value of $@ is the compile
+error, or C<Fatal> error (which will interpolate C<$!>!), or the argument
+to C<die> (which will interpolate C<$!> and C<$?>!).
+
+When the above expression is executed, open(), C<<PIPEE<gt>>, and C<close>
+are translated to C run-time library calls. $! is set if one of these
+calls fails. The value is a symbolic indicator chosen by the C run-time
+library, say C<No such file or directory>.
+
+On some systems the above C library calls are further translated
+to calls to the kernel. The kernel may have set more verbose error
+indicator that one of the handful of standard C errors. In such cases $^E
+contains this verbose error indicator, which may be, say, C<CDROM tray not
+closed>. On systems where C library calls are identical to system calls
+$^E is a duplicate of $!.
+
+Finally, $? may be set to non-C<0> value if the external program
+C</cdrom/install> fails. Upper bits of the particular value may reflect
+specific error conditions encountered by this program (this is
+program-dependent), lower-bits reflect mode of failure (segfault, completion,
+etc.). Note that in contrast to $@, $!, and $^E, which are set only
+if error condition is detected, the variable $? is set on each C<wait> or
+pipe C<close>, overwriting the old value.
+
+For more details, see the individual descriptions at L<$@>, L<$!>, L<$^E>,
+and L<$?>.
diff --git a/contrib/perl5/pod/perlxs.pod b/contrib/perl5/pod/perlxs.pod
new file mode 100644
index 0000000..c578a2e
--- /dev/null
+++ b/contrib/perl5/pod/perlxs.pod
@@ -0,0 +1,1348 @@
+=head1 NAME
+
+perlxs - XS language reference manual
+
+=head1 DESCRIPTION
+
+=head2 Introduction
+
+XS is a language used to create an extension interface
+between Perl and some C library which one wishes to use with
+Perl. The XS interface is combined with the library to
+create a new library which can be linked to Perl. An B<XSUB>
+is a function in the XS language and is the core component
+of the Perl application interface.
+
+The XS compiler is called B<xsubpp>. This compiler will embed
+the constructs necessary to let an XSUB, which is really a C
+function in disguise, manipulate Perl values and creates the
+glue necessary to let Perl access the XSUB. The compiler
+uses B<typemaps> to determine how to map C function parameters
+and variables to Perl values. The default typemap handles
+many common C types. A supplement typemap must be created
+to handle special structures and types for the library being
+linked.
+
+See L<perlxstut> for a tutorial on the whole extension creation process.
+
+Note: For many extensions, Dave Beazley's SWIG system provides a
+significantly more convenient mechanism for creating the XS glue
+code. See L<http://www.cs.utah.edu/~beazley/SWIG> for more
+information.
+
+=head2 On The Road
+
+Many of the examples which follow will concentrate on creating an interface
+between Perl and the ONC+ RPC bind library functions. The rpcb_gettime()
+function is used to demonstrate many features of the XS language. This
+function has two parameters; the first is an input parameter and the second
+is an output parameter. The function also returns a status value.
+
+ bool_t rpcb_gettime(const char *host, time_t *timep);
+
+From C this function will be called with the following
+statements.
+
+ #include <rpc/rpc.h>
+ bool_t status;
+ time_t timep;
+ status = rpcb_gettime( "localhost", &timep );
+
+If an XSUB is created to offer a direct translation between this function
+and Perl, then this XSUB will be used from Perl with the following code.
+The $status and $timep variables will contain the output of the function.
+
+ use RPC;
+ $status = rpcb_gettime( "localhost", $timep );
+
+The following XS file shows an XS subroutine, or XSUB, which
+demonstrates one possible interface to the rpcb_gettime()
+function. This XSUB represents a direct translation between
+C and Perl and so preserves the interface even from Perl.
+This XSUB will be invoked from Perl with the usage shown
+above. Note that the first three #include statements, for
+C<EXTERN.h>, C<perl.h>, and C<XSUB.h>, will always be present at the
+beginning of an XS file. This approach and others will be
+expanded later in this document.
+
+ #include "EXTERN.h"
+ #include "perl.h"
+ #include "XSUB.h"
+ #include <rpc/rpc.h>
+
+ MODULE = RPC PACKAGE = RPC
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ OUTPUT:
+ timep
+
+Any extension to Perl, including those containing XSUBs,
+should have a Perl module to serve as the bootstrap which
+pulls the extension into Perl. This module will export the
+extension's functions and variables to the Perl program and
+will cause the extension's XSUBs to be linked into Perl.
+The following module will be used for most of the examples
+in this document and should be used from Perl with the C<use>
+command as shown earlier. Perl modules are explained in
+more detail later in this document.
+
+ package RPC;
+
+ require Exporter;
+ require DynaLoader;
+ @ISA = qw(Exporter DynaLoader);
+ @EXPORT = qw( rpcb_gettime );
+
+ bootstrap RPC;
+ 1;
+
+Throughout this document a variety of interfaces to the rpcb_gettime()
+XSUB will be explored. The XSUBs will take their parameters in different
+orders or will take different numbers of parameters. In each case the
+XSUB is an abstraction between Perl and the real C rpcb_gettime()
+function, and the XSUB must always ensure that the real rpcb_gettime()
+function is called with the correct parameters. This abstraction will
+allow the programmer to create a more Perl-like interface to the C
+function.
+
+=head2 The Anatomy of an XSUB
+
+The following XSUB allows a Perl program to access a C library function
+called sin(). The XSUB will imitate the C function which takes a single
+argument and returns a single value.
+
+ double
+ sin(x)
+ double x
+
+When using C pointers the indirection operator C<*> should be considered
+part of the type and the address operator C<&> should be considered part of
+the variable, as is demonstrated in the rpcb_gettime() function above. See
+the section on typemaps for more about handling qualifiers and unary
+operators in C types.
+
+The function name and the return type must be placed on
+separate lines.
+
+ INCORRECT CORRECT
+
+ double sin(x) double
+ double x sin(x)
+ double x
+
+The function body may be indented or left-adjusted. The following example
+shows a function with its body left-adjusted. Most examples in this
+document will indent the body.
+
+ CORRECT
+
+ double
+ sin(x)
+ double x
+
+=head2 The Argument Stack
+
+The argument stack is used to store the values which are
+sent as parameters to the XSUB and to store the XSUB's
+return value. In reality all Perl functions keep their
+values on this stack at the same time, each limited to its
+own range of positions on the stack. In this document the
+first position on that stack which belongs to the active
+function will be referred to as position 0 for that function.
+
+XSUBs refer to their stack arguments with the macro B<ST(x)>, where I<x>
+refers to a position in this XSUB's part of the stack. Position 0 for that
+function would be known to the XSUB as ST(0). The XSUB's incoming
+parameters and outgoing return values always begin at ST(0). For many
+simple cases the B<xsubpp> compiler will generate the code necessary to
+handle the argument stack by embedding code fragments found in the
+typemaps. In more complex cases the programmer must supply the code.
+
+=head2 The RETVAL Variable
+
+The RETVAL variable is a magic variable which always matches
+the return type of the C library function. The B<xsubpp> compiler will
+supply this variable in each XSUB and by default will use it to hold the
+return value of the C library function being called. In simple cases the
+value of RETVAL will be placed in ST(0) of the argument stack where it can
+be received by Perl as the return value of the XSUB.
+
+If the XSUB has a return type of C<void> then the compiler will
+not supply a RETVAL variable for that function. When using
+the PPCODE: directive the RETVAL variable is not needed, unless used
+explicitly.
+
+If PPCODE: directive is not used, C<void> return value should be used
+only for subroutines which do not return a value, I<even if> CODE:
+directive is used which sets ST(0) explicitly.
+
+Older versions of this document recommended to use C<void> return
+value in such cases. It was discovered that this could lead to
+segfaults in cases when XSUB was I<truely> C<void>. This practice is
+now deprecated, and may be not supported at some future version. Use
+the return value C<SV *> in such cases. (Currently C<xsubpp> contains
+some heuristic code which tries to disambiguate between "truely-void"
+and "old-practice-declared-as-void" functions. Hence your code is at
+mercy of this heuristics unless you use C<SV *> as return value.)
+
+=head2 The MODULE Keyword
+
+The MODULE keyword is used to start the XS code and to
+specify the package of the functions which are being
+defined. All text preceding the first MODULE keyword is
+considered C code and is passed through to the output
+untouched. Every XS module will have a bootstrap function
+which is used to hook the XSUBs into Perl. The package name
+of this bootstrap function will match the value of the last
+MODULE statement in the XS source files. The value of
+MODULE should always remain constant within the same XS
+file, though this is not required.
+
+The following example will start the XS code and will place
+all functions in a package named RPC.
+
+ MODULE = RPC
+
+=head2 The PACKAGE Keyword
+
+When functions within an XS source file must be separated into packages
+the PACKAGE keyword should be used. This keyword is used with the MODULE
+keyword and must follow immediately after it when used.
+
+ MODULE = RPC PACKAGE = RPC
+
+ [ XS code in package RPC ]
+
+ MODULE = RPC PACKAGE = RPCB
+
+ [ XS code in package RPCB ]
+
+ MODULE = RPC PACKAGE = RPC
+
+ [ XS code in package RPC ]
+
+Although this keyword is optional and in some cases provides redundant
+information it should always be used. This keyword will ensure that the
+XSUBs appear in the desired package.
+
+=head2 The PREFIX Keyword
+
+The PREFIX keyword designates prefixes which should be
+removed from the Perl function names. If the C function is
+C<rpcb_gettime()> and the PREFIX value is C<rpcb_> then Perl will
+see this function as C<gettime()>.
+
+This keyword should follow the PACKAGE keyword when used.
+If PACKAGE is not used then PREFIX should follow the MODULE
+keyword.
+
+ MODULE = RPC PREFIX = rpc_
+
+ MODULE = RPC PACKAGE = RPCB PREFIX = rpcb_
+
+=head2 The OUTPUT: Keyword
+
+The OUTPUT: keyword indicates that certain function parameters should be
+updated (new values made visible to Perl) when the XSUB terminates or that
+certain values should be returned to the calling Perl function. For
+simple functions, such as the sin() function above, the RETVAL variable is
+automatically designated as an output value. In more complex functions
+the B<xsubpp> compiler will need help to determine which variables are output
+variables.
+
+This keyword will normally be used to complement the CODE: keyword.
+The RETVAL variable is not recognized as an output variable when the
+CODE: keyword is present. The OUTPUT: keyword is used in this
+situation to tell the compiler that RETVAL really is an output
+variable.
+
+The OUTPUT: keyword can also be used to indicate that function parameters
+are output variables. This may be necessary when a parameter has been
+modified within the function and the programmer would like the update to
+be seen by Perl.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ OUTPUT:
+ timep
+
+The OUTPUT: keyword will also allow an output parameter to
+be mapped to a matching piece of code rather than to a
+typemap.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ OUTPUT:
+ timep sv_setnv(ST(1), (double)timep);
+
+B<xsubpp> emits an automatic C<SvSETMAGIC()> for all parameters in the
+OUTPUT section of the XSUB, except RETVAL. This is the usually desired
+behavior, as it takes care of properly invoking 'set' magic on output
+parameters (needed for hash or array element parameters that must be
+created if they didn't exist). If for some reason, this behavior is
+not desired, the OUTPUT section may contain a C<SETMAGIC: DISABLE> line
+to disable it for the remainder of the parameters in the OUTPUT section.
+Likewise, C<SETMAGIC: ENABLE> can be used to reenable it for the
+remainder of the OUTPUT section. See L<perlguts> for more details
+about 'set' magic.
+
+=head2 The CODE: Keyword
+
+This keyword is used in more complicated XSUBs which require
+special handling for the C function. The RETVAL variable is
+available but will not be returned unless it is specified
+under the OUTPUT: keyword.
+
+The following XSUB is for a C function which requires special handling of
+its parameters. The Perl usage is given first.
+
+ $status = rpcb_gettime( "localhost", $timep );
+
+The XSUB follows.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t timep
+ CODE:
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 The INIT: Keyword
+
+The INIT: keyword allows initialization to be inserted into the XSUB before
+the compiler generates the call to the C function. Unlike the CODE: keyword
+above, this keyword does not affect the way the compiler handles RETVAL.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ INIT:
+ printf("# Host is %s\n", host );
+ OUTPUT:
+ timep
+
+=head2 The NO_INIT Keyword
+
+The NO_INIT keyword is used to indicate that a function
+parameter is being used only as an output value. The B<xsubpp>
+compiler will normally generate code to read the values of
+all function parameters from the argument stack and assign
+them to C variables upon entry to the function. NO_INIT
+will tell the compiler that some parameters will be used for
+output rather than for input and that they will be handled
+before the function terminates.
+
+The following example shows a variation of the rpcb_gettime() function.
+This function uses the timep variable only as an output variable and does
+not care about its initial contents.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep = NO_INIT
+ OUTPUT:
+ timep
+
+=head2 Initializing Function Parameters
+
+Function parameters are normally initialized with their
+values from the argument stack. The typemaps contain the
+code segments which are used to transfer the Perl values to
+the C parameters. The programmer, however, is allowed to
+override the typemaps and supply alternate (or additional)
+initialization code.
+
+The following code demonstrates how to supply initialization code for
+function parameters. The initialization code is eval'd within double
+quotes by the compiler before it is added to the output so anything
+which should be interpreted literally [mainly C<$>, C<@>, or C<\\>]
+must be protected with backslashes. The variables C<$var>, C<$arg>,
+and C<$type> can be used as in typemaps.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host = (char *)SvPV($arg,PL_na);
+ time_t &timep = 0;
+ OUTPUT:
+ timep
+
+This should not be used to supply default values for parameters. One
+would normally use this when a function parameter must be processed by
+another library function before it can be used. Default parameters are
+covered in the next section.
+
+If the initialization begins with C<=>, then it is output on
+the same line where the input variable is declared. If the
+initialization begins with C<;> or C<+>, then it is output after
+all of the input variables have been declared. The C<=> and C<;>
+cases replace the initialization normally supplied from the typemap.
+For the C<+> case, the initialization from the typemap will preceed
+the initialization code included after the C<+>. A global
+variable, C<%v>, is available for the truely rare case where
+information from one initialization is needed in another
+initialization.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ time_t &timep ; /*\$v{time}=@{[$v{time}=$arg]}*/
+ char *host + SvOK($v{time}) ? SvPV($arg,PL_na) : NULL;
+ OUTPUT:
+ timep
+
+=head2 Default Parameter Values
+
+Default values can be specified for function parameters by
+placing an assignment statement in the parameter list. The
+default value may be a number or a string. Defaults should
+always be used on the right-most parameters only.
+
+To allow the XSUB for rpcb_gettime() to have a default host
+value the parameters to the XSUB could be rearranged. The
+XSUB will then call the real rpcb_gettime() function with
+the parameters in the correct order. Perl will call this
+XSUB with either of the following statements.
+
+ $status = rpcb_gettime( $timep, $host );
+
+ $status = rpcb_gettime( $timep );
+
+The XSUB will look like the code which follows. A CODE:
+block is used to call the real rpcb_gettime() function with
+the parameters in the correct order for that function.
+
+ bool_t
+ rpcb_gettime(timep,host="localhost")
+ char *host
+ time_t timep = NO_INIT
+ CODE:
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 The PREINIT: Keyword
+
+The PREINIT: keyword allows extra variables to be declared before the
+typemaps are expanded. If a variable is declared in a CODE: block then that
+variable will follow any typemap code. This may result in a C syntax
+error. To force the variable to be declared before the typemap code, place
+it into a PREINIT: block. The PREINIT: keyword may be used one or more
+times within an XSUB.
+
+The following examples are equivalent, but if the code is using complex
+typemaps then the first example is safer.
+
+ bool_t
+ rpcb_gettime(timep)
+ time_t timep = NO_INIT
+ PREINIT:
+ char *host = "localhost";
+ CODE:
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+A correct, but error-prone example.
+
+ bool_t
+ rpcb_gettime(timep)
+ time_t timep = NO_INIT
+ CODE:
+ char *host = "localhost";
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 The SCOPE: Keyword
+
+The SCOPE: keyword allows scoping to be enabled for a particular XSUB. If
+enabled, the XSUB will invoke ENTER and LEAVE automatically.
+
+To support potentially complex type mappings, if a typemap entry used
+by this XSUB contains a comment like C</*scope*/> then scoping will
+automatically be enabled for that XSUB.
+
+To enable scoping:
+
+ SCOPE: ENABLE
+
+To disable scoping:
+
+ SCOPE: DISABLE
+
+=head2 The INPUT: Keyword
+
+The XSUB's parameters are usually evaluated immediately after entering the
+XSUB. The INPUT: keyword can be used to force those parameters to be
+evaluated a little later. The INPUT: keyword can be used multiple times
+within an XSUB and can be used to list one or more input variables. This
+keyword is used with the PREINIT: keyword.
+
+The following example shows how the input parameter C<timep> can be
+evaluated late, after a PREINIT.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ PREINIT:
+ time_t tt;
+ INPUT:
+ time_t timep
+ CODE:
+ RETVAL = rpcb_gettime( host, &tt );
+ timep = tt;
+ OUTPUT:
+ timep
+ RETVAL
+
+The next example shows each input parameter evaluated late.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ PREINIT:
+ time_t tt;
+ INPUT:
+ char *host
+ PREINIT:
+ char *h;
+ INPUT:
+ time_t timep
+ CODE:
+ h = host;
+ RETVAL = rpcb_gettime( h, &tt );
+ timep = tt;
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 Variable-length Parameter Lists
+
+XSUBs can have variable-length parameter lists by specifying an ellipsis
+C<(...)> in the parameter list. This use of the ellipsis is similar to that
+found in ANSI C. The programmer is able to determine the number of
+arguments passed to the XSUB by examining the C<items> variable which the
+B<xsubpp> compiler supplies for all XSUBs. By using this mechanism one can
+create an XSUB which accepts a list of parameters of unknown length.
+
+The I<host> parameter for the rpcb_gettime() XSUB can be
+optional so the ellipsis can be used to indicate that the
+XSUB will take a variable number of parameters. Perl should
+be able to call this XSUB with either of the following statements.
+
+ $status = rpcb_gettime( $timep, $host );
+
+ $status = rpcb_gettime( $timep );
+
+The XS code, with ellipsis, follows.
+
+ bool_t
+ rpcb_gettime(timep, ...)
+ time_t timep = NO_INIT
+ PREINIT:
+ char *host = "localhost";
+ CODE:
+ if( items > 1 )
+ host = (char *)SvPV(ST(1), PL_na);
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 The C_ARGS: Keyword
+
+The C_ARGS: keyword allows creating of XSUBS which have different
+calling sequence from Perl than from C, without a need to write
+CODE: or CPPCODE: section. The contents of the C_ARGS: paragraph is
+put as the argument to the called C function without any change.
+
+For example, suppose that C function is declared as
+
+ symbolic nth_derivative(int n, symbolic function, int flags);
+
+and that the default flags are kept in a global C variable
+C<default_flags>. Suppose that you want to create an interface which
+is called as
+
+ $second_deriv = $function->nth_derivative(2);
+
+To do this, declare the XSUB as
+
+ symbolic
+ nth_derivative(function, n)
+ symbolic function
+ int n
+ C_ARGS:
+ n, function, default_flags
+
+=head2 The PPCODE: Keyword
+
+The PPCODE: keyword is an alternate form of the CODE: keyword and is used
+to tell the B<xsubpp> compiler that the programmer is supplying the code to
+control the argument stack for the XSUBs return values. Occasionally one
+will want an XSUB to return a list of values rather than a single value.
+In these cases one must use PPCODE: and then explicitly push the list of
+values on the stack. The PPCODE: and CODE: keywords are not used
+together within the same XSUB.
+
+The following XSUB will call the C rpcb_gettime() function
+and will return its two output values, timep and status, to
+Perl as a single list.
+
+ void
+ rpcb_gettime(host)
+ char *host
+ PREINIT:
+ time_t timep;
+ bool_t status;
+ PPCODE:
+ status = rpcb_gettime( host, &timep );
+ EXTEND(SP, 2);
+ PUSHs(sv_2mortal(newSViv(status)));
+ PUSHs(sv_2mortal(newSViv(timep)));
+
+Notice that the programmer must supply the C code necessary
+to have the real rpcb_gettime() function called and to have
+the return values properly placed on the argument stack.
+
+The C<void> return type for this function tells the B<xsubpp> compiler that
+the RETVAL variable is not needed or used and that it should not be created.
+In most scenarios the void return type should be used with the PPCODE:
+directive.
+
+The EXTEND() macro is used to make room on the argument
+stack for 2 return values. The PPCODE: directive causes the
+B<xsubpp> compiler to create a stack pointer available as C<SP>, and it
+is this pointer which is being used in the EXTEND() macro.
+The values are then pushed onto the stack with the PUSHs()
+macro.
+
+Now the rpcb_gettime() function can be used from Perl with
+the following statement.
+
+ ($status, $timep) = rpcb_gettime("localhost");
+
+When handling output parameters with a PPCODE section, be sure to handle
+'set' magic properly. See L<perlguts> for details about 'set' magic.
+
+=head2 Returning Undef And Empty Lists
+
+Occasionally the programmer will want to return simply
+C<undef> or an empty list if a function fails rather than a
+separate status value. The rpcb_gettime() function offers
+just this situation. If the function succeeds we would like
+to have it return the time and if it fails we would like to
+have undef returned. In the following Perl code the value
+of $timep will either be undef or it will be a valid time.
+
+ $timep = rpcb_gettime( "localhost" );
+
+The following XSUB uses the C<SV *> return type as a mnemonic only,
+and uses a CODE: block to indicate to the compiler
+that the programmer has supplied all the necessary code. The
+sv_newmortal() call will initialize the return value to undef, making that
+the default return value.
+
+ SV *
+ rpcb_gettime(host)
+ char * host
+ PREINIT:
+ time_t timep;
+ bool_t x;
+ CODE:
+ ST(0) = sv_newmortal();
+ if( rpcb_gettime( host, &timep ) )
+ sv_setnv( ST(0), (double)timep);
+
+The next example demonstrates how one would place an explicit undef in the
+return value, should the need arise.
+
+ SV *
+ rpcb_gettime(host)
+ char * host
+ PREINIT:
+ time_t timep;
+ bool_t x;
+ CODE:
+ ST(0) = sv_newmortal();
+ if( rpcb_gettime( host, &timep ) ){
+ sv_setnv( ST(0), (double)timep);
+ }
+ else{
+ ST(0) = &PL_sv_undef;
+ }
+
+To return an empty list one must use a PPCODE: block and
+then not push return values on the stack.
+
+ void
+ rpcb_gettime(host)
+ char *host
+ PREINIT:
+ time_t timep;
+ PPCODE:
+ if( rpcb_gettime( host, &timep ) )
+ PUSHs(sv_2mortal(newSViv(timep)));
+ else{
+ /* Nothing pushed on stack, so an empty */
+ /* list is implicitly returned. */
+ }
+
+Some people may be inclined to include an explicit C<return> in the above
+XSUB, rather than letting control fall through to the end. In those
+situations C<XSRETURN_EMPTY> should be used, instead. This will ensure that
+the XSUB stack is properly adjusted. Consult L<perlguts/"API LISTING"> for
+other C<XSRETURN> macros.
+
+=head2 The REQUIRE: Keyword
+
+The REQUIRE: keyword is used to indicate the minimum version of the
+B<xsubpp> compiler needed to compile the XS module. An XS module which
+contains the following statement will compile with only B<xsubpp> version
+1.922 or greater:
+
+ REQUIRE: 1.922
+
+=head2 The CLEANUP: Keyword
+
+This keyword can be used when an XSUB requires special cleanup procedures
+before it terminates. When the CLEANUP: keyword is used it must follow
+any CODE:, PPCODE:, or OUTPUT: blocks which are present in the XSUB. The
+code specified for the cleanup block will be added as the last statements
+in the XSUB.
+
+=head2 The BOOT: Keyword
+
+The BOOT: keyword is used to add code to the extension's bootstrap
+function. The bootstrap function is generated by the B<xsubpp> compiler and
+normally holds the statements necessary to register any XSUBs with Perl.
+With the BOOT: keyword the programmer can tell the compiler to add extra
+statements to the bootstrap function.
+
+This keyword may be used any time after the first MODULE keyword and should
+appear on a line by itself. The first blank line after the keyword will
+terminate the code block.
+
+ BOOT:
+ # The following message will be printed when the
+ # bootstrap function executes.
+ printf("Hello from the bootstrap!\n");
+
+=head2 The VERSIONCHECK: Keyword
+
+The VERSIONCHECK: keyword corresponds to B<xsubpp>'s C<-versioncheck> and
+C<-noversioncheck> options. This keyword overrides the command line
+options. Version checking is enabled by default. When version checking is
+enabled the XS module will attempt to verify that its version matches the
+version of the PM module.
+
+To enable version checking:
+
+ VERSIONCHECK: ENABLE
+
+To disable version checking:
+
+ VERSIONCHECK: DISABLE
+
+=head2 The PROTOTYPES: Keyword
+
+The PROTOTYPES: keyword corresponds to B<xsubpp>'s C<-prototypes> and
+C<-noprototypes> options. This keyword overrides the command line options.
+Prototypes are enabled by default. When prototypes are enabled XSUBs will
+be given Perl prototypes. This keyword may be used multiple times in an XS
+module to enable and disable prototypes for different parts of the module.
+
+To enable prototypes:
+
+ PROTOTYPES: ENABLE
+
+To disable prototypes:
+
+ PROTOTYPES: DISABLE
+
+=head2 The PROTOTYPE: Keyword
+
+This keyword is similar to the PROTOTYPES: keyword above but can be used to
+force B<xsubpp> to use a specific prototype for the XSUB. This keyword
+overrides all other prototype options and keywords but affects only the
+current XSUB. Consult L<perlsub/Prototypes> for information about Perl
+prototypes.
+
+ bool_t
+ rpcb_gettime(timep, ...)
+ time_t timep = NO_INIT
+ PROTOTYPE: $;$
+ PREINIT:
+ char *host = "localhost";
+ CODE:
+ if( items > 1 )
+ host = (char *)SvPV(ST(1), PL_na);
+ RETVAL = rpcb_gettime( host, &timep );
+ OUTPUT:
+ timep
+ RETVAL
+
+=head2 The ALIAS: Keyword
+
+The ALIAS: keyword allows an XSUB to have two or more unique Perl names
+and to know which of those names was used when it was invoked. The Perl
+names may be fully-qualified with package names. Each alias is given an
+index. The compiler will setup a variable called C<ix> which contain the
+index of the alias which was used. When the XSUB is called with its
+declared name C<ix> will be 0.
+
+The following example will create aliases C<FOO::gettime()> and
+C<BAR::getit()> for this function.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ ALIAS:
+ FOO::gettime = 1
+ BAR::getit = 2
+ INIT:
+ printf("# ix = %d\n", ix );
+ OUTPUT:
+ timep
+
+=head2 The INTERFACE: Keyword
+
+This keyword declares the current XSUB as a keeper of the given
+calling signature. If some text follows this keyword, it is
+considered as a list of functions which have this signature, and
+should be attached to XSUBs.
+
+Say, if you have 4 functions multiply(), divide(), add(), subtract() all
+having the signature
+
+ symbolic f(symbolic, symbolic);
+
+you code them all by using XSUB
+
+ symbolic
+ interface_s_ss(arg1, arg2)
+ symbolic arg1
+ symbolic arg2
+ INTERFACE:
+ multiply divide
+ add subtract
+
+The advantage of this approach comparing to ALIAS: keyword is that one
+can attach an extra function remainder() at runtime by using
+
+ CV *mycv = newXSproto("Symbolic::remainder",
+ XS_Symbolic_interface_s_ss, __FILE__, "$$");
+ XSINTERFACE_FUNC_SET(mycv, remainder);
+
+(This example supposes that there was no INTERFACE_MACRO: section,
+otherwise one needs to use something else instead of
+C<XSINTERFACE_FUNC_SET>.)
+
+=head2 The INTERFACE_MACRO: Keyword
+
+This keyword allows one to define an INTERFACE using a different way
+to extract a function pointer from an XSUB. The text which follows
+this keyword should give the name of macros which would extract/set a
+function pointer. The extractor macro is given return type, C<CV*>,
+and C<XSANY.any_dptr> for this C<CV*>. The setter macro is given cv,
+and the function pointer.
+
+The default value is C<XSINTERFACE_FUNC> and C<XSINTERFACE_FUNC_SET>.
+An INTERFACE keyword with an empty list of functions can be omitted if
+INTERFACE_MACRO keyword is used.
+
+Suppose that in the previous example functions pointers for
+multiply(), divide(), add(), subtract() are kept in a global C array
+C<fp[]> with offsets being C<multiply_off>, C<divide_off>, C<add_off>,
+C<subtract_off>. Then one can use
+
+ #define XSINTERFACE_FUNC_BYOFFSET(ret,cv,f) \
+ ((XSINTERFACE_CVT(ret,))fp[CvXSUBANY(cv).any_i32])
+ #define XSINTERFACE_FUNC_BYOFFSET_set(cv,f) \
+ CvXSUBANY(cv).any_i32 = CAT2( f, _off )
+
+in C section,
+
+ symbolic
+ interface_s_ss(arg1, arg2)
+ symbolic arg1
+ symbolic arg2
+ INTERFACE_MACRO:
+ XSINTERFACE_FUNC_BYOFFSET
+ XSINTERFACE_FUNC_BYOFFSET_set
+ INTERFACE:
+ multiply divide
+ add subtract
+
+in XSUB section.
+
+=head2 The INCLUDE: Keyword
+
+This keyword can be used to pull other files into the XS module. The other
+files may have XS code. INCLUDE: can also be used to run a command to
+generate the XS code to be pulled into the module.
+
+The file F<Rpcb1.xsh> contains our C<rpcb_gettime()> function:
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ OUTPUT:
+ timep
+
+The XS module can use INCLUDE: to pull that file into it.
+
+ INCLUDE: Rpcb1.xsh
+
+If the parameters to the INCLUDE: keyword are followed by a pipe (C<|>) then
+the compiler will interpret the parameters as a command.
+
+ INCLUDE: cat Rpcb1.xsh |
+
+=head2 The CASE: Keyword
+
+The CASE: keyword allows an XSUB to have multiple distinct parts with each
+part acting as a virtual XSUB. CASE: is greedy and if it is used then all
+other XS keywords must be contained within a CASE:. This means nothing may
+precede the first CASE: in the XSUB and anything following the last CASE: is
+included in that case.
+
+A CASE: might switch via a parameter of the XSUB, via the C<ix> ALIAS:
+variable (see L<"The ALIAS: Keyword">), or maybe via the C<items> variable
+(see L<"Variable-length Parameter Lists">). The last CASE: becomes the
+B<default> case if it is not associated with a conditional. The following
+example shows CASE switched via C<ix> with a function C<rpcb_gettime()>
+having an alias C<x_gettime()>. When the function is called as
+C<rpcb_gettime()> its parameters are the usual C<(char *host, time_t *timep)>,
+but when the function is called as C<x_gettime()> its parameters are
+reversed, C<(time_t *timep, char *host)>.
+
+ long
+ rpcb_gettime(a,b)
+ CASE: ix == 1
+ ALIAS:
+ x_gettime = 1
+ INPUT:
+ # 'a' is timep, 'b' is host
+ char *b
+ time_t a = NO_INIT
+ CODE:
+ RETVAL = rpcb_gettime( b, &a );
+ OUTPUT:
+ a
+ RETVAL
+ CASE:
+ # 'a' is host, 'b' is timep
+ char *a
+ time_t &b = NO_INIT
+ OUTPUT:
+ b
+ RETVAL
+
+That function can be called with either of the following statements. Note
+the different argument lists.
+
+ $status = rpcb_gettime( $host, $timep );
+
+ $status = x_gettime( $timep, $host );
+
+=head2 The & Unary Operator
+
+The & unary operator is used to tell the compiler that it should dereference
+the object when it calls the C function. This is used when a CODE: block is
+not used and the object is a not a pointer type (the object is an C<int> or
+C<long> but not a C<int*> or C<long*>).
+
+The following XSUB will generate incorrect C code. The xsubpp compiler will
+turn this into code which calls C<rpcb_gettime()> with parameters C<(char
+*host, time_t timep)>, but the real C<rpcb_gettime()> wants the C<timep>
+parameter to be of type C<time_t*> rather than C<time_t>.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t timep
+ OUTPUT:
+ timep
+
+That problem is corrected by using the C<&> operator. The xsubpp compiler
+will now turn this into code which calls C<rpcb_gettime()> correctly with
+parameters C<(char *host, time_t *timep)>. It does this by carrying the
+C<&> through, so the function call looks like C<rpcb_gettime(host, &timep)>.
+
+ bool_t
+ rpcb_gettime(host,timep)
+ char *host
+ time_t &timep
+ OUTPUT:
+ timep
+
+=head2 Inserting Comments and C Preprocessor Directives
+
+C preprocessor directives are allowed within BOOT:, PREINIT: INIT:,
+CODE:, PPCODE:, and CLEANUP: blocks, as well as outside the functions.
+Comments are allowed anywhere after the MODULE keyword. The compiler
+will pass the preprocessor directives through untouched and will remove
+the commented lines.
+
+Comments can be added to XSUBs by placing a C<#> as the first
+non-whitespace of a line. Care should be taken to avoid making the
+comment look like a C preprocessor directive, lest it be interpreted as
+such. The simplest way to prevent this is to put whitespace in front of
+the C<#>.
+
+If you use preprocessor directives to choose one of two
+versions of a function, use
+
+ #if ... version1
+ #else /* ... version2 */
+ #endif
+
+and not
+
+ #if ... version1
+ #endif
+ #if ... version2
+ #endif
+
+because otherwise xsubpp will believe that you made a duplicate
+definition of the function. Also, put a blank line before the
+#else/#endif so it will not be seen as part of the function body.
+
+=head2 Using XS With C++
+
+If a function is defined as a C++ method then it will assume
+its first argument is an object pointer. The object pointer
+will be stored in a variable called THIS. The object should
+have been created by C++ with the new() function and should
+be blessed by Perl with the sv_setref_pv() macro. The
+blessing of the object by Perl can be handled by a typemap. An example
+typemap is shown at the end of this section.
+
+If the method is defined as static it will call the C++
+function using the class::method() syntax. If the method is not static
+the function will be called using the THIS-E<gt>method() syntax.
+
+The next examples will use the following C++ class.
+
+ class color {
+ public:
+ color();
+ ~color();
+ int blue();
+ void set_blue( int );
+
+ private:
+ int c_blue;
+ };
+
+The XSUBs for the blue() and set_blue() methods are defined with the class
+name but the parameter for the object (THIS, or "self") is implicit and is
+not listed.
+
+ int
+ color::blue()
+
+ void
+ color::set_blue( val )
+ int val
+
+Both functions will expect an object as the first parameter. The xsubpp
+compiler will call that object C<THIS> and will use it to call the specified
+method. So in the C++ code the blue() and set_blue() methods will be called
+in the following manner.
+
+ RETVAL = THIS->blue();
+
+ THIS->set_blue( val );
+
+If the function's name is B<DESTROY> then the C++ C<delete> function will be
+called and C<THIS> will be given as its parameter.
+
+ void
+ color::DESTROY()
+
+The C++ code will call C<delete>.
+
+ delete THIS;
+
+If the function's name is B<new> then the C++ C<new> function will be called
+to create a dynamic C++ object. The XSUB will expect the class name, which
+will be kept in a variable called C<CLASS>, to be given as the first
+argument.
+
+ color *
+ color::new()
+
+The C++ code will call C<new>.
+
+ RETVAL = new color();
+
+The following is an example of a typemap that could be used for this C++
+example.
+
+ TYPEMAP
+ color * O_OBJECT
+
+ OUTPUT
+ # The Perl object is blessed into 'CLASS', which should be a
+ # char* having the name of the package for the blessing.
+ O_OBJECT
+ sv_setref_pv( $arg, CLASS, (void*)$var );
+
+ INPUT
+ O_OBJECT
+ if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
+ $var = ($type)SvIV((SV*)SvRV( $arg ));
+ else{
+ warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
+ XSRETURN_UNDEF;
+ }
+
+=head2 Interface Strategy
+
+When designing an interface between Perl and a C library a straight
+translation from C to XS is often sufficient. The interface will often be
+very C-like and occasionally nonintuitive, especially when the C function
+modifies one of its parameters. In cases where the programmer wishes to
+create a more Perl-like interface the following strategy may help to
+identify the more critical parts of the interface.
+
+Identify the C functions which modify their parameters. The XSUBs for
+these functions may be able to return lists to Perl, or may be
+candidates to return undef or an empty list in case of failure.
+
+Identify which values are used by only the C and XSUB functions
+themselves. If Perl does not need to access the contents of the value
+then it may not be necessary to provide a translation for that value
+from C to Perl.
+
+Identify the pointers in the C function parameter lists and return
+values. Some pointers can be handled in XS with the & unary operator on
+the variable name while others will require the use of the * operator on
+the type name. In general it is easier to work with the & operator.
+
+Identify the structures used by the C functions. In many
+cases it may be helpful to use the T_PTROBJ typemap for
+these structures so they can be manipulated by Perl as
+blessed objects.
+
+=head2 Perl Objects And C Structures
+
+When dealing with C structures one should select either
+B<T_PTROBJ> or B<T_PTRREF> for the XS type. Both types are
+designed to handle pointers to complex objects. The
+T_PTRREF type will allow the Perl object to be unblessed
+while the T_PTROBJ type requires that the object be blessed.
+By using T_PTROBJ one can achieve a form of type-checking
+because the XSUB will attempt to verify that the Perl object
+is of the expected type.
+
+The following XS code shows the getnetconfigent() function which is used
+with ONC+ TIRPC. The getnetconfigent() function will return a pointer to a
+C structure and has the C prototype shown below. The example will
+demonstrate how the C pointer will become a Perl reference. Perl will
+consider this reference to be a pointer to a blessed object and will
+attempt to call a destructor for the object. A destructor will be
+provided in the XS source to free the memory used by getnetconfigent().
+Destructors in XS can be created by specifying an XSUB function whose name
+ends with the word B<DESTROY>. XS destructors can be used to free memory
+which may have been malloc'd by another XSUB.
+
+ struct netconfig *getnetconfigent(const char *netid);
+
+A C<typedef> will be created for C<struct netconfig>. The Perl
+object will be blessed in a class matching the name of the C
+type, with the tag C<Ptr> appended, and the name should not
+have embedded spaces if it will be a Perl package name. The
+destructor will be placed in a class corresponding to the
+class of the object and the PREFIX keyword will be used to
+trim the name to the word DESTROY as Perl will expect.
+
+ typedef struct netconfig Netconfig;
+
+ MODULE = RPC PACKAGE = RPC
+
+ Netconfig *
+ getnetconfigent(netid)
+ char *netid
+
+ MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_
+
+ void
+ rpcb_DESTROY(netconf)
+ Netconfig *netconf
+ CODE:
+ printf("Now in NetconfigPtr::DESTROY\n");
+ free( netconf );
+
+This example requires the following typemap entry. Consult the typemap
+section for more information about adding new typemaps for an extension.
+
+ TYPEMAP
+ Netconfig * T_PTROBJ
+
+This example will be used with the following Perl statements.
+
+ use RPC;
+ $netconf = getnetconfigent("udp");
+
+When Perl destroys the object referenced by $netconf it will send the
+object to the supplied XSUB DESTROY function. Perl cannot determine, and
+does not care, that this object is a C struct and not a Perl object. In
+this sense, there is no difference between the object created by the
+getnetconfigent() XSUB and an object created by a normal Perl subroutine.
+
+=head2 The Typemap
+
+The typemap is a collection of code fragments which are used by the B<xsubpp>
+compiler to map C function parameters and values to Perl values. The
+typemap file may consist of three sections labeled C<TYPEMAP>, C<INPUT>, and
+C<OUTPUT>. The INPUT section tells the compiler how to translate Perl values
+into variables of certain C types. The OUTPUT section tells the compiler
+how to translate the values from certain C types into values Perl can
+understand. The TYPEMAP section tells the compiler which of the INPUT and
+OUTPUT code fragments should be used to map a given C type to a Perl value.
+Each of the sections of the typemap must be preceded by one of the TYPEMAP,
+INPUT, or OUTPUT keywords.
+
+The default typemap in the C<ext> directory of the Perl source contains many
+useful types which can be used by Perl extensions. Some extensions define
+additional typemaps which they keep in their own directory. These
+additional typemaps may reference INPUT and OUTPUT maps in the main
+typemap. The B<xsubpp> compiler will allow the extension's own typemap to
+override any mappings which are in the default typemap.
+
+Most extensions which require a custom typemap will need only the TYPEMAP
+section of the typemap file. The custom typemap used in the
+getnetconfigent() example shown earlier demonstrates what may be the typical
+use of extension typemaps. That typemap is used to equate a C structure
+with the T_PTROBJ typemap. The typemap used by getnetconfigent() is shown
+here. Note that the C type is separated from the XS type with a tab and
+that the C unary operator C<*> is considered to be a part of the C type name.
+
+ TYPEMAP
+ Netconfig *<tab>T_PTROBJ
+
+Here's a more complicated example: suppose that you wanted C<struct
+netconfig> to be blessed into the class C<Net::Config>. One way to do
+this is to use underscores (_) to separate package names, as follows:
+
+ typedef struct netconfig * Net_Config;
+
+And then provide a typemap entry C<T_PTROBJ_SPECIAL> that maps underscores to
+double-colons (::), and declare C<Net_Config> to be of that type:
+
+
+ TYPEMAP
+ Net_Config T_PTROBJ_SPECIAL
+
+ INPUT
+ T_PTROBJ_SPECIAL
+ if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")) {
+ IV tmp = SvIV((SV*)SvRV($arg));
+ $var = ($type) tmp;
+ }
+ else
+ croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")
+
+ OUTPUT
+ T_PTROBJ_SPECIAL
+ sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\",
+ (void*)$var);
+
+The INPUT and OUTPUT sections substitute underscores for double-colons
+on the fly, giving the desired effect. This example demonstrates some
+of the power and versatility of the typemap facility.
+
+=head1 EXAMPLES
+
+File C<RPC.xs>: Interface to some ONC+ RPC bind library functions.
+
+ #include "EXTERN.h"
+ #include "perl.h"
+ #include "XSUB.h"
+
+ #include <rpc/rpc.h>
+
+ typedef struct netconfig Netconfig;
+
+ MODULE = RPC PACKAGE = RPC
+
+ SV *
+ rpcb_gettime(host="localhost")
+ char *host
+ PREINIT:
+ time_t timep;
+ CODE:
+ ST(0) = sv_newmortal();
+ if( rpcb_gettime( host, &timep ) )
+ sv_setnv( ST(0), (double)timep );
+
+ Netconfig *
+ getnetconfigent(netid="udp")
+ char *netid
+
+ MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_
+
+ void
+ rpcb_DESTROY(netconf)
+ Netconfig *netconf
+ CODE:
+ printf("NetconfigPtr::DESTROY\n");
+ free( netconf );
+
+File C<typemap>: Custom typemap for RPC.xs.
+
+ TYPEMAP
+ Netconfig * T_PTROBJ
+
+File C<RPC.pm>: Perl module for the RPC extension.
+
+ package RPC;
+
+ require Exporter;
+ require DynaLoader;
+ @ISA = qw(Exporter DynaLoader);
+ @EXPORT = qw(rpcb_gettime getnetconfigent);
+
+ bootstrap RPC;
+ 1;
+
+File C<rpctest.pl>: Perl test program for the RPC extension.
+
+ use RPC;
+
+ $netconf = getnetconfigent();
+ $a = rpcb_gettime();
+ print "time = $a\n";
+ print "netconf = $netconf\n";
+
+ $netconf = getnetconfigent("tcp");
+ $a = rpcb_gettime("poplar");
+ print "time = $a\n";
+ print "netconf = $netconf\n";
+
+
+=head1 XS VERSION
+
+This document covers features supported by C<xsubpp> 1.935.
+
+=head1 AUTHOR
+
+Dean Roehrich <F<roehrich@cray.com>>
+Jul 8, 1996
diff --git a/contrib/perl5/pod/perlxstut.pod b/contrib/perl5/pod/perlxstut.pod
new file mode 100644
index 0000000..867d42a
--- /dev/null
+++ b/contrib/perl5/pod/perlxstut.pod
@@ -0,0 +1,739 @@
+=head1 NAME
+
+perlXStut - Tutorial for XSUBs
+
+=head1 DESCRIPTION
+
+This tutorial will educate the reader on the steps involved in creating
+a Perl extension. The reader is assumed to have access to L<perlguts> and
+L<perlxs>.
+
+This tutorial starts with very simple examples and becomes more complex,
+with each new example adding new features. Certain concepts may not be
+completely explained until later in the tutorial to ease the
+reader slowly into building extensions.
+
+=head2 VERSION CAVEAT
+
+This tutorial tries hard to keep up with the latest development versions
+of Perl. This often means that it is sometimes in advance of the latest
+released version of Perl, and that certain features described here might
+not work on earlier versions. This section will keep track of when various
+features were added to Perl 5.
+
+=over 4
+
+=item *
+
+In versions of Perl 5.002 prior to the gamma version, the test script
+in Example 1 will not function properly. You need to change the "use
+lib" line to read:
+
+ use lib './blib';
+
+=item *
+
+In versions of Perl 5.002 prior to version beta 3, the line in the .xs file
+about "PROTOTYPES: DISABLE" will cause a compiler error. Simply remove that
+line from the file.
+
+=item *
+
+In versions of Perl 5.002 prior to version 5.002b1h, the test.pl file was not
+automatically created by h2xs. This means that you cannot say "make test"
+to run the test script. You will need to add the following line before the
+"use extension" statement:
+
+ use lib './blib';
+
+=item *
+
+In versions 5.000 and 5.001, instead of using the above line, you will need
+to use the following line:
+
+ BEGIN { unshift(@INC, "./blib") }
+
+=item *
+
+This document assumes that the executable named "perl" is Perl version 5.
+Some systems may have installed Perl version 5 as "perl5".
+
+=back
+
+=head2 DYNAMIC VERSUS STATIC
+
+It is commonly thought that if a system does not have the capability to
+load a library dynamically, you cannot build XSUBs. This is incorrect.
+You I<can> build them, but you must link the XSUB's subroutines with the
+rest of Perl, creating a new executable. This situation is similar to
+Perl 4.
+
+This tutorial can still be used on such a system. The XSUB build mechanism
+will check the system and build a dynamically-loadable library if possible,
+or else a static library and then, optionally, a new statically-linked
+executable with that static library linked in.
+
+Should you wish to build a statically-linked executable on a system which
+can dynamically load libraries, you may, in all the following examples,
+where the command "make" with no arguments is executed, run the command
+"make perl" instead.
+
+If you have generated such a statically-linked executable by choice, then
+instead of saying "make test", you should say "make test_static". On systems
+that cannot build dynamically-loadable libraries at all, simply saying "make
+test" is sufficient.
+
+=head2 EXAMPLE 1
+
+Our first extension will be very simple. When we call the routine in the
+extension, it will print out a well-known message and return.
+
+Run C<h2xs -A -n Mytest>. This creates a directory named Mytest, possibly under
+ext/ if that directory exists in the current working directory. Several files
+will be created in the Mytest dir, including MANIFEST, Makefile.PL, Mytest.pm,
+Mytest.xs, test.pl, and Changes.
+
+The MANIFEST file contains the names of all the files created.
+
+The file Makefile.PL should look something like this:
+
+ use ExtUtils::MakeMaker;
+ # See lib/ExtUtils/MakeMaker.pm for details of how to influence
+ # the contents of the Makefile that is written.
+ WriteMakefile(
+ 'NAME' => 'Mytest',
+ 'VERSION_FROM' => 'Mytest.pm', # finds $VERSION
+ 'LIBS' => [''], # e.g., '-lm'
+ 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
+ 'INC' => '', # e.g., '-I/usr/include/other'
+ );
+
+The file Mytest.pm should start with something like this:
+
+ package Mytest;
+
+ require Exporter;
+ require DynaLoader;
+
+ @ISA = qw(Exporter DynaLoader);
+ # Items to export into callers namespace by default. Note: do not export
+ # names by default without a very good reason. Use EXPORT_OK instead.
+ # Do not simply export all your public functions/methods/constants.
+ @EXPORT = qw(
+
+ );
+ $VERSION = '0.01';
+
+ bootstrap Mytest $VERSION;
+
+ # Preloaded methods go here.
+
+ # Autoload methods go after __END__, and are processed by the autosplit program.
+
+ 1;
+ __END__
+ # Below is the stub of documentation for your module. You better edit it!
+
+And the Mytest.xs file should look something like this:
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ #include "EXTERN.h"
+ #include "perl.h"
+ #include "XSUB.h"
+ #ifdef __cplusplus
+ }
+ #endif
+
+ PROTOTYPES: DISABLE
+
+ MODULE = Mytest PACKAGE = Mytest
+
+Let's edit the .xs file by adding this to the end of the file:
+
+ void
+ hello()
+ CODE:
+ printf("Hello, world!\n");
+
+Now we'll run "perl Makefile.PL". This will create a real Makefile,
+which make needs. Its output looks something like:
+
+ % perl Makefile.PL
+ Checking if your kit is complete...
+ Looks good
+ Writing Makefile for Mytest
+ %
+
+Now, running make will produce output that looks something like this
+(some long lines shortened for clarity):
+
+ % make
+ umask 0 && cp Mytest.pm ./blib/Mytest.pm
+ perl xsubpp -typemap typemap Mytest.xs >Mytest.tc && mv Mytest.tc Mytest.c
+ cc -c Mytest.c
+ Running Mkbootstrap for Mytest ()
+ chmod 644 Mytest.bs
+ LD_RUN_PATH="" ld -o ./blib/PA-RISC1.1/auto/Mytest/Mytest.sl -b Mytest.o
+ chmod 755 ./blib/PA-RISC1.1/auto/Mytest/Mytest.sl
+ cp Mytest.bs ./blib/PA-RISC1.1/auto/Mytest/Mytest.bs
+ chmod 644 ./blib/PA-RISC1.1/auto/Mytest/Mytest.bs
+
+Now, although there is already a test.pl template ready for us, for this
+example only, we'll create a special test script. Create a file called hello
+that looks like this:
+
+ #! /opt/perl5/bin/perl
+
+ use ExtUtils::testlib;
+
+ use Mytest;
+
+ Mytest::hello();
+
+Now we run the script and we should see the following output:
+
+ % perl hello
+ Hello, world!
+ %
+
+=head2 EXAMPLE 2
+
+Now let's add to our extension a subroutine that will take a single argument
+and return 1 if the argument is even, 0 if the argument is odd.
+
+Add the following to the end of Mytest.xs:
+
+ int
+ is_even(input)
+ int input
+ CODE:
+ RETVAL = (input % 2 == 0);
+ OUTPUT:
+ RETVAL
+
+There does not need to be white space at the start of the "int input" line,
+but it is useful for improving readability. The semi-colon at the end of
+that line is also optional.
+
+Any white space may be between the "int" and "input". It is also okay for
+the four lines starting at the "CODE:" line to not be indented. However,
+for readability purposes, it is suggested that you indent them 8 spaces
+(or one normal tab stop).
+
+Now rerun make to rebuild our new shared library.
+
+Now perform the same steps as before, generating a Makefile from the
+Makefile.PL file, and running make.
+
+To test that our extension works, we now need to look at the
+file test.pl. This file is set up to imitate the same kind of testing
+structure that Perl itself has. Within the test script, you perform a
+number of tests to confirm the behavior of the extension, printing "ok"
+when the test is correct, "not ok" when it is not. Change the print
+statement in the BEGIN block to print "1..4", and add the following code
+to the end of the file:
+
+ print &Mytest::is_even(0) == 1 ? "ok 2" : "not ok 2", "\n";
+ print &Mytest::is_even(1) == 0 ? "ok 3" : "not ok 3", "\n";
+ print &Mytest::is_even(2) == 1 ? "ok 4" : "not ok 4", "\n";
+
+We will be calling the test script through the command "make test". You
+should see output that looks something like this:
+
+ % make test
+ PERL_DL_NONLAZY=1 /opt/perl5.002b2/bin/perl (lots of -I arguments) test.pl
+ 1..4
+ ok 1
+ ok 2
+ ok 3
+ ok 4
+ %
+
+=head2 WHAT HAS GONE ON?
+
+The program h2xs is the starting point for creating extensions. In later
+examples we'll see how we can use h2xs to read header files and generate
+templates to connect to C routines.
+
+h2xs creates a number of files in the extension directory. The file
+Makefile.PL is a perl script which will generate a true Makefile to build
+the extension. We'll take a closer look at it later.
+
+The files E<lt>extensionE<gt>.pm and E<lt>extensionE<gt>.xs contain the meat
+of the extension.
+The .xs file holds the C routines that make up the extension. The .pm file
+contains routines that tell Perl how to load your extension.
+
+Generating and invoking the Makefile created a directory blib (which stands
+for "build library") in the current working directory. This directory will
+contain the shared library that we will build. Once we have tested it, we
+can install it into its final location.
+
+Invoking the test script via "make test" did something very important. It
+invoked perl with all those C<-I> arguments so that it could find the various
+files that are part of the extension.
+
+It is I<very> important that while you are still testing extensions that
+you use "make test". If you try to run the test script all by itself, you
+will get a fatal error.
+
+Another reason it is important to use "make test" to run your test script
+is that if you are testing an upgrade to an already-existing version, using
+"make test" insures that you use your new extension, not the already-existing
+version.
+
+When Perl sees a C<use extension;>, it searches for a file with the same name
+as the use'd extension that has a .pm suffix. If that file cannot be found,
+Perl dies with a fatal error. The default search path is contained in the
+@INC array.
+
+In our case, Mytest.pm tells perl that it will need the Exporter and Dynamic
+Loader extensions. It then sets the @ISA and @EXPORT arrays and the $VERSION
+scalar; finally it tells perl to bootstrap the module. Perl will call its
+dynamic loader routine (if there is one) and load the shared library.
+
+The two arrays that are set in the .pm file are very important. The @ISA
+array contains a list of other packages in which to search for methods (or
+subroutines) that do not exist in the current package. The @EXPORT array
+tells Perl which of the extension's routines should be placed into the
+calling package's namespace.
+
+It's important to select what to export carefully. Do NOT export method names
+and do NOT export anything else I<by default> without a good reason.
+
+As a general rule, if the module is trying to be object-oriented then don't
+export anything. If it's just a collection of functions then you can export
+any of the functions via another array, called @EXPORT_OK.
+
+See L<perlmod> for more information.
+
+The $VERSION variable is used to ensure that the .pm file and the shared
+library are "in sync" with each other. Any time you make changes to
+the .pm or .xs files, you should increment the value of this variable.
+
+=head2 WRITING GOOD TEST SCRIPTS
+
+The importance of writing good test scripts cannot be overemphasized. You
+should closely follow the "ok/not ok" style that Perl itself uses, so that
+it is very easy and unambiguous to determine the outcome of each test case.
+When you find and fix a bug, make sure you add a test case for it.
+
+By running "make test", you ensure that your test.pl script runs and uses
+the correct version of your extension. If you have many test cases, you
+might want to copy Perl's test style. Create a directory named "t", and
+ensure all your test files end with the suffix ".t". The Makefile will
+properly run all these test files.
+
+
+=head2 EXAMPLE 3
+
+Our third extension will take one argument as its input, round off that
+value, and set the I<argument> to the rounded value.
+
+Add the following to the end of Mytest.xs:
+
+ void
+ round(arg)
+ double arg
+ CODE:
+ if (arg > 0.0) {
+ arg = floor(arg + 0.5);
+ } else if (arg < 0.0) {
+ arg = ceil(arg - 0.5);
+ } else {
+ arg = 0.0;
+ }
+ OUTPUT:
+ arg
+
+Edit the Makefile.PL file so that the corresponding line looks like this:
+
+ 'LIBS' => ['-lm'], # e.g., '-lm'
+
+Generate the Makefile and run make. Change the BEGIN block to print out
+"1..9" and add the following to test.pl:
+
+ $i = -1.5; &Mytest::round($i); print $i == -2.0 ? "ok 5" : "not ok 5", "\n";
+ $i = -1.1; &Mytest::round($i); print $i == -1.0 ? "ok 6" : "not ok 6", "\n";
+ $i = 0.0; &Mytest::round($i); print $i == 0.0 ? "ok 7" : "not ok 7", "\n";
+ $i = 0.5; &Mytest::round($i); print $i == 1.0 ? "ok 8" : "not ok 8", "\n";
+ $i = 1.2; &Mytest::round($i); print $i == 1.0 ? "ok 9" : "not ok 9", "\n";
+
+Running "make test" should now print out that all nine tests are okay.
+
+You might be wondering if you can round a constant. To see what happens, add
+the following line to test.pl temporarily:
+
+ &Mytest::round(3);
+
+Run "make test" and notice that Perl dies with a fatal error. Perl won't let
+you change the value of constants!
+
+=head2 WHAT'S NEW HERE?
+
+Two things are new here. First, we've made some changes to Makefile.PL.
+In this case, we've specified an extra library to link in, the math library
+libm. We'll talk later about how to write XSUBs that can call every routine
+in a library.
+
+Second, the value of the function is being passed back not as the function's
+return value, but through the same variable that was passed into the function.
+
+=head2 INPUT AND OUTPUT PARAMETERS
+
+You specify the parameters that will be passed into the XSUB just after you
+declare the function return value and name. Each parameter line starts with
+optional white space, and may have an optional terminating semicolon.
+
+The list of output parameters occurs after the OUTPUT: directive. The use
+of RETVAL tells Perl that you wish to send this value back as the return
+value of the XSUB function. In Example 3, the value we wanted returned was
+contained in the same variable we passed in, so we listed it (and not RETVAL)
+in the OUTPUT: section.
+
+=head2 THE XSUBPP COMPILER
+
+The compiler xsubpp takes the XS code in the .xs file and converts it into
+C code, placing it in a file whose suffix is .c. The C code created makes
+heavy use of the C functions within Perl.
+
+=head2 THE TYPEMAP FILE
+
+The xsubpp compiler uses rules to convert from Perl's data types (scalar,
+array, etc.) to C's data types (int, char *, etc.). These rules are stored
+in the typemap file ($PERLLIB/ExtUtils/typemap). This file is split into
+three parts.
+
+The first part attempts to map various C data types to a coded flag, which
+has some correspondence with the various Perl types. The second part contains
+C code which xsubpp uses for input parameters. The third part contains C
+code which xsubpp uses for output parameters. We'll talk more about the
+C code later.
+
+Let's now take a look at a portion of the .c file created for our extension.
+
+ XS(XS_Mytest_round)
+ {
+ dXSARGS;
+ if (items != 1)
+ croak("Usage: Mytest::round(arg)");
+ {
+ double arg = (double)SvNV(ST(0)); /* XXXXX */
+ if (arg > 0.0) {
+ arg = floor(arg + 0.5);
+ } else if (arg < 0.0) {
+ arg = ceil(arg - 0.5);
+ } else {
+ arg = 0.0;
+ }
+ sv_setnv(ST(0), (double)arg); /* XXXXX */
+ }
+ XSRETURN(1);
+ }
+
+Notice the two lines marked with "XXXXX". If you check the first section of
+the typemap file, you'll see that doubles are of type T_DOUBLE. In the
+INPUT section, an argument that is T_DOUBLE is assigned to the variable
+arg by calling the routine SvNV on something, then casting it to double,
+then assigned to the variable arg. Similarly, in the OUTPUT section,
+once arg has its final value, it is passed to the sv_setnv function to
+be passed back to the calling subroutine. These two functions are explained
+in L<perlguts>; we'll talk more later about what that "ST(0)" means in the
+section on the argument stack.
+
+=head2 WARNING
+
+In general, it's not a good idea to write extensions that modify their input
+parameters, as in Example 3. However, to accommodate better calling
+pre-existing C routines, which often do modify their input parameters,
+this behavior is tolerated. The next example will show how to do this.
+
+=head2 EXAMPLE 4
+
+In this example, we'll now begin to write XSUBs that will interact with
+predefined C libraries. To begin with, we will build a small library of
+our own, then let h2xs write our .pm and .xs files for us.
+
+Create a new directory called Mytest2 at the same level as the directory
+Mytest. In the Mytest2 directory, create another directory called mylib,
+and cd into that directory.
+
+Here we'll create some files that will generate a test library. These will
+include a C source file and a header file. We'll also create a Makefile.PL
+in this directory. Then we'll make sure that running make at the Mytest2
+level will automatically run this Makefile.PL file and the resulting Makefile.
+
+In the testlib directory, create a file mylib.h that looks like this:
+
+ #define TESTVAL 4
+
+ extern double foo(int, long, const char*);
+
+Also create a file mylib.c that looks like this:
+
+ #include <stdlib.h>
+ #include "./mylib.h"
+
+ double
+ foo(a, b, c)
+ int a;
+ long b;
+ const char * c;
+ {
+ return (a + b + atof(c) + TESTVAL);
+ }
+
+And finally create a file Makefile.PL that looks like this:
+
+ use ExtUtils::MakeMaker;
+ $Verbose = 1;
+ WriteMakefile(
+ NAME => 'Mytest2::mylib',
+ SKIP => [qw(all static static_lib dynamic dynamic_lib)],
+ clean => {'FILES' => 'libmylib$(LIB_EXT)'},
+ );
+
+
+ sub MY::top_targets {
+ '
+ all :: static
+
+ static :: libmylib$(LIB_EXT)
+
+ libmylib$(LIB_EXT): $(O_FILES)
+ $(AR) cr libmylib$(LIB_EXT) $(O_FILES)
+ $(RANLIB) libmylib$(LIB_EXT)
+
+ ';
+ }
+
+We will now create the main top-level Mytest2 files. Change to the directory
+above Mytest2 and run the following command:
+
+ % h2xs -O -n Mytest2 ./Mytest2/mylib/mylib.h
+
+This will print out a warning about overwriting Mytest2, but that's okay.
+Our files are stored in Mytest2/mylib, and will be untouched.
+
+The normal Makefile.PL that h2xs generates doesn't know about the mylib
+directory. We need to tell it that there is a subdirectory and that we
+will be generating a library in it. Let's add the following key-value
+pair to the WriteMakefile call:
+
+ 'MYEXTLIB' => 'mylib/libmylib$(LIB_EXT)',
+
+and a new replacement subroutine too:
+
+ sub MY::postamble {
+ '
+ $(MYEXTLIB): mylib/Makefile
+ cd mylib && $(MAKE) $(PASTHRU)
+ ';
+ }
+
+(Note: Most makes will require that there be a tab character that indents
+the line C<cd mylib && $(MAKE) $(PASTHRU)>, similarly for the Makefile in the
+subdirectory.)
+
+Let's also fix the MANIFEST file so that it accurately reflects the contents
+of our extension. The single line that says "mylib" should be replaced by
+the following three lines:
+
+ mylib/Makefile.PL
+ mylib/mylib.c
+ mylib/mylib.h
+
+To keep our namespace nice and unpolluted, edit the .pm file and change
+the lines setting @EXPORT to @EXPORT_OK (there are two: one in the line
+beginning "use vars" and one setting the array itself). Finally, in the
+.xs file, edit the #include line to read:
+
+ #include "mylib/mylib.h"
+
+And also add the following function definition to the end of the .xs file:
+
+ double
+ foo(a,b,c)
+ int a
+ long b
+ const char * c
+ OUTPUT:
+ RETVAL
+
+Now we also need to create a typemap file because the default Perl doesn't
+currently support the const char * type. Create a file called typemap and
+place the following in it:
+
+ const char * T_PV
+
+Now run perl on the top-level Makefile.PL. Notice that it also created a
+Makefile in the mylib directory. Run make and see that it does cd into
+the mylib directory and run make in there as well.
+
+Now edit the test.pl script and change the BEGIN block to print "1..4",
+and add the following lines to the end of the script:
+
+ print &Mytest2::foo(1, 2, "Hello, world!") == 7 ? "ok 2\n" : "not ok 2\n";
+ print &Mytest2::foo(1, 2, "0.0") == 7 ? "ok 3\n" : "not ok 3\n";
+ print abs(&Mytest2::foo(0, 0, "-3.4") - 0.6) <= 0.01 ? "ok 4\n" : "not ok 4\n";
+
+(When dealing with floating-point comparisons, it is often useful not to check
+for equality, but rather the difference being below a certain epsilon factor,
+0.01 in this case)
+
+Run "make test" and all should be well.
+
+=head2 WHAT HAS HAPPENED HERE?
+
+Unlike previous examples, we've now run h2xs on a real include file. This
+has caused some extra goodies to appear in both the .pm and .xs files.
+
+=over 4
+
+=item *
+
+In the .xs file, there's now a #include declaration with the full path to
+the mylib.h header file.
+
+=item *
+
+There's now some new C code that's been added to the .xs file. The purpose
+of the C<constant> routine is to make the values that are #define'd in the
+header file available to the Perl script (in this case, by calling
+C<&main::TESTVAL>). There's also some XS code to allow calls to the
+C<constant> routine.
+
+=item *
+
+The .pm file has exported the name TESTVAL in the @EXPORT array. This
+could lead to name clashes. A good rule of thumb is that if the #define
+is going to be used by only the C routines themselves, and not by the user,
+they should be removed from the @EXPORT array. Alternately, if you don't
+mind using the "fully qualified name" of a variable, you could remove most
+or all of the items in the @EXPORT array.
+
+=item *
+
+If our include file contained #include directives, these would not be
+processed at all by h2xs. There is no good solution to this right now.
+
+=back
+
+We've also told Perl about the library that we built in the mylib
+subdirectory. That required the addition of only the MYEXTLIB variable
+to the WriteMakefile call and the replacement of the postamble subroutine
+to cd into the subdirectory and run make. The Makefile.PL for the
+library is a bit more complicated, but not excessively so. Again we
+replaced the postamble subroutine to insert our own code. This code
+specified simply that the library to be created here was a static
+archive (as opposed to a dynamically loadable library) and provided the
+commands to build it.
+
+=head2 SPECIFYING ARGUMENTS TO XSUBPP
+
+With the completion of Example 4, we now have an easy way to simulate some
+real-life libraries whose interfaces may not be the cleanest in the world.
+We shall now continue with a discussion of the arguments passed to the
+xsubpp compiler.
+
+When you specify arguments in the .xs file, you are really passing three
+pieces of information for each one listed. The first piece is the order
+of that argument relative to the others (first, second, etc). The second
+is the type of argument, and consists of the type declaration of the
+argument (e.g., int, char*, etc). The third piece is the exact way in
+which the argument should be used in the call to the library function
+from this XSUB. This would mean whether or not to place a "&" before
+the argument or not, meaning the argument expects to be passed the address
+of the specified data type.
+
+There is a difference between the two arguments in this hypothetical function:
+
+ int
+ foo(a,b)
+ char &a
+ char * b
+
+The first argument to this function would be treated as a char and assigned
+to the variable a, and its address would be passed into the function foo.
+The second argument would be treated as a string pointer and assigned to the
+variable b. The I<value> of b would be passed into the function foo. The
+actual call to the function foo that xsubpp generates would look like this:
+
+ foo(&a, b);
+
+Xsubpp will identically parse the following function argument lists:
+
+ char &a
+ char&a
+ char & a
+
+However, to help ease understanding, it is suggested that you place a "&"
+next to the variable name and away from the variable type), and place a
+"*" near the variable type, but away from the variable name (as in the
+complete example above). By doing so, it is easy to understand exactly
+what will be passed to the C function -- it will be whatever is in the
+"last column".
+
+You should take great pains to try to pass the function the type of variable
+it wants, when possible. It will save you a lot of trouble in the long run.
+
+=head2 THE ARGUMENT STACK
+
+If we look at any of the C code generated by any of the examples except
+example 1, you will notice a number of references to ST(n), where n is
+usually 0. The "ST" is actually a macro that points to the n'th argument
+on the argument stack. ST(0) is thus the first argument passed to the
+XSUB, ST(1) is the second argument, and so on.
+
+When you list the arguments to the XSUB in the .xs file, that tells xsubpp
+which argument corresponds to which of the argument stack (i.e., the first
+one listed is the first argument, and so on). You invite disaster if you
+do not list them in the same order as the function expects them.
+
+=head2 EXTENDING YOUR EXTENSION
+
+Sometimes you might want to provide some extra methods or subroutines
+to assist in making the interface between Perl and your extension simpler
+or easier to understand. These routines should live in the .pm file.
+Whether they are automatically loaded when the extension itself is loaded
+or loaded only when called depends on where in the .pm file the subroutine
+definition is placed.
+
+=head2 DOCUMENTING YOUR EXTENSION
+
+There is absolutely no excuse for not documenting your extension.
+Documentation belongs in the .pm file. This file will be fed to pod2man,
+and the embedded documentation will be converted to the manpage format,
+then placed in the blib directory. It will be copied to Perl's man
+page directory when the extension is installed.
+
+You may intersperse documentation and Perl code within the .pm file.
+In fact, if you want to use method autoloading, you must do this,
+as the comment inside the .pm file explains.
+
+See L<perlpod> for more information about the pod format.
+
+=head2 INSTALLING YOUR EXTENSION
+
+Once your extension is complete and passes all its tests, installing it
+is quite simple: you simply run "make install". You will either need
+to have write permission into the directories where Perl is installed,
+or ask your system administrator to run the make for you.
+
+=head2 SEE ALSO
+
+For more information, consult L<perlguts>, L<perlxs>, L<perlmod>,
+and L<perlpod>.
+
+=head2 Author
+
+Jeff Okamoto <F<okamoto@corp.hp.com>>
+
+Reviewed and assisted by Dean Roehrich, Ilya Zakharevich, Andreas Koenig,
+and Tim Bunce.
+
+=head2 Last Changed
+
+1996/7/10
diff --git a/contrib/perl5/pod/pod2html.PL b/contrib/perl5/pod/pod2html.PL
new file mode 100644
index 0000000..4eec29c
--- /dev/null
+++ b/contrib/perl5/pod/pod2html.PL
@@ -0,0 +1,183 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
+chdir dirname($0);
+$file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+# In the following, perl variables are not expanded during extraction.
+
+print OUT <<'!NO!SUBS!';
+=pod
+
+=head1 NAME
+
+pod2html - convert .pod files to .html files
+
+=head1 SYNOPSIS
+
+ pod2html --help --htmlroot=<name> --infile=<name> --outfile=<name>
+ --podpath=<name>:...:<name> --podroot=<name>
+ --libpods=<name>:...:<name> --recurse --norecurse --verbose
+ --index --noindex --title=<name>
+
+=head1 DESCRIPTION
+
+Converts files from pod format (see L<perlpod>) to HTML format.
+
+=head1 ARGUMENTS
+
+pod2html takes the following arguments:
+
+=over 4
+
+=item help
+
+ --help
+
+Displays the usage message.
+
+=item htmlroot
+
+ --htmlroot=name
+
+Sets the base URL for the HTML files. When cross-references are made,
+the HTML root is prepended to the URL.
+
+=item infile
+
+ --infile=name
+
+Specify the pod file to convert. Input is taken from STDIN if no
+infile is specified.
+
+=item outfile
+
+ --outfile=name
+
+Specify the HTML file to create. Output goes to STDOUT if no outfile
+is specified.
+
+=item podroot
+
+ --podroot=name
+
+Specify the base directory for finding library pods.
+
+=item podpath
+
+ --podpath=name:...:name
+
+Specify which subdirectories of the podroot contain pod files whose
+HTML converted forms can be linked-to in cross-references.
+
+=item libpods
+
+ --libpods=name:...:name
+
+List of page names (eg, "perlfunc") which contain linkable C<=item>s.
+
+=item netscape
+
+ --netscape
+
+Use Netscape HTML directives when applicable.
+
+=item nonetscape
+
+ --nonetscape
+
+Do not use Netscape HTML directives (default).
+
+=item index
+
+ --index
+
+Generate an index at the top of the HTML file (default behaviour).
+
+=item noindex
+
+ --noindex
+
+Do not generate an index at the top of the HTML file.
+
+
+=item recurse
+
+ --recurse
+
+Recurse into subdirectories specified in podpath (default behaviour).
+
+=item norecurse
+
+ --norecurse
+
+Do not recurse into subdirectories specified in podpath.
+
+=item title
+
+ --title=title
+
+Specify the title of the resulting HTML file.
+
+=item verbose
+
+ --verbose
+
+Display progress messages.
+
+=back
+
+=head1 AUTHOR
+
+Tom Christiansen, E<lt>tchrist@perl.comE<gt>.
+
+=head1 BUGS
+
+See L<Pod::Html> for a list of known bugs in the translator.
+
+=head1 SEE ALSO
+
+L<perlpod>, L<Pod::HTML>
+
+=head1 COPYRIGHT
+
+This program is distributed under the Artistic License.
+
+=cut
+
+use Pod::Html;
+
+pod2html @ARGV;
+!NO!SUBS!
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
diff --git a/contrib/perl5/pod/pod2latex.PL b/contrib/perl5/pod/pod2latex.PL
new file mode 100644
index 0000000..feed98e
--- /dev/null
+++ b/contrib/perl5/pod/pod2latex.PL
@@ -0,0 +1,708 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
+chdir dirname($0);
+$file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+# In the following, perl variables are not expanded during extraction.
+
+print OUT <<'!NO!SUBS!';
+#
+# pod2latex, version 1.1
+# by Taro Kawagish (kawagish@imslab.co.jp), Jan 11, 1995.
+#
+# pod2latex filters Perl pod documents to LaTeX documents.
+#
+# What pod2latex does:
+# 1. Pod file 'perl_doc_entry.pod' is filtered to 'perl_doc_entry.tex'.
+# 2. Indented paragraphs are translated into
+# '\begin{verbatim} ... \end{verbatim}'.
+# 3. '=head1 heading' command is translated into '\section{heading}'
+# 4. '=head2 heading' command is translated into '\subsection*{heading}'
+# 5. '=over N' command is translated into
+# '\begin{itemize}' if following =item starts with *,
+# '\begin{enumerate}' if following =item starts with 1.,
+# '\begin{description}' if else.
+# (indentation level N is ignored.)
+# 6. '=item * heading' command is translated into '\item heading',
+# '=item 1. heading' command is translated into '\item heading',
+# '=item heading' command(other) is translated into '\item[heading]'.
+# 7. '=back' command is translated into
+# '\end{itemize}' if started with '\begin{itemize}',
+# '\end{enumerate}' if started with '\begin{enumerate}',
+# '\end{description}' if started with '\begin{description}'.
+# 8. other paragraphs are translated into strings with TeX special characters
+# escaped.
+# 9. In heading text, and other paragraphs, the following translation of pod
+# quotes are done, and then TeX special characters are escaped after that.
+# I<text> to {\em text\/},
+# B<text> to {\bf text},
+# S<text> to text1,
+# where text1 is a string with blank characters replaced with ~,
+# C<text> to {\tt text2},
+# where text2 is a string with TeX special characters escaped to
+# obtain a literal printout,
+# E<text> (HTML escape) to TeX escaped string,
+# L<text> to referencing string as is done by pod2man,
+# F<file> to {\em file\/},
+# Z<> to a null string,
+# 10. those headings are indexed:
+# '=head1 heading' => \section{heading}\index{heading}
+# '=head2 heading' => \subsection*{heading}\index{heading}
+# only when heading does not match frequent patterns such as
+# DESCRIPTION, DIAGNOSTICS,...
+# '=item heading' => \item{heading}\index{heading}
+#
+# Usage:
+# pod2latex perl_doc_entry.pod
+# this will write to a file 'perl_doc_entry.tex'.
+#
+# To LaTeX:
+# The following commands need to be defined in the preamble of the LaTeX
+# document:
+# \def\C++{{\rm C\kern-.05em\raise.3ex\hbox{\footnotesize ++}}}
+# \def\underscore{\leavevmode\kern.04em\vbox{\hrule width 0.4em height 0.3pt}}
+# and \parindent should be set zero:
+# \setlength{\parindent}{0pt}
+#
+# Note:
+# This script was written modifing pod2man.
+#
+# Bug:
+# If HTML escapes E<text> other than E<amp>,E<lt>,E<gt>,E<quot> are used
+# in C<>, translation will produce wrong character strings.
+# Translation of HTML escapes of various European accents might be wrong.
+
+
+$/ = ""; # record separator is blank lines
+# TeX special characters.
+##$tt_ables = "!@*()-=+|;:'\"`,./?<>";
+$backslash_escapables = "#\$%&{}_";
+$backslash_escapables2 = "#\$%&{}"; # except _
+##$nonverbables = "^\\~";
+##$bracketesc = "[]";
+##@tex_verb_fences = unpack("aaaaaaaaa","|#@!*+?:;");
+
+@head1_freq_patterns # =head1 patterns which need not be index'ed
+ = ("AUTHOR","Author","BUGS","DATE","DESCRIPTION","DIAGNOSTICS",
+ "ENVIRONMENT","EXAMPLES","FILES","INTRODUCTION","NAME","NOTE",
+ "SEE ALSO","SYNOPSIS","WARNING");
+
+$indent = 0;
+
+# parse the pods, produce LaTeX.
+
+open(POD,"<$ARGV[0]") || die "cant open $ARGV[0]";
+($pod=$ARGV[0]) =~ s/\.pod$//;
+open(LATEX,">$pod.tex");
+&do_hdr();
+
+$cutting = 1;
+$begun = "";
+while (<POD>) {
+ if ($cutting) {
+ next unless /^=/;
+ $cutting = 0;
+ }
+ if ($begun) {
+ if (/^=end\s+$begun/) {
+ $begun = "";
+ }
+ elsif ($begun =~ /^(tex|latex)$/) {
+ print LATEX $_;
+ }
+ next;
+ }
+ chop;
+ length || (print LATEX "\n") && next;
+
+ # translate indented lines as a verabatim paragraph
+ if (/^\s/) {
+ @lines = split(/\n/);
+ print LATEX "\\begin{verbatim}\n";
+ for (@lines) {
+ 1 while s
+ {^( [^\t]* ) \t ( \t* ) }
+ { $1 . ' ' x (8 - (length($1)%8) + 8*(length($2))) }ex;
+ print LATEX $_,"\n";
+ }
+ print LATEX "\\end{verbatim}\n";
+ next;
+ }
+
+ if (/^=for\s+(\S+)\s*/s) {
+ if ($1 eq "tex" or $1 eq "latex") {
+ print LATEX $',"\n";
+ } else {
+ # ignore unknown for
+ }
+ next;
+ }
+ elsif (/^=begin\s+(\S+)\s*/s) {
+ $begun = $1;
+ if ($1 eq "tex" or $1 eq "latex") {
+ print LATEX $'."\n";
+ }
+ next;
+ }
+
+ # preserve '=item' line with pod quotes as they are.
+ if (/^=item/) {
+ ($bareitem = $_) =~ s/^=item\s*//;
+ }
+
+ # check for things that'll hosed our noremap scheme; affects $_
+ &init_noremap();
+
+ # expand strings "func()" as pod quotes.
+ if (!/^=item/) {
+ # first hide pod escapes.
+ # escaped strings are mapped into the ones with the MSB's on.
+ s/([A-Z]<[^<>]*>)/noremap($1)/ge;
+
+ # func() is a reference to a perl function
+ s{\b([:\w]+\(\))}{I<$1>}g;
+ # func(n) is a reference to a man page
+ s{(\w+)(\([^\s,\051]+\))}{I<$1>$2}g;
+ # convert simple variable references
+# s/([\$\@%][\w:]+)/C<$1>/g;
+# s/\$[\w:]+\[[0-9]+\]/C<$&>/g;
+
+ if (m{ ([\-\w]+\([^\051]*?[\@\$,][^\051]*?\))
+ }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
+ {
+ warn "``$1'' should be a [LCI]<$1> ref";
+ }
+ while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
+ warn "``$1'' should be [CB]<$1> ref";
+ }
+
+ # put back pod quotes so we get the inside of <> processed;
+ $_ = &clear_noremap($_);
+ }
+
+
+ # process TeX special characters
+
+ # First hide HTML quotes E<> since they can be included in C<>.
+ s/(E<[^<>]+>)/noremap($1)/ge;
+
+ # Then hide C<> type literal quotes.
+ # String inside of C<> will later be expanded into {\tt ..} strings
+ # with TeX special characters escaped as needed.
+ s/(C<[^<>]*>)/&noremap($1)/ge;
+
+ # Next escape TeX special characters including other pod quotes B< >,...
+ #
+ # NOTE: s/re/&func($str)/e evaluates $str just once in perl5.
+ # (in perl4 evaluation takes place twice before getting passed to func().)
+
+ # - hyphen => ---
+ s/(\S+)(\s+)-+(\s+)(\S+)/"$1".&noremap(" --- ")."$4"/ge;
+ # '-', '--', "-" => '{\tt -}', '{\tt --}', "{\tt -}"
+## s/("|')(\s*)(-+)(\s*)\1/&noremap("$1$2\{\\tt $3\}$4$1")/ge;
+## changed Wed Jan 25 15:26:39 JST 1995
+ # '-', '--', "-" => '$-$', '$--$', "$-$"
+ s/(\s+)(['"])(-+)([^'"\-]*)\2(\s+|[,.])/"$1$2".&noremap("\$$3\$")."$4$2$5"/ge;
+ s/(\s+)(['"])([^'"\-]*)(-+)(\s*)\2(\s+|[,.])/"$1$2$3".&noremap("\$$4\$")."$5$2$6"/ge;
+ # (--|-) => ($--$|$-$)
+ s/(\s+)\((-+)([=@%\$\+\\\|\w]*)(-*)([=@%\$\+\\\|\w]*)\)(\s+|[,.])/"$1\(".&noremap("\$$2\$")."$3".&noremap("\$$4\$")."$5\)$6"/ge;
+ # numeral - => $-$
+ s/(\(|[0-9]+|\s+)-(\s*\(?\s*[0-9]+)/&noremap("$1\$-\$$2")/ge;
+ # -- in quotes => two separate -
+ s/B<([^<>]*)--([^<>]*)>/&noremap("B<$1\{\\tt --\}$2>")/ge;
+
+ # backslash escapable characters except _.
+ s/([$backslash_escapables2])/&noremap("\\$1")/ge;
+ s/_/&noremap("\\underscore{}")/ge; # a litle thicker than \_.
+ # quote TeX special characters |, ^, ~, \.
+ s/\|/&noremap("\$|\$")/ge;
+ s/\^/&noremap("\$\\hat{\\hspace{0.4em}}\$")/ge;
+ s/\~/&noremap("\$\\tilde{\\hspace{0.4em}}\$")/ge;
+ s/\\/&noremap("\$\\backslash{}\$")/ge;
+ # quote [ and ] to be used in \item[]
+ s/([\[\]])/&noremap("{\\tt $1}")/ge;
+ # characters need to be treated differently in TeX
+ # keep * if an item heading
+ s/^(=item[ \t]+)[*]((.|\n)*)/"$1" . &noremap("*") . "$2"/ge;
+ s/[*]/&noremap("\$\\ast\$")/ge; # other *
+
+ # hide other pod quotes.
+ s/([ABD-Z]<[^<>]*>)/&noremap($1)/ge;
+
+ # escape < and > as math strings,
+ # now that we are done with hiding pod <> quotes.
+ s/</&noremap("\$<\$")/ge;
+ s/>/&noremap("\$>\$")/ge;
+
+ # put it back so we get the <> processed again;
+ $_ = &clear_noremap($_);
+
+
+ # Expand pod quotes recursively:
+ # (1) type face directives [BIFS]<[^<>]*> to appropriate TeX commands,
+ # (2) L<[^<>]*> to reference strings,
+ # (3) C<[^<>]*> to TeX literal quotes,
+ # (4) HTML quotes E<> inside of C<> quotes.
+
+ # Hide E<> again since they can be included in C<>.
+ s/(E<[^<>]+>)/noremap($1)/ge;
+
+ $maxnest = 10;
+ while ($maxnest-- && /[A-Z]</) {
+
+ # bold and italic quotes
+ s/B<([^<>]*)>/"{\\bf $1}"/eg;
+ s#I<([^<>]*)>#"{\\em $1\\/}"#eg;
+
+ # files and filelike refs in italics
+ s#F<([^<>]*)>#"{\\em $1\\/}"#eg;
+
+ # no break quote -- usually we want C<> for this
+ s/S<([^<>]*)>/&nobreak($1)/eg;
+
+ # LREF: a manpage(3f)
+ s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the {\\em $1\\/}$2 manpage:g;
+
+ # LREF: an =item on another manpage
+ s{
+ L<([^/]+)/([:\w]+(\(\))?)>
+ } {the C<$2> entry in the I<$1> manpage}gx;
+
+ # LREF: an =item on this manpage
+ s{
+ ((?:L</([:\w]+(\(\))?)>
+ (,?\s+(and\s+)?)?)+)
+ } { &internal_lrefs($1) }gex;
+
+ # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
+ # the "func" can disambiguate
+ s{
+ L<(?:([a-zA-Z]\S+?) /)?"?(.*?)"?>
+ }{
+ do {
+ $1 # if no $1, assume it means on this page.
+ ? "the section on I<$2> in the I<$1> manpage"
+ : "the section on I<$2>"
+ }
+ }gex;
+
+ s/Z<>/\\&/g; # the "don't format me" thing
+
+ # comes last because not subject to reprocessing
+ s{
+ C<([^<>]*)>
+ }{
+ do {
+ ($str = $1) =~ tr/\200-\377/\000-\177/; #normalize hidden stuff
+ # expand HTML escapes if any;
+ # WARNING: if HTML escapes other than E<amp>,E<lt>,E<gt>,
+ # E<quot> are in C<>, they will not be printed correctly.
+ $str = &expand_HTML_escapes($str);
+ $strverb = &alltt($str); # Tex verbatim escape of a string.
+ &noremap("$strverb");
+ }
+ }gex;
+
+# if ( /C<([^<>]*)/ ) {
+# $str = $1;
+# if ($str !~ /\|/) { # if includes |
+# s/C<([^<>]*)>/&noremap("\\verb|$str|")/eg;
+# } else {
+# print STDERR "found \| in C<.*> at paragraph $.\n";
+# # find a character not contained in $str to use it as a
+# # separator of the \verb
+# ($chars = $str) =~ s/(\W)/\\$1/g;
+# ## ($chars = $str) =~ s/([\$<>,\|"'\-^{}()*+?\\])/\\$1/g;
+# @fence = grep(!/[ $chars]/,@tex_verb_fences);
+# s/C<([^<>]*)>/&noremap("\\verb$fence[0]$str$fence[0]")/eg;
+# }
+# }
+ }
+
+
+ # process each pod command
+ if (s/^=//) { # if a command
+ s/\n/ /g;
+ ($cmd, $rest) = split(' ', $_, 2);
+ $rest =~ s/^\s*//;
+ $rest =~ s/\s*$//;
+
+ if (defined $rest) {
+ &escapes;
+ }
+
+ $rest = &clear_noremap($rest);
+ $rest = &expand_HTML_escapes($rest);
+
+ if ($cmd eq 'cut') {
+ $cutting = 1;
+ $lastcmd = 'cut';
+ }
+ elsif ($cmd eq 'head1') { # heading type 1
+ $rest =~ s/^\s*//; $rest =~ s/\s*$//;
+ print LATEX "\n\\subsection*{$rest}";
+ # put index entry
+ ($index = $rest) =~ s/^(An?\s+|The\s+)//i; # remove 'A' and 'The'
+ # index only those heads not matching the frequent patterns.
+ foreach $pat (@head1_freq_patterns) {
+ if ($index =~ /^$pat/) {
+ goto freqpatt;
+ }
+ }
+ print LATEX "%\n\\index{$index}\n" if ($index);
+ freqpatt:
+ $lastcmd = 'head1';
+ }
+ elsif ($cmd eq 'head2') { # heading type 2
+ $rest =~ s/^\s*//; $rest =~ s/\s*$//;
+ print LATEX "\n\\subsubsection*{$rest}";
+ # put index entry
+ ($index = $rest) =~ s/^(An?\s+|The\s+)//i; # remove 'A' and 'The'
+ $index =~ s/^Example\s*[1-9][0-9]*\s*:\s*//; # remove 'Example :'
+ print LATEX "%\n\\index{$index}\n" if ($index);
+ $lastcmd = 'head2';
+ }
+ elsif ($cmd eq 'over') { # 1 level within a listing environment
+ push(@indent,$indent);
+ $indent = $rest + 0;
+ $lastcmd = 'over';
+ }
+ elsif ($cmd eq 'back') { # 1 level out of a listing environment
+ $indent = pop(@indent);
+ warn "Unmatched =back\n" unless defined $indent;
+ $listingcmd = pop(@listingcmd);
+ print LATEX "\n\\end{$listingcmd}\n" if ($listingcmd);
+ $lastcmd = 'back';
+ }
+ elsif ($cmd eq 'item') { # an item paragraph starts
+ if ($lastcmd eq 'over') { # if we have just entered listing env
+ # see what type of list environment we are in.
+ if ($rest =~ /^[0-9]\.?/) { # if numeral heading
+ $listingcmd = 'enumerate';
+ } elsif ($rest =~ /^\*\s*/) { # if * heading
+ $listingcmd = 'itemize';
+ } elsif ($rest =~ /^[^*]/) { # if other headings
+ $listingcmd = 'description';
+ } else {
+ warn "unknown list type for item $rest";
+ }
+ print LATEX "\n\\begin{$listingcmd}\n";
+ push(@listingcmd,$listingcmd);
+ } elsif ($lastcmd ne 'item') {
+ warn "Illegal '=item' command without preceding 'over':";
+ warn "=item $bareitem";
+ }
+
+ if ($listingcmd eq 'enumerate') {
+ $rest =~ s/^[0-9]+\.?\s*//; # remove numeral heading
+ print LATEX "\n\\item";
+ print LATEX "{\\bf $rest}" if $rest;
+ } elsif ($listingcmd eq 'itemize') {
+ $rest =~ s/^\*\s*//; # remove * heading
+ print LATEX "\n\\item";
+ print LATEX "{\\bf $rest}" if $rest;
+ } else { # description item
+ print LATEX "\n\\item[$rest]";
+ }
+ $lastcmd = 'item';
+ $rightafter_item = 'yes';
+
+ # check if the item heading is short or long.
+ ($itemhead = $rest) =~ s/{\\bf (\S*)}/$1/g;
+ if (length($itemhead) < 4) {
+ $itemshort = "yes";
+ } else {
+ $itemshort = "no";
+ }
+ # write index entry
+ if ($pod =~ "perldiag") { # skip 'perldiag.pod'
+ goto noindex;
+ }
+ # strip out the item of pod quotes and get a plain text entry
+ $bareitem =~ s/\n/ /g; # remove newlines
+ $bareitem =~ s/\s*$//; # remove trailing space
+ $bareitem =~ s/[A-Z]<([^<>]*)>/$1/g; # remove <> quotes
+ ($index = $bareitem) =~ s/^\*\s+//; # remove leading '*'
+ $index =~ s/^(An?\s+|The\s+)//i; # remove 'A' and 'The'
+ $index =~ s/^\s*[1-9][0-9]*\s*[.]\s*$//; # remove numeral only
+ $index =~ s/^\s*\w\s*$//; # remove 1 char only's
+ # quote ", @ and ! with " to be used in makeindex.
+ $index =~ s/"/""/g; # quote "
+ $index =~ s/@/"@/g; # quote @
+ $index =~ s/!/"!/g; # quote !
+ ($rest2=$rest) =~ s/^\*\s+//; # remove *
+ $rest2 =~ s/"/""/g; # quote "
+ $rest2 =~ s/@/"@/g; # quote @
+ $rest2 =~ s/!/"!/g; # quote !
+ if ($pod =~ "(perlfunc|perlvar)") { # when doc is perlfunc,perlvar
+ # take only the 1st word of item heading
+ $index =~ s/^([^{}\s]*)({.*})?([^{}\s]*)\s+.*/\1\2\3/;
+ $rest2 =~ s/^([^{}\s]*)({.*})?([^{}\s]*)\s+.*/\1\2\3/;
+ }
+ if ($index =~ /[A-Za-z\$@%]/) {
+ # write \index{plain_text_entry@TeX_string_entry}
+ print LATEX "%\n\\index{$index\@$rest2}%\n";
+ }
+ noindex:
+ ;
+ }
+ elsif ($cmd eq 'pod') {
+ ; # recognise the pod directive, as no op (hs)
+ }
+ elsif ($cmd eq 'pod') {
+ ; # recognise the pod directive, as no op (hs)
+ }
+ else {
+ warn "Unrecognized directive: $cmd\n";
+ }
+ }
+ else { # if not command
+ &escapes;
+ $_ = &clear_noremap($_);
+ $_ = &expand_HTML_escapes($_);
+
+ # if the present paragraphs follows an =item declaration,
+ # put a line break.
+ if ($lastcmd eq 'item' &&
+ $rightafter_item eq 'yes' && $itemshort eq "no") {
+ print LATEX "\\hfil\\\\";
+ $rightafter_item = 'no';
+ }
+ print LATEX "\n",$_;
+ }
+}
+
+print LATEX "\n";
+close(POD);
+close(LATEX);
+
+
+#########################################################################
+
+sub do_hdr {
+ print LATEX "% LaTeX document produced by pod2latex from \"$pod.pod\".\n";
+ print LATEX "% The followings need be defined in the preamble of this document:\n";
+ print LATEX "%\\def\\C++{{\\rm C\\kern-.05em\\raise.3ex\\hbox{\\footnotesize ++}}}\n";
+ print LATEX "%\\def\\underscore{\\leavevmode\\kern.04em\\vbox{\\hrule width 0.4em height 0.3pt}}\n";
+ print LATEX "%\\setlength{\\parindent}{0pt}\n";
+ print LATEX "\n";
+ $podq = &escape_tex_specials("\U$pod\E");
+ print LATEX "\\section{$podq}%\n";
+ print LATEX "\\index{$podq}";
+ print LATEX "\n";
+}
+
+sub nobreak {
+ my $string = shift;
+ $string =~ s/ +/~/g; # TeX no line break
+ $string;
+}
+
+sub noremap {
+ local($thing_to_hide) = shift;
+ $thing_to_hide =~ tr/\000-\177/\200-\377/;
+ return $thing_to_hide;
+}
+
+sub init_noremap {
+ # escape high bit characters in input stream
+ s/([\200-\377])/"E<".ord($1).">"/ge;
+}
+
+sub clear_noremap {
+ local($tmp) = shift;
+ $tmp =~ tr/\200-\377/\000-\177/;
+ return $tmp;
+}
+
+sub expand_HTML_escapes {
+ local($s) = $_[0];
+ $s =~ s { E<((\d+)|([A-Za-z]+))> }
+ {
+ do {
+ defined($2)
+ ? do { chr($2) }
+ :
+ exists $HTML_Escapes{$3}
+ ? do { $HTML_Escapes{$3} }
+ : do {
+ warn "Unknown escape: $& in $_";
+ "E<$1>";
+ }
+ }
+ }egx;
+ return $s;
+}
+
+sub escapes {
+ # make C++ into \C++, which is to be defined as
+ # \def\C++{{\rm C\kern-.05em\raise.3ex\hbox{\footnotesize ++}}}
+ s/\bC\+\+/\\C++{}/g;
+}
+
+# Translate a string into a TeX \tt string to obtain a verbatim print out.
+# TeX special characters are escaped by \.
+# This can be used inside of LaTeX command arguments.
+# We don't use LaTeX \verb since it doesn't work inside of command arguments.
+sub alltt {
+ local($str) = shift;
+ # other chars than #,\,$,%,&,{,},_,\,^,~ ([ and ] included).
+ $str =~ s/([^${backslash_escapables}\\\^\~]+)/&noremap("$&")/eg;
+ # chars #,\,$,%,&,{,} => \# , ...
+ $str =~ s/([$backslash_escapables2])/&noremap("\\$&")/eg;
+ # chars _,\,^,~ => \char`\_ , ...
+ $str =~ s/_/&noremap("\\char`\\_")/eg;
+ $str =~ s/\\/&noremap("\\char`\\\\")/ge;
+ $str =~ s/\^/\\char`\\^/g;
+ $str =~ s/\~/\\char`\\~/g;
+
+ $str =~ tr/\200-\377/\000-\177/; # put back
+ $str = "{\\tt ".$str."}"; # make it a \tt string
+ return $str;
+}
+
+sub escape_tex_specials {
+ local($str) = shift;
+ # other chars than #,\,$,%,&,{,}, _,\,^,~ ([ and ] included).
+ # backslash escapable characters #,\,$,%,&,{,} except _.
+ $str =~ s/([$backslash_escapables2])/&noremap("\\$1")/ge;
+ $str =~ s/_/&noremap("\\underscore{}")/ge; # \_ is too thin.
+ # quote TeX special characters |, ^, ~, \.
+ $str =~ s/\|/&noremap("\$|\$")/ge;
+ $str =~ s/\^/&noremap("\$\\hat{\\hspace{0.4em}}\$")/ge;
+ $str =~ s/\~/&noremap("\$\\tilde{\\hspace{0.4em}}\$")/ge;
+ $str =~ s/\\/&noremap("\$\\backslash{}\$")/ge;
+ # characters need to be treated differently in TeX
+ # *
+ $str =~ s/[*]/&noremap("\$\\ast\$")/ge;
+ # escape < and > as math string,
+ $str =~ s/</&noremap("\$<\$")/ge;
+ $str =~ s/>/&noremap("\$>\$")/ge;
+ $str =~ tr/\200-\377/\000-\177/; # put back
+ return $str;
+}
+
+sub internal_lrefs {
+ local($_) = shift;
+
+ s{L</([^>]+)>}{$1}g;
+ my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
+ my $retstr = "the ";
+ my $i;
+ for ($i = 0; $i <= $#items; $i++) {
+ $retstr .= "C<$items[$i]>";
+ $retstr .= ", " if @items > 2 && $i != $#items;
+ $retstr .= " and " if $i+2 == @items;
+ }
+ $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
+ . " elsewhere in this document";
+
+ return $retstr;
+}
+
+# map of HTML escapes to TeX escapes.
+BEGIN {
+%HTML_Escapes = (
+ 'amp' => '&', # ampersand
+ 'lt' => '<', # left chevron, less-than
+ 'gt' => '>', # right chevron, greater-than
+ 'quot' => '"', # double quote
+
+ "Aacute" => "\\'{A}", # capital A, acute accent
+ "aacute" => "\\'{a}", # small a, acute accent
+ "Acirc" => "\\^{A}", # capital A, circumflex accent
+ "acirc" => "\\^{a}", # small a, circumflex accent
+ "AElig" => '\\AE', # capital AE diphthong (ligature)
+ "aelig" => '\\ae', # small ae diphthong (ligature)
+ "Agrave" => "\\`{A}", # capital A, grave accent
+ "agrave" => "\\`{a}", # small a, grave accent
+ "Aring" => '\\u{A}', # capital A, ring
+ "aring" => '\\u{a}', # small a, ring
+ "Atilde" => '\\~{A}', # capital A, tilde
+ "atilde" => '\\~{a}', # small a, tilde
+ "Auml" => '\\"{A}', # capital A, dieresis or umlaut mark
+ "auml" => '\\"{a}', # small a, dieresis or umlaut mark
+ "Ccedil" => '\\c{C}', # capital C, cedilla
+ "ccedil" => '\\c{c}', # small c, cedilla
+ "Eacute" => "\\'{E}", # capital E, acute accent
+ "eacute" => "\\'{e}", # small e, acute accent
+ "Ecirc" => "\\^{E}", # capital E, circumflex accent
+ "ecirc" => "\\^{e}", # small e, circumflex accent
+ "Egrave" => "\\`{E}", # capital E, grave accent
+ "egrave" => "\\`{e}", # small e, grave accent
+ "ETH" => '\\OE', # capital Eth, Icelandic
+ "eth" => '\\oe', # small eth, Icelandic
+ "Euml" => '\\"{E}', # capital E, dieresis or umlaut mark
+ "euml" => '\\"{e}', # small e, dieresis or umlaut mark
+ "Iacute" => "\\'{I}", # capital I, acute accent
+ "iacute" => "\\'{i}", # small i, acute accent
+ "Icirc" => "\\^{I}", # capital I, circumflex accent
+ "icirc" => "\\^{i}", # small i, circumflex accent
+ "Igrave" => "\\`{I}", # capital I, grave accent
+ "igrave" => "\\`{i}", # small i, grave accent
+ "Iuml" => '\\"{I}', # capital I, dieresis or umlaut mark
+ "iuml" => '\\"{i}', # small i, dieresis or umlaut mark
+ "Ntilde" => '\\~{N}', # capital N, tilde
+ "ntilde" => '\\~{n}', # small n, tilde
+ "Oacute" => "\\'{O}", # capital O, acute accent
+ "oacute" => "\\'{o}", # small o, acute accent
+ "Ocirc" => "\\^{O}", # capital O, circumflex accent
+ "ocirc" => "\\^{o}", # small o, circumflex accent
+ "Ograve" => "\\`{O}", # capital O, grave accent
+ "ograve" => "\\`{o}", # small o, grave accent
+ "Oslash" => "\\O", # capital O, slash
+ "oslash" => "\\o", # small o, slash
+ "Otilde" => "\\~{O}", # capital O, tilde
+ "otilde" => "\\~{o}", # small o, tilde
+ "Ouml" => '\\"{O}', # capital O, dieresis or umlaut mark
+ "ouml" => '\\"{o}', # small o, dieresis or umlaut mark
+ "szlig" => '\\ss{}', # small sharp s, German (sz ligature)
+ "THORN" => '\\L', # capital THORN, Icelandic
+ "thorn" => '\\l',, # small thorn, Icelandic
+ "Uacute" => "\\'{U}", # capital U, acute accent
+ "uacute" => "\\'{u}", # small u, acute accent
+ "Ucirc" => "\\^{U}", # capital U, circumflex accent
+ "ucirc" => "\\^{u}", # small u, circumflex accent
+ "Ugrave" => "\\`{U}", # capital U, grave accent
+ "ugrave" => "\\`{u}", # small u, grave accent
+ "Uuml" => '\\"{U}', # capital U, dieresis or umlaut mark
+ "uuml" => '\\"{u}', # small u, dieresis or umlaut mark
+ "Yacute" => "\\'{Y}", # capital Y, acute accent
+ "yacute" => "\\'{y}", # small y, acute accent
+ "yuml" => '\\"{y}', # small y, dieresis or umlaut mark
+);
+}
+!NO!SUBS!
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
diff --git a/contrib/perl5/pod/pod2man.PL b/contrib/perl5/pod/pod2man.PL
new file mode 100644
index 0000000..8040bf5
--- /dev/null
+++ b/contrib/perl5/pod/pod2man.PL
@@ -0,0 +1,1216 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# $man3ext
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
+chdir dirname($0);
+$file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+
+\$DEF_PM_SECTION = '$Config{man3ext}' || '3';
+!GROK!THIS!
+
+# In the following, perl variables are not expanded during extraction.
+
+print OUT <<'!NO!SUBS!';
+
+=head1 NAME
+
+pod2man - translate embedded Perl pod directives into man pages
+
+=head1 SYNOPSIS
+
+B<pod2man>
+[ B<--section=>I<manext> ]
+[ B<--release=>I<relpatch> ]
+[ B<--center=>I<string> ]
+[ B<--date=>I<string> ]
+[ B<--fixed=>I<font> ]
+[ B<--official> ]
+[ B<--lax> ]
+I<inputfile>
+
+=head1 DESCRIPTION
+
+B<pod2man> converts its input file containing embedded pod directives (see
+L<perlpod>) into nroff source suitable for viewing with nroff(1) or
+troff(1) using the man(7) macro set.
+
+Besides the obvious pod conversions, B<pod2man> also takes care of
+func(), func(n), and simple variable references like $foo or @bar so
+you don't have to use code escapes for them; complex expressions like
+C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
+little roffish things that it catches include translating the minus in
+something like foo-bar, making a long dash--like this--into a real em
+dash, fixing up "paired quotes", putting a little space after the
+parens in something like func(), making C++ and PI look right, making
+double underbars have a little tiny space between them, making ALLCAPS
+a teeny bit smaller in troff(1), and escaping backslashes so you don't
+have to.
+
+=head1 OPTIONS
+
+=over 8
+
+=item center
+
+Set the centered header to a specific string. The default is
+"User Contributed Perl Documentation", unless the C<--official> flag is
+given, in which case the default is "Perl Programmers Reference Guide".
+
+=item date
+
+Set the left-hand footer string to this value. By default,
+the modification date of the input file will be used.
+
+=item fixed
+
+The fixed font to use for code refs. Defaults to CW.
+
+=item official
+
+Set the default header to indicate that this page is of
+the standard release in case C<--center> is not given.
+
+=item release
+
+Set the centered footer. By default, this is the current
+perl release.
+
+=item section
+
+Set the section for the C<.TH> macro. The standard conventions on
+sections are to use 1 for user commands, 2 for system calls, 3 for
+functions, 4 for devices, 5 for file formats, 6 for games, 7 for
+miscellaneous information, and 8 for administrator commands. This works
+best if you put your Perl man pages in a separate tree, like
+F</usr/local/perl/man/>. By default, section 1 will be used
+unless the file ends in F<.pm> in which case section 3 will be selected.
+
+=item lax
+
+Don't complain when required sections aren't present.
+
+=back
+
+=head1 Anatomy of a Proper Man Page
+
+For those not sure of the proper layout of a man page, here's
+an example of the skeleton of a proper man page. Head of the
+major headers should be setout as a C<=head1> directive, and
+are historically written in the rather startling ALL UPPER CASE
+format, although this is not mandatory.
+Minor headers may be included using C<=head2>, and are
+typically in mixed case.
+
+=over 10
+
+=item NAME
+
+Mandatory section; should be a comma-separated list of programs or
+functions documented by this podpage, such as:
+
+ foo, bar - programs to do something
+
+=item SYNOPSIS
+
+A short usage summary for programs and functions, which
+may someday be deemed mandatory.
+
+=item DESCRIPTION
+
+Long drawn out discussion of the program. It's a good idea to break this
+up into subsections using the C<=head2> directives, like
+
+ =head2 A Sample Subection
+
+ =head2 Yet Another Sample Subection
+
+=item OPTIONS
+
+Some people make this separate from the description.
+
+=item RETURN VALUE
+
+What the program or function returns if successful.
+
+=item ERRORS
+
+Exceptions, return codes, exit stati, and errno settings.
+
+=item EXAMPLES
+
+Give some example uses of the program.
+
+=item ENVIRONMENT
+
+Envariables this program might care about.
+
+=item FILES
+
+All files used by the program. You should probably use the FE<lt>E<gt>
+for these.
+
+=item SEE ALSO
+
+Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
+
+=item NOTES
+
+Miscellaneous commentary.
+
+=item CAVEATS
+
+Things to take special care with; sometimes called WARNINGS.
+
+=item DIAGNOSTICS
+
+All possible messages the program can print out--and
+what they mean.
+
+=item BUGS
+
+Things that are broken or just don't work quite right.
+
+=item RESTRICTIONS
+
+Bugs you don't plan to fix :-)
+
+=item AUTHOR
+
+Who wrote it (or AUTHORS if multiple).
+
+=item HISTORY
+
+Programs derived from other sources sometimes have this, or
+you might keep a modification log here.
+
+=back
+
+=head1 EXAMPLES
+
+ pod2man program > program.1
+ pod2man some_module.pm > /usr/perl/man/man3/some_module.3
+ pod2man --section=7 note.pod > note.7
+
+=head1 DIAGNOSTICS
+
+The following diagnostics are generated by B<pod2man>. Items
+marked "(W)" are non-fatal, whereas the "(F)" errors will cause
+B<pod2man> to immediately exit with a non-zero status.
+
+=over 4
+
+=item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
+
+(W) If you start include an option, you should set it off
+as bold, italic, or code.
+
+=item can't open %s: %s
+
+(F) The input file wasn't available for the given reason.
+
+=item Improper man page - no dash in NAME header in paragraph %d of %s
+
+(W) The NAME header did not have an isolated dash in it. This is
+considered important.
+
+=item Invalid man page - no NAME line in %s
+
+(F) You did not include a NAME header, which is essential.
+
+=item roff font should be 1 or 2 chars, not `%s' (F)
+
+(F) The font specified with the C<--fixed> option was not
+a one- or two-digit roff font.
+
+=item %s is missing required section: %s
+
+(W) Required sections include NAME, DESCRIPTION, and if you're
+using a section starting with a 3, also a SYNOPSIS. Actually,
+not having a NAME is a fatal.
+
+=item Unknown escape: %s in %s
+
+(W) An unknown HTML entity (probably for an 8-bit character) was given via
+a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
+entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
+Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
+Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
+icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
+ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
+THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
+Yacute, yacute, and yuml.
+
+=item Unmatched =back
+
+(W) You have a C<=back> without a corresponding C<=over>.
+
+=item Unrecognized pod directive: %s
+
+(W) You specified a pod directive that isn't in the known list of
+C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
+
+
+=back
+
+=head1 NOTES
+
+If you would like to print out a lot of man page continuously, you
+probably want to set the C and D registers to set contiguous page
+numbering and even/odd paging, at least on some versions of man(7).
+Settting the F register will get you some additional experimental
+indexing:
+
+ troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
+
+The indexing merely outputs messages via C<.tm> for each
+major page, section, subsection, item, and any C<XE<lt>E<gt>>
+directives.
+
+
+=head1 RESTRICTIONS
+
+None at this time.
+
+=head1 BUGS
+
+The =over and =back directives don't really work right. They
+take absolute positions instead of offsets, don't nest well, and
+making people count is suboptimal in any event.
+
+=head1 AUTHORS
+
+Original prototype by Larry Wall, but so massively hacked over by
+Tom Christiansen such that Larry probably doesn't recognize it anymore.
+
+=cut
+
+$/ = "";
+$cutting = 1;
+@Indices = ();
+
+# We try first to get the version number from a local binary, in case we're
+# running an installed version of Perl to produce documentation from an
+# uninstalled newer version's pod files.
+if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
+ ($version,$patch) =
+ `\PATH=.:..:\$PATH; perl -v` =~ /version (\d\.\d{3})(?:_(\d{2}))?/;
+}
+# No luck; we'll just go with the running Perl's version
+($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
+$DEF_RELEASE = "perl $version";
+$DEF_RELEASE .= ", patch $patch" if $patch;
+
+
+sub makedate {
+ my $secs = shift;
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
+ my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
+ return "$mday/$mname/$year";
+}
+
+use Getopt::Long;
+
+$DEF_SECTION = 1;
+$DEF_CENTER = "User Contributed Perl Documentation";
+$STD_CENTER = "Perl Programmers Reference Guide";
+$DEF_FIXED = 'CW';
+$DEF_LAX = 0;
+
+sub usage {
+ warn "$0: @_\n" if @_;
+ die <<EOF;
+usage: $0 [options] podpage
+Options are:
+ --section=manext (default "$DEF_SECTION")
+ --release=relpatch (default "$DEF_RELEASE")
+ --center=string (default "$DEF_CENTER")
+ --date=string (default "$DEF_DATE")
+ --fixed=font (default "$DEF_FIXED")
+ --official (default NOT)
+ --lax (default NOT)
+EOF
+}
+
+$uok = GetOptions( qw(
+ section=s
+ release=s
+ center=s
+ date=s
+ fixed=s
+ official
+ lax
+ help));
+
+$DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
+
+usage("Usage error!") unless $uok;
+usage() if $opt_help;
+usage("Need one and only one podpage argument") unless @ARGV == 1;
+
+$section = $opt_section || ($ARGV[0] =~ /\.pm$/
+ ? $DEF_PM_SECTION : $DEF_SECTION);
+$RP = $opt_release || $DEF_RELEASE;
+$center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
+$lax = $opt_lax || $DEF_LAX;
+
+$CFont = $opt_fixed || $DEF_FIXED;
+
+if (length($CFont) == 2) {
+ $CFont_embed = "\\f($CFont";
+}
+elsif (length($CFont) == 1) {
+ $CFont_embed = "\\f$CFont";
+}
+else {
+ die "roff font should be 1 or 2 chars, not `$CFont_embed'";
+}
+
+$date = $opt_date || $DEF_DATE;
+
+for (qw{NAME DESCRIPTION}) {
+# for (qw{NAME DESCRIPTION AUTHOR}) {
+ $wanna_see{$_}++;
+}
+$wanna_see{SYNOPSIS}++ if $section =~ /^3/;
+
+
+$name = @ARGV ? $ARGV[0] : "<STDIN>";
+$Filename = $name;
+if ($section =~ /^1/) {
+ require File::Basename;
+ $name = uc File::Basename::basename($name);
+}
+$name =~ s/\.(pod|p[lm])$//i;
+
+# Lose everything up to the first of
+# */lib/*perl* standard or site_perl module
+# */*perl*/lib from -D prefix=/opt/perl
+# */*perl*/ random module hierarchy
+# which works.
+$name =~ s-//+-/-g;
+if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
+ or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
+ or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
+ # Lose ^site(_perl)?/.
+ $name =~ s-^site(_perl)?/--;
+ # Lose ^arch/. (XXX should we use Config? Just for archname?)
+ $name =~ s~^(.*-$^O|$^O-.*)/~~o;
+ # Lose ^version/.
+ $name =~ s-^\d+\.\d+/--;
+}
+
+# Translate Getopt/Long to Getopt::Long, etc.
+$name =~ s(/)(::)g;
+
+if ($name ne 'something') {
+ FCHECK: {
+ open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
+ while (<F>) {
+ next unless /^=\b/;
+ if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
+ $_ = <F>;
+ unless (/\s*-+\s+/) {
+ $oops++;
+ warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
+ } else {
+ my @n = split /\s+-+\s+/;
+ if (@n != 2) {
+ $oops++;
+ warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
+ }
+ else {
+ %namedesc = @n;
+ }
+ }
+ last FCHECK;
+ }
+ next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
+ next if /^=pod\b/; # It is OK to have =pod before NAME
+ die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
+ }
+ die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
+ }
+ close F;
+}
+
+print <<"END";
+.rn '' }`
+''' \$RCSfile\$\$Revision\$\$Date\$
+'''
+''' \$Log\$
+'''
+.de Sh
+.br
+.if t .Sp
+.ne 5
+.PP
+\\fB\\\\\$1\\fR
+.PP
+..
+.de Sp
+.if t .sp .5v
+.if n .sp
+..
+.de Ip
+.br
+.ie \\\\n(.\$>=3 .ne \\\\\$3
+.el .ne 3
+.IP "\\\\\$1" \\\\\$2
+..
+.de Vb
+.ft $CFont
+.nf
+.ne \\\\\$1
+..
+.de Ve
+.ft R
+
+.fi
+..
+'''
+'''
+''' Set up \\*(-- to give an unbreakable dash;
+''' string Tr holds user defined translation string.
+''' Bell System Logo is used as a dummy character.
+'''
+.tr \\(*W-|\\(bv\\*(Tr
+.ie n \\{\\
+.ds -- \\(*W-
+.ds PI pi
+.if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
+.if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
+.ds L" ""
+.ds R" ""
+''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
+''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
+''' such as .IP and .SH, which do another additional levels of
+''' double-quote interpretation
+.ds M" """
+.ds S" """
+.ds N" """""
+.ds T" """""
+.ds L' '
+.ds R' '
+.ds M' '
+.ds S' '
+.ds N' '
+.ds T' '
+'br\\}
+.el\\{\\
+.ds -- \\(em\\|
+.tr \\*(Tr
+.ds L" ``
+.ds R" ''
+.ds M" ``
+.ds S" ''
+.ds N" ``
+.ds T" ''
+.ds L' `
+.ds R' '
+.ds M' `
+.ds S' '
+.ds N' `
+.ds T' '
+.ds PI \\(*p
+'br\\}
+END
+
+print <<'END';
+.\" If the F register is turned on, we'll generate
+.\" index entries out stderr for the following things:
+.\" TH Title
+.\" SH Header
+.\" Sh Subsection
+.\" Ip Item
+.\" X<> Xref (embedded
+.\" Of course, you have to process the output yourself
+.\" in some meaninful fashion.
+.if \nF \{
+.de IX
+.tm Index:\\$1\t\\n%\t"\\$2"
+..
+.nr % 0
+.rr F
+.\}
+END
+
+print <<"END";
+.TH $name $section "$RP" "$date" "$center"
+.UC
+END
+
+push(@Indices, qq{.IX Title "$name $section"});
+
+while (($name, $desc) = each %namedesc) {
+ for ($name, $desc) { s/^\s+//; s/\s+$//; }
+ push(@Indices, qq(.IX Name "$name - $desc"\n));
+}
+
+print <<'END';
+.if n .hy 0
+.if n .na
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.de CQ \" put $1 in typewriter font
+END
+print ".ft $CFont\n";
+print <<'END';
+'if n "\c
+'if t \\&\\$1\c
+'if n \\&\\$1\c
+'if n \&"
+\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
+'.ft R
+..
+.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
+. \" AM - accent mark definitions
+.bd B 3
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds ? ?
+. ds ! !
+. ds /
+. ds q
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
+. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
+.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
+.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
+.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.ds oe o\h'-(\w'o'u*4/10)'e
+.ds Oe O\h'-(\w'O'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds v \h'-1'\o'\(aa\(ga'
+. ds _ \h'-1'^
+. ds . \h'-1'.
+. ds 3 3
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+. ds oe oe
+. ds Oe OE
+.\}
+.rm #[ #] #H #V #F C
+END
+
+$indent = 0;
+
+$begun = "";
+
+# Unrolling [^A-Z>]|[A-Z](?!<) gives: // MRE pp 165.
+my $nonest = '(?:[^A-Z>]*(?:[A-Z](?!<)[^A-Z>]*)*)';
+
+while (<>) {
+ if ($cutting) {
+ next unless /^=/;
+ $cutting = 0;
+ }
+ if ($begun) {
+ if (/^=end\s+$begun/) {
+ $begun = "";
+ }
+ elsif ($begun =~ /^(roff|man)$/) {
+ print STDOUT $_;
+ }
+ next;
+ }
+ chomp;
+
+ # Translate verbatim paragraph
+
+ if (/^\s/) {
+ @lines = split(/\n/);
+ for (@lines) {
+ 1 while s
+ {^( [^\t]* ) \t ( \t* ) }
+ { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
+ s/\\/\\e/g;
+ s/\A/\\&/s;
+ }
+ $lines = @lines;
+ makespace() unless $verbatim++;
+ print ".Vb $lines\n";
+ print join("\n", @lines), "\n";
+ print ".Ve\n";
+ $needspace = 0;
+ next;
+ }
+
+ $verbatim = 0;
+
+ if (/^=for\s+(\S+)\s*/s) {
+ if ($1 eq "man" or $1 eq "roff") {
+ print STDOUT $',"\n\n";
+ } else {
+ # ignore unknown for
+ }
+ next;
+ }
+ elsif (/^=begin\s+(\S+)\s*/s) {
+ $begun = $1;
+ if ($1 eq "man" or $1 eq "roff") {
+ print STDOUT $'."\n\n";
+ }
+ next;
+ }
+
+ # check for things that'll hosed our noremap scheme; affects $_
+ init_noremap();
+
+ if (!/^=item/) {
+
+ # trofficate backslashes; must do it before what happens below
+ s/\\/noremap('\\e')/ge;
+
+ # protect leading periods and quotes against *roff
+ # mistaking them for directives
+ s/^(?:[A-Z]<)?[.']/\\&$&/gm;
+
+ # first hide the escapes in case we need to
+ # intuit something and get it wrong due to fmting
+
+ 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
+
+ # func() is a reference to a perl function
+ s{
+ \b
+ (
+ [:\w]+ \(\)
+ )
+ } {I<$1>}gx;
+
+ # func(n) is a reference to a perl function or a man page
+ s{
+ ([:\w]+)
+ (
+ \( [^\051]+ \)
+ )
+ } {I<$1>\\|$2}gx;
+
+ # convert simple variable references
+ s/(\s+)([\$\@%][\w:]+)(?!\()/${1}C<$2>/g;
+
+ if (m{ (
+ [\-\w]+
+ \(
+ [^\051]*?
+ [\@\$,]
+ [^\051]*?
+ \)
+ )
+ }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
+ {
+ warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
+ $oops++;
+ }
+
+ while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
+ warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
+ $oops++;
+ }
+
+ # put it back so we get the <> processed again;
+ clear_noremap(0); # 0 means leave the E's
+
+ } else {
+ # trofficate backslashes
+ s/\\/noremap('\\e')/ge;
+
+ }
+
+ # need to hide E<> first; they're processed in clear_noremap
+ s/(E<[^<>]+>)/noremap($1)/ge;
+
+
+ $maxnest = 10;
+ while ($maxnest-- && /[A-Z]</) {
+
+ # can't do C font here
+ s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
+
+ # files and filelike refs in italics
+ s/F<($nonest)>/I<$1>/g;
+
+ # no break -- usually we want C<> for this
+ s/S<($nonest)>/nobreak($1)/eg;
+
+ # LREF: a la HREF L<show this text|man/section>
+ s:L<([^|>]+)\|[^>]+>:$1:g;
+
+ # LREF: a manpage(3f)
+ s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
+
+ # LREF: an =item on another manpage
+ s{
+ L<
+ ([^/]+)
+ /
+ (
+ [:\w]+
+ (\(\))?
+ )
+ >
+ } {the C<$2> entry in the I<$1> manpage}gx;
+
+ # LREF: an =item on this manpage
+ s{
+ ((?:
+ L<
+ /
+ (
+ [:\w]+
+ (\(\))?
+ )
+ >
+ (,?\s+(and\s+)?)?
+ )+)
+ } { internal_lrefs($1) }gex;
+
+ # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
+ # the "func" can disambiguate
+ s{
+ L<
+ (?:
+ ([a-zA-Z]\S+?) /
+ )?
+ "?(.*?)"?
+ >
+ }{
+ do {
+ $1 # if no $1, assume it means on this page.
+ ? "the section on I<$2> in the I<$1> manpage"
+ : "the section on I<$2>"
+ }
+ }gesx; # s in case it goes over multiple lines, so . matches \n
+
+ s/Z<>/\\&/g;
+
+ # comes last because not subject to reprocessing
+ s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
+ }
+
+ if (s/^=//) {
+ $needspace = 0; # Assume this.
+
+ s/\n/ /g;
+
+ ($Cmd, $_) = split(' ', $_, 2);
+
+ $dotlevel = 1;
+ if ($Cmd eq 'head1') {
+ $dotlevel = 1;
+ }
+ elsif ($Cmd eq 'head2') {
+ $dotlevel = 1;
+ }
+ elsif ($Cmd eq 'item') {
+ $dotlevel = 2;
+ }
+
+ if (defined $_) {
+ &escapes($dotlevel);
+ s/"/""/g;
+ }
+
+ clear_noremap(1);
+
+ if ($Cmd eq 'cut') {
+ $cutting = 1;
+ }
+ elsif ($Cmd eq 'head1') {
+ s/\s+$//;
+ delete $wanna_see{$_} if exists $wanna_see{$_};
+ print qq{.SH "$_"\n};
+ push(@Indices, qq{.IX Header "$_"\n});
+ }
+ elsif ($Cmd eq 'head2') {
+ print qq{.Sh "$_"\n};
+ push(@Indices, qq{.IX Subsection "$_"\n});
+ }
+ elsif ($Cmd eq 'over') {
+ push(@indent,$indent);
+ $indent += ($_ + 0) || 5;
+ }
+ elsif ($Cmd eq 'back') {
+ $indent = pop(@indent);
+ warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
+ $needspace = 1;
+ }
+ elsif ($Cmd eq 'item') {
+ s/^\*( |$)/\\(bu$1/g;
+ # if you know how to get ":s please do
+ s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
+ s/\\\*\(L"([^"]+?)""/'$1'/g;
+ s/[^"]""([^"]+?)""[^"]/'$1'/g;
+ # here do something about the $" in perlvar?
+ print STDOUT qq{.Ip "$_" $indent\n};
+ push(@Indices, qq{.IX Item "$_"\n});
+ }
+ elsif ($Cmd eq 'pod') {
+ # this is just a comment
+ }
+ else {
+ warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
+ }
+ }
+ else {
+ if ($needspace) {
+ &makespace;
+ }
+ &escapes(0);
+ clear_noremap(1);
+ print $_, "\n";
+ $needspace = 1;
+ }
+}
+
+print <<"END";
+
+.rn }` ''
+END
+
+if (%wanna_see && !$lax) {
+ @missing = keys %wanna_see;
+ warn "$0: $Filename is missing required section"
+ . (@missing > 1 && "s")
+ . ": @missing\n";
+ $oops++;
+}
+
+foreach (@Indices) { print "$_\n"; }
+
+exit;
+#exit ($oops != 0);
+
+#########################################################################
+
+sub nobreak {
+ my $string = shift;
+ $string =~ s/ /\\ /g;
+ $string;
+}
+
+sub escapes {
+ my $indot = shift;
+
+ s/X<(.*?)>/mkindex($1)/ge;
+
+ # translate the minus in foo-bar into foo\-bar for roff
+ s/([^0-9a-z-])-([^-])/$1\\-$2/g;
+
+ # make -- into the string version \*(-- (defined above)
+ s/\b--\b/\\*(--/g;
+ s/"--([^"])/"\\*(--$1/g; # should be a better way
+ s/([^"])--"/$1\\*(--"/g;
+
+ # fix up quotes; this is somewhat tricky
+ my $dotmacroL = 'L';
+ my $dotmacroR = 'R';
+ if ( $indot == 1 ) {
+ $dotmacroL = 'M';
+ $dotmacroR = 'S';
+ }
+ elsif ( $indot >= 2 ) {
+ $dotmacroL = 'N';
+ $dotmacroR = 'T';
+ }
+ if (!/""/) {
+ s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
+ s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
+ }
+
+ #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
+ #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
+
+
+ # make sure that func() keeps a bit a space tween the parens
+ ### s/\b\(\)/\\|()/g;
+ ### s/\b\(\)/(\\|)/g;
+
+ # make C++ into \*C+, which is a squinched version (defined above)
+ s/\bC\+\+/\\*(C+/g;
+
+ # make double underbars have a little tiny space between them
+ s/__/_\\|_/g;
+
+ # PI goes to \*(PI (defined above)
+ s/\bPI\b/noremap('\\*(PI')/ge;
+
+ # make all caps a teeny bit smaller, but don't muck with embedded code literals
+ my $hidCFont = font('C');
+ if ($Cmd !~ /^head1/) { # SH already makes smaller
+ # /g isn't enough; 1 while or we'll be off
+
+# 1 while s{
+# (?!$hidCFont)(..|^.|^)
+# \b
+# (
+# [A-Z][\/A-Z+:\-\d_$.]+
+# )
+# (s?)
+# \b
+# } {$1\\s-1$2\\s0}gmox;
+
+ 1 while s{
+ (?!$hidCFont)(..|^.|^)
+ (
+ \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
+ )
+ } {
+ $1 . noremap( '\\s-1' . $2 . '\\s0' )
+ }egmox;
+
+ }
+}
+
+# make troff just be normal, but make small nroff get quoted
+# decided to just put the quotes in the text; sigh;
+sub ccvt {
+ local($_,$prev) = @_;
+ noremap(qq{.CQ "$_" \n\\&});
+}
+
+sub makespace {
+ if ($indent) {
+ print ".Sp\n";
+ }
+ else {
+ print ".PP\n";
+ }
+}
+
+sub mkindex {
+ my ($entry) = @_;
+ my @entries = split m:\s*/\s*:, $entry;
+ push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
+ return '';
+}
+
+sub font {
+ local($font) = shift;
+ return '\\f' . noremap($font);
+}
+
+sub noremap {
+ local($thing_to_hide) = shift;
+ $thing_to_hide =~ tr/\000-\177/\200-\377/;
+ return $thing_to_hide;
+}
+
+sub init_noremap {
+ # escape high bit characters in input stream
+ s/([\200-\377])/"E<".ord($1).">"/ge;
+}
+
+sub clear_noremap {
+ my $ready_to_print = $_[0];
+
+ tr/\200-\377/\000-\177/;
+
+ # trofficate backslashes
+ # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
+
+ # now for the E<>s, which have been hidden until now
+ # otherwise the interative \w<> processing would have
+ # been hosed by the E<gt>
+ s {
+ E<
+ (
+ ( \d + )
+ | ( [A-Za-z]+ )
+ )
+ >
+ } {
+ do {
+ defined $2
+ ? chr($2)
+ :
+ exists $HTML_Escapes{$3}
+ ? do { $HTML_Escapes{$3} }
+ : do {
+ warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
+ "E<$1>";
+ }
+ }
+ }egx if $ready_to_print;
+}
+
+sub internal_lrefs {
+ local($_) = shift;
+ local $trailing_and = s/and\s+$// ? "and " : "";
+
+ s{L</([^>]+)>}{$1}g;
+ my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
+ my $retstr = "the ";
+ my $i;
+ for ($i = 0; $i <= $#items; $i++) {
+ $retstr .= "C<$items[$i]>";
+ $retstr .= ", " if @items > 2 && $i != $#items;
+ $retstr .= " and " if $i+2 == @items;
+ }
+
+ $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
+ . " elsewhere in this document";
+ # terminal space to avoid words running together (pattern used
+ # strips terminal spaces)
+ $retstr .= " " if length $trailing_and;
+ $retstr .= $trailing_and;
+
+ return $retstr;
+
+}
+
+BEGIN {
+%HTML_Escapes = (
+ 'amp' => '&', # ampersand
+ 'lt' => '<', # left chevron, less-than
+ 'gt' => '>', # right chevron, greater-than
+ 'quot' => '"', # double quote
+
+ "Aacute" => "A\\*'", # capital A, acute accent
+ "aacute" => "a\\*'", # small a, acute accent
+ "Acirc" => "A\\*^", # capital A, circumflex accent
+ "acirc" => "a\\*^", # small a, circumflex accent
+ "AElig" => '\*(AE', # capital AE diphthong (ligature)
+ "aelig" => '\*(ae', # small ae diphthong (ligature)
+ "Agrave" => "A\\*`", # capital A, grave accent
+ "agrave" => "A\\*`", # small a, grave accent
+ "Aring" => 'A\\*o', # capital A, ring
+ "aring" => 'a\\*o', # small a, ring
+ "Atilde" => 'A\\*~', # capital A, tilde
+ "atilde" => 'a\\*~', # small a, tilde
+ "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
+ "auml" => 'a\\*:', # small a, dieresis or umlaut mark
+ "Ccedil" => 'C\\*,', # capital C, cedilla
+ "ccedil" => 'c\\*,', # small c, cedilla
+ "Eacute" => "E\\*'", # capital E, acute accent
+ "eacute" => "e\\*'", # small e, acute accent
+ "Ecirc" => "E\\*^", # capital E, circumflex accent
+ "ecirc" => "e\\*^", # small e, circumflex accent
+ "Egrave" => "E\\*`", # capital E, grave accent
+ "egrave" => "e\\*`", # small e, grave accent
+ "ETH" => '\\*(D-', # capital Eth, Icelandic
+ "eth" => '\\*(d-', # small eth, Icelandic
+ "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
+ "euml" => "e\\*:", # small e, dieresis or umlaut mark
+ "Iacute" => "I\\*'", # capital I, acute accent
+ "iacute" => "i\\*'", # small i, acute accent
+ "Icirc" => "I\\*^", # capital I, circumflex accent
+ "icirc" => "i\\*^", # small i, circumflex accent
+ "Igrave" => "I\\*`", # capital I, grave accent
+ "igrave" => "i\\*`", # small i, grave accent
+ "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
+ "iuml" => "i\\*:", # small i, dieresis or umlaut mark
+ "Ntilde" => 'N\*~', # capital N, tilde
+ "ntilde" => 'n\*~', # small n, tilde
+ "Oacute" => "O\\*'", # capital O, acute accent
+ "oacute" => "o\\*'", # small o, acute accent
+ "Ocirc" => "O\\*^", # capital O, circumflex accent
+ "ocirc" => "o\\*^", # small o, circumflex accent
+ "Ograve" => "O\\*`", # capital O, grave accent
+ "ograve" => "o\\*`", # small o, grave accent
+ "Oslash" => "O\\*/", # capital O, slash
+ "oslash" => "o\\*/", # small o, slash
+ "Otilde" => "O\\*~", # capital O, tilde
+ "otilde" => "o\\*~", # small o, tilde
+ "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
+ "ouml" => "o\\*:", # small o, dieresis or umlaut mark
+ "szlig" => '\*8', # small sharp s, German (sz ligature)
+ "THORN" => '\\*(Th', # capital THORN, Icelandic
+ "thorn" => '\\*(th',, # small thorn, Icelandic
+ "Uacute" => "U\\*'", # capital U, acute accent
+ "uacute" => "u\\*'", # small u, acute accent
+ "Ucirc" => "U\\*^", # capital U, circumflex accent
+ "ucirc" => "u\\*^", # small u, circumflex accent
+ "Ugrave" => "U\\*`", # capital U, grave accent
+ "ugrave" => "u\\*`", # small u, grave accent
+ "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
+ "uuml" => "u\\*:", # small u, dieresis or umlaut mark
+ "Yacute" => "Y\\*'", # capital Y, acute accent
+ "yacute" => "y\\*'", # small y, acute accent
+ "yuml" => "y\\*:", # small y, dieresis or umlaut mark
+);
+}
+
+!NO!SUBS!
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
diff --git a/contrib/perl5/pod/pod2text.PL b/contrib/perl5/pod/pod2text.PL
new file mode 100644
index 0000000..94516c3
--- /dev/null
+++ b/contrib/perl5/pod/pod2text.PL
@@ -0,0 +1,51 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
+chdir dirname($0);
+$file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+# In the following, perl variables are not expanded during extraction.
+
+print OUT <<'!NO!SUBS!';
+
+use Pod::Text;
+
+if(@ARGV) {
+ pod2text($ARGV[0]);
+} else {
+ pod2text("<&STDIN");
+}
+
+!NO!SUBS!
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
diff --git a/contrib/perl5/pod/roffitall b/contrib/perl5/pod/roffitall
new file mode 100644
index 0000000..918fe02
--- /dev/null
+++ b/contrib/perl5/pod/roffitall
@@ -0,0 +1,284 @@
+#!/bin/sh
+#
+# Usage: roffitall [-nroff|-psroff|-groff]
+#
+# Authors: Tom Christiansen, Raphael Manfredi
+
+me=roffitall
+tmp=.
+
+if test -f ../config.sh; then
+ . ../config.sh
+fi
+
+mandir=$installman1dir
+libdir=$installman3dir
+
+test -d $mandir || mandir=/usr/new/man/man1
+test -d $libdir || libdir=/usr/new/man/man3
+
+case "$1" in
+-nroff) cmd="nroff -man"; ext='txt';;
+-psroff) cmd="psroff -t"; ext='ps';;
+-groff) cmd="groff -man"; ext='ps';;
+*)
+ echo "Usage: roffitall [-nroff|-psroff|-groff]" >&2
+ exit 1
+ ;;
+esac
+
+toroff=`
+ echo \
+ $mandir/perl.1 \
+ $mandir/perldata.1 \
+ $mandir/perlsyn.1 \
+ $mandir/perlop.1 \
+ $mandir/perlre.1 \
+ $mandir/perlrun.1 \
+ $mandir/perlfunc.1 \
+ $mandir/perlvar.1 \
+ $mandir/perlsub.1 \
+ $mandir/perlmod.1 \
+ $mandir/perlmodlib.1 \
+ $mandir/perlmodinstall.1 \
+ $mandir/perlform.1 \
+ $mandir/perllocale.1 \
+ $mandir/perlref.1 \
+ $mandir/perldsc.1 \
+ $mandir/perllol.1 \
+ $mandir/perltoot.1 \
+ $mandir/perlobj.1 \
+ $mandir/perltie.1 \
+ $mandir/perlbot.1 \
+ $mandir/perlipc.1 \
+ $mandir/perldebug.1 \
+ $mandir/perldiag.1 \
+ $mandir/perlsec.1 \
+ $mandir/perltrap.1 \
+ $mandir/perlport.1 \
+ $mandir/perlstyle.1 \
+ $mandir/perlpod.1 \
+ $mandir/perlbook.1 \
+ $mandir/perlembed.1 \
+ $mandir/perlapio.1 \
+ $mandir/perlxs.1 \
+ $mandir/perlxstut.1 \
+ $mandir/perlguts.1 \
+ $mandir/perlcall.1 \
+ $mandir/perlhist.1 \
+ $mandir/perldelta.1 \
+ $mandir/perl5004delta.1 \
+ $mandir/perlfaq.1 \
+ $mandir/perlfaq1.1 \
+ $mandir/perlfaq2.1 \
+ $mandir/perlfaq3.1 \
+ $mandir/perlfaq4.1 \
+ $mandir/perlfaq5.1 \
+ $mandir/perlfaq6.1 \
+ $mandir/perlfaq7.1 \
+ $mandir/perlfaq8.1 \
+ $mandir/perlfaq9.1 \
+ \
+ $mandir/a2p.1 \
+ $mandir/c2ph.1 \
+ $mandir/h2ph.1 \
+ $mandir/h2xs.1 \
+ $mandir/perlbug.1 \
+ $mandir/perldoc.1 \
+ $mandir/pl2pm.1 \
+ $mandir/pod2html.1 \
+ $mandir/pod2man.1 \
+ $mandir/s2p.1 \
+ $mandir/splain.1 \
+ $mandir/xsubpp.1 \
+ \
+ $libdir/attrs.3 \
+ $libdir/autouse.3 \
+ $libdir/base.3 \
+ $libdir/blib.3 \
+ $libdir/constant.3 \
+ $libdir/diagnostics.3 \
+ $libdir/fields.3 \
+ $libdir/integer.3 \
+ $libdir/less.3 \
+ $libdir/lib.3 \
+ $libdir/locale.3 \
+ $libdir/ops.3 \
+ $libdir/overload.3 \
+ $libdir/re.3 \
+ $libdir/sigtrap.3 \
+ $libdir/strict.3 \
+ $libdir/subs.3 \
+ $libdir/vars.3 \
+ \
+ $libdir/AnyDBM_File.3 \
+ $libdir/AutoLoader.3 \
+ $libdir/AutoSplit.3 \
+ $libdir/B.3 \
+ $libdir/B::Asmdata.3 \
+ $libdir/B::Assembler.3 \
+ $libdir/B::Bblock.3 \
+ $libdir/B::Bytecode.3 \
+ $libdir/B::C.3 \
+ $libdir/B::CC.3 \
+ $libdir/B::Debug.3 \
+ $libdir/B::Deparse.3 \
+ $libdir/B::Disassembler.3 \
+ $libdir/B::Lint.3 \
+ $libdir/B::Showlex.3 \
+ $libdir/B::Stackobj.3 \
+ $libdir/B::Terse.3 \
+ $libdir/B::Xref.3 \
+ $libdir/Benchmark.3 \
+ $libdir/Carp.3 \
+ $libdir/CGI.3 \
+ $libdir/CGI::Apache.3 \
+ $libdir/CGI::Carp.3 \
+ $libdir/CGI::Cookie.3 \
+ $libdir/CGI::Fast.3 \
+ $libdir/CGI::Push.3 \
+ $libdir/CGI::Switch.3 \
+ $libdir/Class::Struct.3 \
+ $libdir/Config.3 \
+ $libdir/CPAN.3 \
+ $libdir/CPAN::FirstTime.3 \
+ $libdir/CPAN::Nox.3 \
+ $libdir/Cwd.3 \
+ $libdir/Data::Dumper.3 \
+ $libdir/DB_File.3 \
+ $libdir/Devel::SelfStubber.3 \
+ $libdir/DirHandle.3 \
+ $libdir/DynaLoader.3 \
+ $libdir/English.3 \
+ $libdir/Env.3 \
+ $libdir/Errno.3 \
+ $libdir/Exporter.3 \
+ $libdir/ExtUtils::Command.3 \
+ $libdir/ExtUtils::Embed.3 \
+ $libdir/ExtUtils::Install.3 \
+ $libdir/ExtUtils::Installed.3 \
+ $libdir/ExtUtils::Liblist.3 \
+ $libdir/ExtUtils::MakeMaker.3 \
+ $libdir/ExtUtils::Manifest.3 \
+ $libdir/ExtUtils::Miniperl.3 \
+ $libdir/ExtUtils::Mkbootstrap.3 \
+ $libdir/ExtUtils::Mksymlists.3 \
+ $libdir/ExtUtils::MM_OS2.3 \
+ $libdir/ExtUtils::MM_Unix.3 \
+ $libdir/ExtUtils::MM_VMS.3 \
+ $libdir/ExtUtils::MM_Win32.3 \
+ $libdir/ExtUtils::Packlist.3 \
+ $libdir/ExtUtils::testlib.3 \
+ $libdir/Fatal.3 \
+ $libdir/Fcntl.3 \
+ $libdir/File::Basename.3 \
+ $libdir/File::CheckTree.3 \
+ $libdir/File::Compare.3 \
+ $libdir/File::Copy.3 \
+ $libdir/File::DosGlob.3 \
+ $libdir/File::Find.3 \
+ $libdir/File::Path.3 \
+ $libdir/File::Spec.3 \
+ $libdir/File::Spec::Mac.3 \
+ $libdir/File::Spec::OS2.3 \
+ $libdir/File::Spec::Unix.3 \
+ $libdir/File::Spec::VMS.3 \
+ $libdir/File::Spec::Win32.3 \
+ $libdir/File::stat.3 \
+ $libdir/FileCache.3 \
+ $libdir/FileHandle.3 \
+ $libdir/FindBin.3 \
+ $libdir/GDBM_File.3 \
+ $libdir/Getopt::Long.3 \
+ $libdir/Getopt::Std.3 \
+ $libdir/I18N::Collate.3 \
+ $libdir/IO.3 \
+ $libdir/IO::File.3 \
+ $libdir/IO::Handle.3 \
+ $libdir/IO::Pipe.3 \
+ $libdir/IO::Seekable.3 \
+ $libdir/IO::Select.3 \
+ $libdir/IO::Socket.3 \
+ $libdir/IPC::Msg.3 \
+ $libdir/IPC::Open2.3 \
+ $libdir/IPC::Open3.3 \
+ $libdir/IPC::Semaphore.3 \
+ $libdir/IPC::SysV.3 \
+ $libdir/Math::BigFloat.3 \
+ $libdir/Math::BigInt.3 \
+ $libdir/Math::Complex.3 \
+ $libdir/Math::Trig.3 \
+ $libdir/NDBM_File.3 \
+ $libdir/Net::hostent.3 \
+ $libdir/Net::netent.3 \
+ $libdir/Net::Ping.3 \
+ $libdir/Net::protoent.3 \
+ $libdir/Net::servent.3 \
+ $libdir/O.3 \
+ $libdir/Opcode.3 \
+ $libdir/Pod::Html.3 \
+ $libdir/Pod::Text.3 \
+ $libdir/POSIX.3 \
+ $libdir/Safe.3 \
+ $libdir/SDBM_File.3 \
+ $libdir/Search::Dict.3 \
+ $libdir/SelectSaver.3 \
+ $libdir/SelfLoader.3 \
+ $libdir/Shell.3 \
+ $libdir/Socket.3 \
+ $libdir/Symbol.3 \
+ $libdir/Sys::Hostname.3 \
+ $libdir/Sys::Syslog.3 \
+ $libdir/Term::Cap.3 \
+ $libdir/Term::Complete.3 \
+ $libdir/Term::ReadLine.3 \
+ $libdir/Test.3 \
+ $libdir/Test::Harness.3 \
+ $libdir/Text::Abbrev.3 \
+ $libdir/Text::ParseWords.3 \
+ $libdir/Text::Soundex.3 \
+ $libdir/Text::Tabs.3 \
+ $libdir/Text::Wrap.3 \
+ $libdir/Tie::Array.3 \
+ $libdir/Tie::Handle.3 \
+ $libdir/Tie::Hash.3 \
+ $libdir/Tie::RefHash.3 \
+ $libdir/Tie::Scalar.3 \
+ $libdir/Tie::SubstrHash.3 \
+ $libdir/Time::gmtime.3 \
+ $libdir/Time::Local.3 \
+ $libdir/Time::localtime.3 \
+ $libdir/Time::tm.3 \
+ $libdir/UNIVERSAL.3 \
+ $libdir/User::grent.3 \
+ $libdir/User::pwent.3 | \
+ perl -ne 'map { -r && print "$_ " } split'`
+
+ # Bypass internal shell buffer limit -- can't use case
+ if perl -e '$a = shift; exit($a =~ m|/|)' $toroff; then
+ echo "$me: empty file list -- did you run install?" >&2
+ exit 1
+ fi
+
+ #psroff -t -man -rC1 -rD1 -rF1 > $tmp/PerlDoc.ps 2>$tmp/PerlTOC.raw
+ #nroff -man -rC1 -rD1 -rF1 > $tmp/PerlDoc.txt 2>$tmp/PerlTOC.nr.raw
+
+ # First, create the raw data
+ run="$cmd -rC1 -rD1 -rF1 >$tmp/PerlDoc.$ext 2>$tmp/PerlTOC.$ext.raw"
+ echo "$me: running $run"
+ eval $run $toroff
+
+ #Now create the TOC
+ echo "$me: parsing TOC"
+ ./rofftoc $tmp/PerlTOC.$ext.raw > $tmp/PerlTOC.tmp.man
+ run="$cmd $tmp/PerlTOC.tmp.man >$tmp/PerlTOC.$ext"
+ echo "$me: running $run"
+ eval $run
+
+ # Finally, recreate the Doc, without the blank page 0
+ run="$cmd -rC1 -rD1 >$tmp/PerlDoc.$ext 2>$tmp/PerlTOC.$ext.raw"
+ echo "$me: running $run"
+ eval $run $toroff
+ rm -f $tmp/PerlTOC.tmp.man $tmp/PerlTOC.$ext.raw
+ echo "$me: leaving you with $tmp/PerlDoc.$ext and $tmp/PerlTOC.$ext"
+
diff --git a/contrib/perl5/pod/rofftoc b/contrib/perl5/pod/rofftoc
new file mode 100755
index 0000000..a2d0e7b
--- /dev/null
+++ b/contrib/perl5/pod/rofftoc
@@ -0,0 +1,66 @@
+# feed this into perl
+ eval 'exec perl -S $0 ${1+"$@"}'
+ if $running_under_some_shell;
+
+# Usage: rofftoc PerlTOC.xxx.raw
+#
+# Post-processes roffitall output. Called from roffitall to produce
+# a formatted table of contents.
+#
+# Author: Tom Christiansen
+
+print <<'EOF';
+.de NP
+'.sp 0.8i
+.tl ''- % -''
+'bp
+'sp 0.5i
+.tl ''\fB\s+2Perl Table of Contents\s0\fR''
+'sp 0.3i
+..
+.wh -1i NP
+.af % i
+.sp 0.5i
+.tl ''\fB\s+5Perl Table of Contents\s0\fR''
+.sp 0.5i
+.nf
+.na
+EOF
+while (<>) {
+ #chomp;
+ s/Index://;
+ ($type, $page, $desc) = split ' ', $_, 3;
+ $desc =~ s/^"(.*)"$/$1/;
+ if ($type eq 'Title') {
+ ($name = $desc) =~ s/ .*//;
+ next;
+ } elsif ($type eq 'Name') {
+ #print STDERR $page, "\t", $desc;
+ print ".ne 5\n";
+ print ".in 0\n";
+ print ".sp\n";
+ print ".ft B\n";
+ print "$desc\n";
+ print ".ft P\n";
+ print ".in 5n\n";
+ } elsif ($type eq 'Header') {
+ print ".br\n", $page, "\t", $desc;
+ } elsif ($type eq 'Subsection') {
+ print ".br\n", $page, "\t\t", $desc;
+ } elsif ($type eq 'Item') {
+ next if $desc =~ /\\bu/;
+ next unless $name =~ /POSIX|func/i;
+ print ".br\n", $page, "\t\t\t", $desc;
+ }
+}
+__END__
+Index:Title 1 "PERL 1"
+Index:Name 1 "perl - Practical Extraction and Report Language"
+Index:Header 1 "NAME"
+Index:Header 1 "SYNOPSIS"
+Index:Header 2 "DESCRIPTION"
+Index:Item 2 "\(bu Many usability enhancements"
+Index:Item 2 "\(bu Simplified grammar"
+Index:Item 2 "\(bu Lexical scoping"
+Index:Item 2 "\(bu Arbitrarily nested data structures"
+Index:Item 2 "\(bu Modularity and reusability"
diff --git a/contrib/perl5/pod/splitman b/contrib/perl5/pod/splitman
new file mode 100755
index 0000000..9fe404a
--- /dev/null
+++ b/contrib/perl5/pod/splitman
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+while (<>) {
+ if ($seqno = 1 .. /^\.TH/) {
+ unless ($seqno =~ /e/i) {
+ $header .= $_;
+ }
+ next;
+ }
+
+ if ( /^\.Ip\s*"(.*)"\s*\d+$/) {
+ $desking = 0;
+ $desc = $1;
+ if (name($desc) ne $myname) {
+ $myname = name($desc);
+ print $myname, "\n";
+ open(MAN, "> $myname.3pl");
+ print MAN <<EOALL;
+$header
+.TH $myname 3PL "\\*(RP"
+.SH NAME
+$myname
+.SH SYNOPSIS
+.B $desc
+EOALL
+ } else {
+ print MAN <<EOMORE;
+.br
+.ti +3n
+or
+.br
+.B $desc
+EOMORE
+ }
+ next;
+ }
+ unless ($desking) {
+ print MAN ".SH DESCRIPTION\n";
+ $desking = 1;
+ }
+ print MAN;
+}
+
+sub name {
+ ($_[0] =~ /(\w+)/)[0];
+}
diff --git a/contrib/perl5/pod/splitpod b/contrib/perl5/pod/splitpod
new file mode 100755
index 0000000..fd38e51
--- /dev/null
+++ b/contrib/perl5/pod/splitpod
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+
+use lib '../lib'; # If you haven't installed perl yet.
+use Pod::Functions;
+
+local $/ = '';
+
+$cur = '';
+while (<>) {
+
+ next unless /^=(?!cut)/ .. /^=cut/;
+
+ if (s/=item (\S+)/$1/) {
+ #$cur = "POSIX::" . $1;
+ $next{$cur} = $1;
+ $cur = $1;
+ $syn{$cur} .= $_;
+ next;
+ } else {
+ #s,L</,L<POSIX/,g;
+ s,L</,L<perlfunc/,g;
+ push @{$pod{$cur}}, $_ if $cur;
+ }
+}
+
+for $f ( keys %syn ) {
+ next unless $Type{$f};
+ $flavor = $Flavor{$f};
+ $orig = $f;
+ ($name = $f) =~ s/\W//g;
+
+ # deal with several functions sharing a description
+ $func = $orig;
+ $func = $next{$func} until $pod{$func};
+ my $body = join "", @{$pod{$func}};
+
+ # deal with unbalanced =over and =back cause by the split
+ my $has_over = $body =~ /^=over/;
+ my $has_back = $body =~ /^=back/;
+ $body =~ s/^=over\s*//m if $has_over and !$has_back;
+ $body =~ s/^=back\s*//m if $has_back and !$has_over;
+ open (POD, "> $name.pod") || die "can't open $name.pod: $!";
+ print POD <<EOF;
+=head1 NAME
+
+$orig - $flavor
+
+=head1 SYNOPSIS
+
+$syn{$orig}
+
+=head1 DESCRIPTION
+
+$body
+
+EOF
+
+ close POD;
+
+}
OpenPOWER on IntegriCloud