[CMI.PM] Multi-line substitution?

Milt Epstein mepstein at uiuc.edu
Wed Jan 21 16:18:33 CST 2004


On Wed, 21 Jan 2004, Mitch Kutzko wrote:

> Anyone?  Anyone?  Bueller?  Bueller?
> ;-)

Someone responded to your post, didn't you see it?  They said the
problem was related to the fact that you're calling perl with the '-p'
option, which effectively feeds a line at a time to your script,
essentially making the use of the 's' modifier irrelevant.


> --------------------
>
> Hi,  folks -- I'm trying to remove the following three lines from a website
> I run, and these three lines occur in many files on the site:
>
> 	<p>
>
> 	<table border="0" width="800" cellpadding="15" cellspacing="0">
>
>
> I've looked in the Cookbook and on the web, and by all the accounts and
> examples I can find, this should work, but it doesn't.  Doesn't do a dang
> thing, in fact.  (Which tells me it's not matching, of course, but I don't
> see how it can not match.)
>
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//s
>
> If I reduce the match string down to the whole <table> command by itself,
> it works fine.  Basically, it just refuses to match across more than one
> line.
>
> I've tried the following, all with the same utter lack of results over
> multiple lines:
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//sm
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//smg
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//m
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//mg
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*<table border="0" width="800" cellpadding="15" cellspacing="0">//sm
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>.*?<table border="0" width="800" cellpadding="15" cellspacing="0">//s
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>..<table border="0" width="800" cellpadding="15" cellspacing="0">//s
>
> 	#!/usr/bin/perl -pi.old
> 	s/<p>...<table border="0" width="800" cellpadding="15" cellspacing="0">//s
>
> 	#!/usr/bin/perl -pi.old
> 	s/\<p\>.*\<table border="0" width="800" cellpadding="15" cellspacing="0"\>//s
>
> etc...  (You get the idea by now, I'm sure...  ;-) )
>
> This should be (and, of course, will turn out to be) painfully simple to
> do.  What am I not doing?
>
>
> Thoughts?  Ideas?  Suggestions?  Tequila?
>
> ;-)
>
> As always, thanks in advance!
>
> Mitch
> --
> Mitch Kutzko | mitch at dast.nlanr.net | mitch at ncsa.uiuc.edu | 217-333-1199
> http://hobbes.ncsa.uiuc.edu/
> _______________________________________________
> Champaign-Urbana mailing list
> Champaign-Urbana at mail.pm.org
> http://mail.pm.org/mailman/listinfo/champaign-urbana
>

Milt Epstein
Research Programmer
Integration and Software Engineering (ISE)
Campus Information Technologies and Educational Services (CITES)
University of Illinois at Urbana-Champaign (UIUC)
mepstein at uiuc.edu



More information about the Champaign-Urbana mailing list