SPUG: Regex/matching-op Problem

Tim Maher tim at consultix-inc.com
Thu Aug 14 18:38:12 CDT 2003


HELP!

My brain has fallen down, and it can't get back up!

I can't figure out why this program won't match two sentences in the same
line, as with the "rejoicing" one. See another source of confusion in final
comments way below.

Any ideas?

-Tim
(aka "Yumpy the Certifier")


perl -wln -e 'BEGIN { $/="" ; $,="\n\n"; }
	print /(?:And|Or|But)\b[^.?!]+?[.?!]/g ;' <<Eof

Many generations of cruft had accumulated in the Attic of Perl,
giving rise to much whinging amongst the JAPHs and longing
for the coming of Perlitus Sixtus.

And so it came to pass that The Larry blessed a Ponie, 
and appointed brave knights, armed with the Sticks of the Riddle, to guide her. 

And there was great rejoicing among JAPHs everywhere.  And much grog was quenched.

But there was no quenching by The Damian, 
who graciously bequeathed his share to Yumpy the Certifier.

Eof

# Problem: I want the "rejoicing" line to match twice, but I don't even get once
# Clues: A trailing space after the period on any line prevents its match; why?

-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX  (866) DOC-PERL  (866) DOC-UNIX   |
| tim(AT)Consultix-Inc.Com  TeachMeUnix.Com  TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
|  Watch for my Book: "Minimal Perl for Shell Programmers"   |
*------------------------------------------------------------*



More information about the spug-list mailing list