diff options
author | Ilya Zakharevich <ilya@math.ohio-state.edu> | 1997-01-21 10:26:32 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-25 15:58:00 +1200 |
commit | e7ea3e70155d0bea30720ba41eb6bb6742aac0d1 (patch) | |
tree | eced55218bc1fc8626006cea8162ac9db29e39f1 /pod/perlop.pod | |
parent | 9e3a2af888982d0a201149cbcdbf3feb6771acb4 (diff) | |
download | perl-e7ea3e70155d0bea30720ba41eb6bb6742aac0d1.tar.gz |
patch for LWP 5.05 to make it play with both 5.003 and 5.003_20 + overload patch
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r-- | pod/perlop.pod | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index dd3aeab663..55108f0328 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -737,6 +737,32 @@ The last example should print: Note how C<m//g> matches change the value reported by C<pos()>, but the non-global match doesn't. +A useful idiom for C<lex>-like scanners is C</\G.../g>. You can +combine several regexps like this to process a string part-by-part, +doing different actions depending on which regexp matched. The next +regexp would step in at the place the previous one left off. + + $_ = <<'EOL'; + $url = new URI::URL "http://www/"; die if $url eq "xXx"; +EOL + LOOP: + { + print(" digits"), redo LOOP if /\G\d+\b[,.;]?\s*/g; + print(" lowercase"), redo LOOP if /\G[a-z]+\b[,.;]?\s*/g; + print(" UPPERCASE"), redo LOOP if /\G[A-Z]+\b[,.;]?\s*/g; + print(" Capitalized"), redo LOOP if /\G[A-Z][a-z]+\b[,.;]?\s*/g; + print(" MiXeD"), redo LOOP if /\G[A-Za-z]+\b[,.;]?\s*/g; + print(" alphanumeric"), redo LOOP if /\G[A-Za-z0-9]+\b[,.;]?\s*/g; + print(" line-noise"), redo LOOP if /\G[^A-Za-z0-9]+/g; + print ". That's all!\n"; + } + +Here is the output (split into several lines): + + line-noise lowercase line-noise lowercase UPPERCASE line-noise + UPPERCASE line-noise lowercase line-noise lowercase line-noise + lowercase lowercase line-noise lowercase lowercase line-noise + MiXeD line-noise. That's all! =item q/STRING/ |