summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorTim Bunce <Tim.Bunce@ig.co.uk>1997-06-11 12:00:00 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-06-11 12:00:00 +1200
commit3e3baf6d63945cb64e829d6e5c70a7d00f3d3d03 (patch)
tree0143be655536dc428f4fa3cc7d01f6bcffe14c01 /pod
parent08aa1457cd52a368c210ab76a3da91cfadabea1a (diff)
parent3458556dd685b1767b760a72bd2e9007b5c4575e (diff)
downloadperl-3e3baf6d63945cb64e829d6e5c70a7d00f3d3d03.tar.gz
[differences between cumulative patch application and perl5.004_01]perl-5.004_01
[editor's note: The changes between this and 5.004 were processed from the m1t2 release, which was a bad idea as it was the _01 release which had the final corrected attributions. The differences between the various m*t* releases do that; I considered it most valuable just to look at the _NN releases. Many patches have been separated out and/or applied from the p5p archives nonetheless.]
Diffstat (limited to 'pod')
-rw-r--r--pod/checkpods.PL5
-rw-r--r--pod/perlbook.pod2
-rw-r--r--pod/perldata.pod2
-rw-r--r--pod/perldebug.pod2
-rw-r--r--pod/perldiag.pod16
-rw-r--r--pod/perlfaq8.pod334
-rw-r--r--pod/perlfaq9.pod4
-rw-r--r--pod/perlfunc.pod12
-rw-r--r--pod/perlguts.pod137
-rw-r--r--pod/perllol.pod2
-rw-r--r--pod/perlop.pod4
-rw-r--r--pod/perlrun.pod11
-rw-r--r--pod/perlsub.pod38
-rw-r--r--pod/perltoc.pod94
-rw-r--r--pod/perltoot.pod4
-rw-r--r--pod/pod2man.PL55
-rwxr-xr-xpod/splitpod10
17 files changed, 292 insertions, 440 deletions
diff --git a/pod/checkpods.PL b/pod/checkpods.PL
index 4bec4da609..ccd78ec9cf 100644
--- a/pod/checkpods.PL
+++ b/pod/checkpods.PL
@@ -62,7 +62,10 @@ while (<>) {
$exit = 1;
}
$last_blank = /^\s+$/;
- close(ARGV) if eof;
+ if (eof) {
+ close(ARGV);
+ $last_blank = 0;
+ }
}
exit $exit
!NO!SUBS!
diff --git a/pod/perlbook.pod b/pod/perlbook.pod
index d4bc876692..8005e81d29 100644
--- a/pod/perlbook.pod
+++ b/pod/perlbook.pod
@@ -33,3 +33,5 @@ of regular expressions in various languages including Perl.
Mastering Regular Expressions (the Hip Owl Book):
ISBN 1-56592-257-3 (English)
+
+A new edition of Learning Perl is due mid/late 1997.
diff --git a/pod/perldata.pod b/pod/perldata.pod
index 38d5e9380d..dc2975a7d4 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -196,7 +196,7 @@ You can truncate an array down to nothing by assigning the null list ()
to it. The following are equivalent:
@whatever = ();
- $#whatever = $[ - 1;
+ $#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
diff --git a/pod/perldebug.pod b/pod/perldebug.pod
index 94ece44a6f..1b206fb96d 100644
--- a/pod/perldebug.pod
+++ b/pod/perldebug.pod
@@ -334,7 +334,7 @@ affects printing of return value after C<r> command.
=item C<ornaments>
-affects screen appearance of the command line (see L<Term::Readline>).
+affects screen appearance of the command line (see L<Term::ReadLine>).
=item C<frame>
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index ea33f50f9f..1b0f92e31f 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -630,6 +630,10 @@ method, nor does any of its base classes. See L<perlobj>.
(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 mktemp()
(F) The mktemp() routine failed for some reason while trying to process
@@ -893,7 +897,7 @@ a valid magic number.
=item Deep recursion on subroutine "%s"
(W) This subroutine has called itself (directly or indirectly) 100
-times than it has returned. This probably indicates an infinite
+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.
@@ -2120,7 +2124,7 @@ think so.
=item setruid() not implemented
-(F) You tried to assign to C<$<lt>>, and your operating system doesn't support
+(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.
@@ -2211,9 +2215,11 @@ construct. Remember that bracketing delimiters count nesting level.
=item substr outside of string
-(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>.
+(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
diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod
index 4fabce6f36..f4d3c12f6f 100644
--- a/pod/perlfaq8.pod
+++ b/pod/perlfaq8.pod
@@ -849,337 +849,3 @@ included with the 5.002 release of Perl.
Copyright (c) 1997 Tom Christiansen and Nathan Torkington.
All rights reserved. See L<perlfaq> for distribution information.
- END-of-perlfaq8.pod
-echo x - perlfaq9.pod
-sed 's/^X//' >perlfaq9.pod << 'END-of-perlfaq9.pod'
-=head1 NAME
-
-perlfaq9 - Networking ($Revision: 1.17 $, $Date: 1997/04/24 22:44:29 $)
-
-=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. Can you help me fix it?
-
-Sure, but you probably can't afford our contracting rates :-)
-
-Seriously, 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 are:
-
- http://www.perl.com/perl/faq/idiots-guide.html
- http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
- http://www.perl.com/perl/faq/perl-cgi-faq.html
- http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
- http://www.boutell.com/faq/
-
-=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
-.
-
-=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:
-
- # print HTML from a URL
- use LWP::Simple;
- getprint "http://www.sn.no/libwww-perl/";
-
- # 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 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.
-
-=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 an email 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?
-
-A lot of people are tempted to code this up themselves, so you've
-probably all seen a lot of code involving C<$ENV{CONTENT_LENGTH}> and
-C<$ENV{QUERY_STRING}>. It's true that this can work, but there are
-also a lot of versions of this floating around that are quite simply
-broken!
-
-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).
-
-=head2 How do I check a valid email address?
-
-You can't.
-
-Without sending mail to the address and seeing whether it bounces (and
-even then you face the halting problem), you cannot determine whether
-an email address is valid. Even if you apply the email 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 email
-addresses with a simple regexp, such as
-C</^[\w.-]+\@([\w.-]\.)+\w+$/>. 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 email to
-(say, Bill Clinton or your postmaster), and then makes sure that the
-hostname given can be looked up in DNS. It's not fast, but it works.
-
-Here's an alternative strategy used by many CGI script authors: Check
-the email address with a simple regexp (such as the one above). If
-the regexp matched the address, accept the address. If the regexp
-didn't match the address, request confirmation from the user that the
-email address they entered was correct.
-
-=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 email 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 email address can mean that this generates addresses
-that the company's email system will not accept, so you should ask for
-users' email 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/read mail?
-
-Sending mail: the Mail::Mailer module from CPAN (part of the MailTools
-package) is UNIX-centric, while Mail::Internet uses Net::SMTP which is
-not UNIX-centric. Reading 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;
-
-=head2 How do I find out my hostname/domainname/IP address?
-
-A lot of code has historically cavalierly called the C<`hostname`>
-program. While sometimes expedient, this isn't very portable. 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 Tom Christiansen and Nathan Torkington.
-All rights reserved. See L<perlfaq> for distribution information.
-
diff --git a/pod/perlfaq9.pod b/pod/perlfaq9.pod
index d7faca02e3..aa942c2da0 100644
--- a/pod/perlfaq9.pod
+++ b/pod/perlfaq9.pod
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq9 - Networking ($Revision: 1.16 $, $Date: 1997/04/23 18:12:06 $)
+perlfaq9 - Networking ($Revision: 1.17 $, $Date: 1997/04/24 22:44:29 $)
=head1 DESCRIPTION
@@ -295,7 +295,7 @@ give you the hostname after which you can find out the IP address
use Socket;
use Sys::Hostname;
my $host = hostname();
- my $addr = inet_ntoa(scalar(gethostbyname($host || 'localhost')));
+ 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
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index e3c4c9546d..a28487ac1d 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -448,7 +448,7 @@ successfully changed. See also L</oct>, if all you have is a string.
=item chomp
-This is a slightly safer version of chop (see below). It removes any
+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
@@ -1731,7 +1731,7 @@ it succeeded, FALSE otherwise. See example in L<perlipc/"Sockets: Client/Server
A local modifies the listed variables to be local to the enclosing block,
subroutine, C<eval{}>, or C<do>. If more than one value is listed, the
list must be placed in parentheses. See L<perlsub/"Temporary Values via
-local()"> for details.
+local()"> for details, including issues with tied arrays and hashes.
But you really probably want to be using my() instead, because local() isn't
what most people think of as "local"). See L<perlsub/"Private Variables
@@ -2335,10 +2335,10 @@ If EXPR is omitted, uses $_.
=item rand
-Returns a random fractional number between 0 and the value of EXPR.
-(EXPR should be positive.) If EXPR is omitted, returns a value between
-0 and 1. Automatically calls srand() unless srand() has already been
-called. See also srand().
+Returns a random fractional number greater than or equal to 0 and less
+than the value of EXPR. (EXPR should be positive.) If EXPR is
+omitted, the value 1 is used. Automatically calls srand() unless
+srand() has already been called. See also srand().
(Note: If your rand function consistently returns numbers that are too
large or too small, then your version of Perl was probably compiled
diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index 2eb5229060..28c196017c 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -161,7 +161,7 @@ Take this code:
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
+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<&sv_undef> in the first
line and all will be well.
@@ -225,9 +225,12 @@ 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>.
-note that C<av_fetch> and C<av_store> both return C<SV**>'s, not C<SV*>'s
-as their return value.
+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*);
@@ -247,6 +250,9 @@ by using the following:
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:
@@ -327,6 +333,9 @@ The hash algorithm is defined in the C<PERL_HASH(hash, key, klen)> macro:
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:
@@ -368,6 +377,10 @@ 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
@@ -697,7 +710,7 @@ 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
+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>:
@@ -813,6 +826,65 @@ 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.
+
=head1 Subroutines
=head2 XSUBs and the Argument Stack
@@ -1191,6 +1263,9 @@ 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 av_len
@@ -1230,8 +1305,14 @@ Shifts an SV off the beginning of the array.
=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, otherwise it can be
-dereferenced to get the original C<SV*>.
+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));
@@ -1544,7 +1625,7 @@ and C<hv_free_ent>.
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
+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));
@@ -1553,7 +1634,7 @@ returned.
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
+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));
@@ -1579,6 +1660,9 @@ 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
@@ -1591,6 +1675,9 @@ 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
@@ -1658,8 +1745,14 @@ Returns the package name of a stash. See C<SvSTASH>, C<CvSTASH>.
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, otherwise it can be dereferenced to get the
-original C<SV*>.
+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));
@@ -1668,9 +1761,15 @@ original C<SV*>.
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 entry was stored in a tied hash.
-Otherwise the contents of the return value can be accessed using the
-C<He???> macros described here.
+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));
@@ -1981,7 +2080,7 @@ Releases a Perl interpreter. See L<perlembed>.
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.
+set and the variable does not exist then NULL is returned.
AV* perl_get_av _((char* name, I32 create));
@@ -1989,7 +2088,7 @@ set and the variable does not exist then null is returned.
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.
+set and the variable does not exist then NULL is returned.
CV* perl_get_cv _((char* name, I32 create));
@@ -1997,7 +2096,7 @@ set and the variable does not exist then null is returned.
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.
+set and the variable does not exist then NULL is returned.
HV* perl_get_hv _((char* name, I32 create));
@@ -2005,7 +2104,7 @@ set and the variable does not exist then null is returned.
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.
+set and the variable does not exist then NULL is returned.
SV* perl_get_sv _((char* name, I32 create));
@@ -2957,4 +3056,4 @@ API Listing by Dean Roehrich <F<roehrich@cray.com>>.
=head1 DATE
-Version 31.7: 1997/5/1
+Version 31.8: 1997/5/17
diff --git a/pod/perllol.pod b/pod/perllol.pod
index ac36364ae0..1de3b1ad74 100644
--- a/pod/perllol.pod
+++ b/pod/perllol.pod
@@ -270,7 +270,7 @@ $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; $x <= 12; $y++) {
+ for ($starty = $y = 7; $y <= 12; $y++) {
$newLoL[$x - $startx][$y - $starty] = $LoL[$x][$y];
}
}
diff --git a/pod/perlop.pod b/pod/perlop.pod
index d853865520..32a0827cb3 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -392,7 +392,7 @@ As a scalar operator:
As a list operator:
for (101 .. 200) { print; } # print $_ 100 times
- @foo = @foo[$[ .. $#foo]; # an expensive no-op
+ @foo = @foo[0 .. $#foo]; # an expensive no-op
@foo = @foo[$#foo-4 .. $#foo]; # slice last 5 items
The range operator (in a list context) makes use of the magical
@@ -1058,7 +1058,7 @@ of filenames. The loop
is equivalent to the following Perl-like pseudo code:
- unshift(@ARGV, '-') if $#ARGV < $[;
+ unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
open(ARGV, $ARGV);
while (<ARGV>) {
diff --git a/pod/perlrun.pod b/pod/perlrun.pod
index c4679e1def..de7116d939 100644
--- a/pod/perlrun.pod
+++ b/pod/perlrun.pod
@@ -567,6 +567,17 @@ 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(). 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 your perl executable was built with B<-DDEBUGGING_MSTATS>,
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index c124f21c6a..d08426adab 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -58,7 +58,7 @@ it was assigned to.) Note that assigning to the whole array @_ 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 return statement may be used exit the
+evaluated. Alternatively, a 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,
@@ -469,6 +469,42 @@ both supply a list context to the right-hand side, while
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..]
+
+
=head2 Passing Symbol Table Entries (typeglobs)
[Note: The mechanism described in this section was originally the only
diff --git a/pod/perltoc.pod b/pod/perltoc.pod
index d58f12cf86..989c1efe01 100644
--- a/pod/perltoc.pod
+++ b/pod/perltoc.pod
@@ -775,60 +775,7 @@ search path?
=item AUTHOR AND COPYRIGHT
-=item DESCRIPTION
-
-=over
-
-=item My CGI script runs from the command line but not the browser. Can
-you help me fix it?
-
-=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 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 an email header?
-
-=item How do I decode a CGI form?
-
-=item How do I check a valid email address?
-
-=item How do I decode a MIME/BASE64 string?
-
-=item How do I return the user's email address?
-
-=item How do I send/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 perlfaq9 - Networking ($Revision: 1.16 $, $Date: 1997/04/23 18:12:06
+=head2 perlfaq9 - Networking ($Revision: 1.17 $, $Date: 1997/04/24 22:44:29
$)
=item DESCRIPTION
@@ -894,6 +841,10 @@ CGI script to do bad things?
=over
+=item List assignment to %ENV works
+
+=item "Can't locate Foo.pm in @INC" error now lists @INC
+
=item Compilation option: Binary compatibility with 5.003
=item $PERL5OPT environment variable
@@ -904,6 +855,8 @@ CGI script to do bad things?
=item Deprecated: Inherited C<AUTOLOAD> for non-methods
+=item Previously deprecated %OVERLOAD is no longer usable
+
=item Subroutine arguments created only when they're modified
=item Group vector changeable with C<$)>
@@ -1241,8 +1194,8 @@ B<-T>, B<-u>, B<-U>, B<-v>, B<-V>, B<-V:>I<name>, B<-w>, B<-x> I<directory>
=item ENVIRONMENT
-HOME, LOGDIR, PATH, PERL5LIB, PERL5OPT, PERLLIB, PERL5DB,
-PERL_DEBUG_MSTATS, PERL_DESTRUCT_LEVEL
+HOME, LOGDIR, PATH, PERL5LIB, PERL5OPT, PERLLIB, PERL5DB, PERL5SHELL
+(specific to WIN32 port), PERL_DEBUG_MSTATS, PERL_DESTRUCT_LEVEL
=head2 perlfunc - Perl builtin functions
@@ -2194,6 +2147,8 @@ program
=back
+=item Embedding Perl under Win32
+
=item MORAL
=item AUTHOR
@@ -2408,6 +2363,8 @@ B<PerlIO_get_base(f)>, B<PerlIO_get_bufsiz(f)>
=item Finding Magic
+=item Understanding the Magic of Tied Hashes and Arrays
+
=back
=item Subroutines
@@ -3518,6 +3475,8 @@ For static extensions, For dynamic extensions, For dynamic extensions
=item VMS implementation
+=item Win32 implementation
+
=back
=item SEE ALSO
@@ -3609,9 +3568,10 @@ ExtUtils::MakeMaker
=item DESCRIPTION
-catfile, static_lib (o), dynamic_lib (o), canonpath, perl_script,
-pm_to_blib, test_via_harness (o), tool_autosplit (override), tools_other
-(o), manifypods (o), dist_ci (o), dist_core (o), pasthru (o)
+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
@@ -3786,6 +3746,22 @@ rmscopy($from,$to[,$date_flag])
=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
diff --git a/pod/perltoot.pod b/pod/perltoot.pod
index 2f5634c58c..3a35c05b90 100644
--- a/pod/perltoot.pod
+++ b/pod/perltoot.pod
@@ -89,7 +89,7 @@ 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 an anonymous hash. That's because a
+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.
@@ -799,7 +799,7 @@ 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
+ use Employee;
my $empl = Employee->new();
$empl->name("Jason");
$empl->age(23);
diff --git a/pod/pod2man.PL b/pod/pod2man.PL
index cd14ce2866..2c1837a37a 100644
--- a/pod/pod2man.PL
+++ b/pod/pod2man.PL
@@ -444,6 +444,7 @@ if ($name ne 'something') {
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;
@@ -499,16 +500,36 @@ print <<"END";
.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
@@ -706,6 +727,10 @@ while (<>) {
# 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
@@ -833,8 +858,19 @@ while (<>) {
($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;
+ &escapes($dotlevel);
s/"/""/g;
}
@@ -883,7 +919,7 @@ while (<>) {
if ($needspace) {
&makespace;
}
- &escapes;
+ &escapes(0);
clear_noremap(1);
print $_, "\n";
$needspace = 1;
@@ -915,6 +951,7 @@ sub nobreak {
}
sub escapes {
+ my $indot = shift;
s/X<(.*?)>/mkindex($1)/ge;
@@ -927,9 +964,19 @@ sub escapes {
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\\*(L$2")/ge;
- s/(['"])($|[\-\s,;\\!?.])/noremap("\\*(R$1$2")/ge;
+ s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
+ s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
}
#s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
diff --git a/pod/splitpod b/pod/splitpod
index 8db4060370..889dfa215a 100755
--- a/pod/splitpod
+++ b/pod/splitpod
@@ -18,7 +18,7 @@ while (<>) {
} else {
#s,L</,L<POSIX/,g;
s,L</,L<perlfunc/,g;
- $pod{$cur} .= $_ if $cur;
+ push @{$pod{$cur} ||= []}, $_ if $cur;
}
}
@@ -27,6 +27,12 @@ for $f ( keys %syn ) {
$flavor = $Flavor{$f};
$orig = $f;
($name = $f) =~ s/\W//g;
+ # deal with unbalanced =over and =back cause by the split
+ my $body = $pod{$orig};
+ 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
@@ -39,7 +45,7 @@ $syn{$orig}
=head1 DESCRIPTION
-$pod{$orig}
+$body
EOF