diff options
author | Tom Christiansen <tchrist@perl.com> | 1998-06-13 16:19:32 -0600 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-15 01:37:12 +0000 |
commit | 5a964f204835a8014f4ba86fc91884cff958ac67 (patch) | |
tree | b1ad7153799ba133ce772012c9dc05ea615f1c6e /pod/perlfaq6.pod | |
parent | ad973f306c11e119dc3a8448590409962bde25db (diff) | |
download | perl-5a964f204835a8014f4ba86fc91884cff958ac67.tar.gz |
documentation update from tchrist
Message-Id: <199806140419.WAA20549@chthon.perl.com>
Subject: doc patches
p4raw-id: //depot/perl@1132
Diffstat (limited to 'pod/perlfaq6.pod')
-rw-r--r-- | pod/perlfaq6.pod | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/pod/perlfaq6.pod b/pod/perlfaq6.pod index 535e464455..0e94f9b2bb 100644 --- a/pod/perlfaq6.pod +++ b/pod/perlfaq6.pod @@ -25,7 +25,7 @@ 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) /ge; + s/^(\w+)(.*)/ lc($1) . ":" . length($2) /meg; =item Comments Inside the Regexp @@ -69,8 +69,9 @@ delimiter within the pattern: =head2 I'm having trouble matching over more than one line. What's wrong? -Either you don't have newlines in your string, or you aren't using the -correct modifier(s) on your pattern. +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 $/ @@ -94,7 +95,7 @@ record read in. $/ = ''; # read in more whole paragraph, not just one line while ( <> ) { - while ( /\b(\w\S+)(\s+\1)+\b/gi ) { + while ( /\b([\w'-]+)(\s+\1)+\b/gi ) { # word starts alpha print "Duplicate $1 at paragraph $.\n"; } } @@ -133,6 +134,16 @@ 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 @@ -211,7 +222,7 @@ This prints: this is a SUcCESS case -=head2 How can I make C<\w> match accented characters? +=head2 How can I make C<\w> match national character sets? See L<perllocale>. @@ -600,6 +611,18 @@ all mixed. =head1 AUTHOR AND COPYRIGHT -Copyright (c) 1997 Tom Christiansen and Nathan Torkington. -All rights reserved. See L<perlfaq> for distribution information. - +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. |