From: Jarkko Hietaniemi Date: Thu, 18 Oct 2001 00:10:44 +0000 (+0000) Subject: FAQ sync. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8305e449a259649641f455b333f66bc0de7f3b62;p=p5sagit%2Fp5-mst-13.2.git FAQ sync. p4raw-id: //depot/perl@12486 --- diff --git a/pod/perlfaq.pod b/pod/perlfaq.pod index 556a010..4c65915 100644 --- a/pod/perlfaq.pod +++ b/pod/perlfaq.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq - frequently asked questions about Perl ($Date: 2001/09/20 03:03:00 $) +perlfaq - frequently asked questions about Perl ($Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -1372,7 +1372,7 @@ of perlfaq7 on variable names within variables. =item 7/January/99 -Small touchups here and there. Added all questions in this +Small touch ups here and there. Added all questions in this document as a sort of table of contents. =item 22/June/98 diff --git a/pod/perlfaq2.pod b/pod/perlfaq2.pod index 0832fb6..52dc457 100644 --- a/pod/perlfaq2.pod +++ b/pod/perlfaq2.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.1 $, $Date: 2001/09/20 03:03:00 $) +perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.2 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -440,7 +440,7 @@ 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, scores of software designers and developers, and myriads of +Larry, scores of software designers and developers, and myriad programmers, all working for free to create a useful thing to make life better for everyone. diff --git a/pod/perlfaq3.pod b/pod/perlfaq3.pod index 27a54fa..e4d03fb 100644 --- a/pod/perlfaq3.pod +++ b/pod/perlfaq3.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq3 - Programming Tools ($Revision: 1.7 $, $Date: 2001/10/09 22:17:53 $) +perlfaq3 - Programming Tools ($Revision: 1.8 $, $Date: 2001/10/17 14:14:20 $) =head1 DESCRIPTION @@ -869,30 +869,11 @@ 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/tutorials/cgifaq.html - - 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 +when it runs fine on the command line'', see the troubleshooting +guides and references in L or in the CGI MetaFAQ: + http://www.perl.org/CGI_MetaFAQ.html + =head2 Where can I learn about object-oriented Perl programming? A good place to start is L, and you can use L, diff --git a/pod/perlfaq5.pod b/pod/perlfaq5.pod index bfd6d35..95957eb 100644 --- a/pod/perlfaq5.pod +++ b/pod/perlfaq5.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq5 - Files and Formats ($Revision: 1.2 $, $Date: 2001/09/26 10:44:41 $) +perlfaq5 - Files and Formats ($Revision: 1.3 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -67,7 +67,7 @@ or even this: $document = join('', <$sock>); print "DOC IS: $document\n"; -Note the bizarrely hardcoded carriage return and newline in their octal +Note the bizarrely hard coded 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's the way things work in network programming: you really should specify the exact bit pattern @@ -242,7 +242,7 @@ Berkeley-style ps: We've used C<$$var> in a way that forbidden by C. 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 +symbolic references. This is okay 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? @@ -376,7 +376,7 @@ 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 of hashes or arrays, can be used with built-ins like C, C, or the diamond operator. Using -something other than a simple scalar varaible as a filehandle is +something other than a simple scalar variable as a filehandle is illegal and won't even compile: @fd = (*STDIN, *STDOUT, *STDERR); @@ -733,7 +733,7 @@ If you know you are only writing code to run on an OS and filesystem that does implement append mode correctly (a local filesystem on a modern Unix for example), and you keep the file in block-buffered mode and you write less than one buffer-full of output between each manual flushing -of the buffer then each bufferload is almost garanteed to be written to +of the buffer then each bufferload is almost guaranteed to be written to the end of the file in one chunk without getting intermingled with anyone else's output. You can also use the syswrite() function which is simply a wrapper around your systems write(2) system call. @@ -771,7 +771,7 @@ Don't forget them or you'll be quite sorry. 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. These +B<-A>, or B<-C> file test operations as documented in L. 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, @@ -1024,7 +1024,7 @@ Or write a small C program using the editor of champions: % ./fionread 0x4004667f -And then hard-code it, leaving porting as an exercise to your successor. +And then hard code it, leaving porting as an exercise to your successor. $FIONREAD = 0x4004667f; # XXX: opsys dependent diff --git a/pod/perlfaq6.pod b/pod/perlfaq6.pod index 1cad815..4a52259 100644 --- a/pod/perlfaq6.pod +++ b/pod/perlfaq6.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq6 - Regexes ($Revision: 1.1 $, $Date: 2001/09/20 03:03:00 $) +perlfaq6 - Regexes ($Revision: 1.3 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -194,7 +194,7 @@ properties of bitwise xor on ASCII strings. print; -And here it is as a subroutine, modelled after the above: +And here it is as a subroutine, modeled after the above: sub preserve_case($$) { my ($old, $new) = @_; @@ -383,20 +383,30 @@ A slight modification also removes C++ 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--with -the possible exception of bizarre and experimental features in the -development-track releases of Perl. You still need to use non-regex -techniques to parse balanced text, such as the text enclosed between -matching parentheses or braces, for example. +Historically, Perl regular expressions were not capable of matching +balanced text. As of more recent versions of perl including 5.6.1 +experimental features have been added that make it possible to do this. +Look at the documentation for the (??{ }) construct in recent perlre manual +pages to see an example of matching balanced parentheses. Be sure to take +special notice of the warnings present in the manual before making use +of this feature. + +CPAN contains many modules that can be useful for matching text +depending on the context. Damian Conway provides some useful +patterns in Regexp::Common. The module Text::Balanced provides a +general solution to this problem. + +One of the common applications of balanced text matching is working +with XML and HTML. There are many modules available that support +these needs. Two examples are HTML::Parser and XML::Parser. There +are many others. 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 use, +The C::Scan module from CPAN also contains such subs for internal use, but they are undocumented. =head2 What does it mean that regexes are greedy? How can I get around it? diff --git a/pod/perlfaq7.pod b/pod/perlfaq7.pod index 50dc83f..b1d3917 100644 --- a/pod/perlfaq7.pod +++ b/pod/perlfaq7.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq7 - Perl Language Issues ($Revision: 1.1 $, $Date: 2001/09/20 03:03:00 $) +perlfaq7 - Perl Language Issues ($Revision: 1.2 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -184,7 +184,7 @@ own module. Make sure to change the names appropriately. # if using RCS/CVS, this next line may be preferred, # but beware two-digit versions. - $VERSION = do{my@r=q$Revision: 1.1 $=~/\d+/g;sprintf '%d.'.'%02d'x$#r,@r}; + $VERSION = do{my@r=q$Revision: 1.2 $=~/\d+/g;sprintf '%d.'.'%02d'x$#r,@r}; @ISA = qw(Exporter); @EXPORT = qw(&func1 &func2 &func3); @@ -682,7 +682,7 @@ construct like this: 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 +We'll do a multiway conditional based on the type of reference stored in $whatchamacallit: SWITCH: for (ref $whatchamacallit) { diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod index e2fd28c..19be3be 100644 --- a/pod/perlfaq8.pod +++ b/pod/perlfaq8.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq8 - System Interaction ($Revision: 1.1 $, $Date: 2001/09/20 03:03:00 $) +perlfaq8 - System Interaction ($Revision: 1.2 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -294,7 +294,7 @@ of code just because you're afraid of a little $| variable: 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 +socket I/O between Unix and Macintosh. You'll need to hard code your line terminators, in that case. =item non-blocking input @@ -435,7 +435,7 @@ 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. -However, if all you want to do is change your timezone, you can +However, if all you want to do is change your time zone, you can probably get away with setting an environment variable: $ENV{TZ} = "MST7MDT"; # unixish diff --git a/pod/perlfaq9.pod b/pod/perlfaq9.pod index 3bf862f..f7b81d5 100644 --- a/pod/perlfaq9.pod +++ b/pod/perlfaq9.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq9 - Networking ($Revision: 1.2 $, $Date: 2001/09/28 06:40:07 $) +perlfaq9 - Networking ($Revision: 1.3 $, $Date: 2001/10/16 13:27:22 $) =head1 DESCRIPTION @@ -487,7 +487,7 @@ Or you might be able 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 -include queueing, MX records, and security. +include queuing, MX records, and security. =head2 How do I use MIME to make an attachment to a mail message?