This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[REPATCH 5.005_61] Re: perldiag.pod omissions
[perl5.git] / pod / perlfaq9.pod
index 9927152..2443fc9 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq9 - Networking ($Revision: 1.20 $, $Date: 1998/06/22 18:31:09 $)
+perlfaq9 - Networking ($Revision: 1.26 $, $Date: 1999/05/23 16:08:30 $)
 
 =head1 DESCRIPTION
 
@@ -23,7 +23,7 @@ The useful FAQs and related documents are:
         http://www.webthing.com/page.cgi/cgifaq
 
     Web FAQ
-    http://www.boutell.com/faq/
+        http://www.boutell.com/faq/
 
     WWW Security FAQ
         http://www.w3.org/Security/Faq/
@@ -76,9 +76,8 @@ 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).
+The most correct way (albeit not the fastest) is to use HTML::Parser
+from CPAN (part of the HTML-Tree package on CPAN).
 
 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
@@ -101,7 +100,7 @@ a solution:
 
     <IMG SRC = "foo.gif" ALT = "A > B">
 
-    <IMG SRC = "foo.gif" 
+    <IMG SRC = "foo.gif"
         ALT = "A > B">
 
     <!-- <A comment> -->
@@ -132,12 +131,11 @@ A quick but imperfect approach is
     }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.
+bases, deal with HTML comments, deal with HREF and NAME attributes
+in the same tag, understand extra qualifiers like TARGET, 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?
 
@@ -160,8 +158,9 @@ 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:
+The libwww-perl (LWP) modules from CPAN provide a more powerful way
+to do this.  They don't require lynx, but like lynx, can still work
+through proxies:
 
     # simplest version
     use LWP::Simple;
@@ -172,8 +171,9 @@ do this.  They work through proxies, and don't require lynx:
     getprint "http://www.sn.no/libwww-perl/";
 
     # or print ASCII from HTML from a URL
+    # also need HTML-Tree package from CPAN
     use LWP::Simple;
-    use HTML::Parse;
+    use HTML::Parser;
     use HTML::FormatText;
     my ($html, $ascii);
     $html = get("http://www.perl.com/");
@@ -236,9 +236,21 @@ because of "optimizations" that servers do.
     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.
+To target a particular frame in a frameset, include the "Window-target:"
+in the header.
+
+    print <<EOF;
+    Location: http://www.domain.com/newpage
+    Window-target: <FrameName>
+
+    EOF
+
+To be correct to the spec, each of those virtual newlines should really be
+physical C<"\015\012"> sequences by the time you hit the client browser.
+Except for NPH scripts, though, that local newline should get translated
+by your server into standard form, so you shouldn't have a problem
+here, even if you are stuck on MacOS.  Everybody else probably won't
+even notice.
 
 =head2 How do I put a password on my web pages?
 
@@ -303,7 +315,7 @@ 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).
+http://cgi-lib.stanford.edu/cgi-lib/ ).
 
 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.
@@ -329,7 +341,7 @@ 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
+mail addresses with a simple regex, 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
@@ -411,7 +423,8 @@ Use the C<sendmail> program directly:
     To: Final Destination <you\@otherhost>
     Subject: A relevant subject line
 
-    Body of the message goes here, in as many lines as you like.
+    Body of the message goes here after the blank line
+    in as many lines as you like.
     EOF
     close(SENDMAIL)     or warn "sendmail didn't close nicely";
 
@@ -422,7 +435,12 @@ 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:
+Alternate, less convenient approaches include calling mail (sometimes
+called mailx) directly or simply opening up port 25 have having an
+intimate conversation between just you and the remote SMTP daemon,
+probably sendmail.
+
+Or you might be able use the CPAN module Mail::Mailer:
 
     use Mail::Mailer;
 
@@ -437,35 +455,17 @@ Or use the CPAN module Mail::Mailer:
 
 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 
+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 
+While you could 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), 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;
@@ -476,12 +476,12 @@ Often a module is overkill, though.  Here's a mail sorter.
             $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, 
+Or more succinctly,
 
     #!/usr/bin/perl -n00
     # bysub2 - awkish sort-by-subject
@@ -504,7 +504,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($name)) || 'localhost');
+    my $addr = inet_ntoa(scalar gethostbyname($host || '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
@@ -531,11 +531,12 @@ available from CPAN) is more complex but can put as well as fetch.
 
 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.
+CPAN).  The rpcgen suite, available from CPAN/authors/id/JAKE/, is
+an RPC stub generator and includes an RPC::ONC module.
 
 =head1 AUTHOR AND COPYRIGHT
 
-Copyright (c) 1997, 1998 Tom Christiansen and Nathan Torkington.
+Copyright (c) 1997-1999 Tom Christiansen and Nathan Torkington.
 All rights reserved.
 
 When included as part of the Standard Version of Perl, or as part of