add verbose stack display option, -Dvs
[p5sagit/p5-mst-13.2.git] / pod / perlfaq6.pod
index 7c9fa6a..4e5ba50 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq6 - Regexes ($Revision: 1.4 $, $Date: 2001/11/09 08:06:04 $)
+perlfaq6 - Regular Expressions ($Revision: 1.12 $, $Date: 2002/06/01 22:31:09 $)
 
 =head1 DESCRIPTION
 
@@ -9,7 +9,7 @@ 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 L<perlfaq9>: ``How do I decode or create those %-encodings 
-on the web'' and L<perfaq4>: ``How do I determine whether a scalar is
+on the web'' and L<perlfaq4>: ``How do I determine whether a scalar is
 a number/whole/integer/float'', to be precise).
 
 =head2 How can I hope to use regular expressions without creating illegible and unmaintainable code?
@@ -70,9 +70,9 @@ delimiter within the pattern:
 
 =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).
+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 $/
@@ -166,7 +166,7 @@ appear within a certain time.
     close FH;
 
     ## Get a read/write filehandle to it.
-    $fh = new FileHandle "+<file";
+    $fh = new IO::File "+<file";
 
     ## Attach it to a "stream" object.
     use Net::Telnet;
@@ -218,10 +218,10 @@ longer than the original, you can use this code, by Jeff Pinyan:
   sub preserve_case {
     my ($from, $to) = @_;
     my ($lf, $lt) = map length, @_;
-    
+
     if ($lt < $lf) { $from = substr $from, 0, $lt }
     else { $from .= substr $to, $lf }
-    
+
     return uc $to | ($from ^ uc $from);
   }
 
@@ -279,7 +279,7 @@ consider an underscore a letter).
 
 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 an C<s///> substitution is considered
+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 regex special characters will be acted on unless you
 precede the substitution with \Q.  Here's an example:
@@ -634,18 +634,29 @@ 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!
+The problem is that both grep and map build a return list,
+regardless of the context.  This means you're making Perl go
+to the trouble of building a list that you then just throw away.
+If the list is large, you waste both time and space.  If your
+intent is to iterate over the list then use a for loop for this
+purpose.
 
 =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.
+Starting from Perl 5.6 Perl has had some level of multibyte character
+support.  Perl 5.8 or later is recommended.  Supported multibyte
+character repertoires include Unicode, and legacy encodings
+through the Encode module.  See L<perluniintro>, L<perlunicode>,
+and L<Encode>.
+
+If you are stuck with older Perls, you can do Unicode with the
+C<Unicode::String> module, and character conversions using the
+C<Unicode::Map8> and C<Unicode::Map> modules.  If you are using
+Japanese encodings, you might try using the jperl 5.005_03.
+
+Finally, 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
@@ -719,7 +730,7 @@ in L<perlre>.
 
 =head1 AUTHOR AND COPYRIGHT
 
-Copyright (c) 1997-1999 Tom Christiansen and Nathan Torkington.
+Copyright (c) 1997-2002 Tom Christiansen and Nathan Torkington.
 All rights reserved.
 
 This documentation is free; you can redistribute it and/or modify it