perl script question.

Gary Kline kline at thought.org
Sat Jan 10 17:44:21 PST 2004


On Sat, Jan 10, 2004 at 11:36:45PM +0000, Matthew Seaman wrote:
> On Sat, Jan 10, 2004 at 06:26:30PM -0500, Marty Landman wrote:
> > At 06:02 PM 1/10/2004, Matthew Seaman wrote:
> > >On Sat, Jan 10, 2004 at 11:39:07PM +0100, Björn Andersson wrote:
> > >
> > >> If this occures more than once on a line we should have the line as this:
> > >>   perl -pi.bak -e 's/\s+\w+_\w+\.?//g;' filename
> > >
> > >Good point.  Also, if the stuff_separated_by_underscores wraps around
> > >onto more than one line, then there may not be any leading whitespace:
> > 
> > I don't see why the translate sol'tn that Gary Kline gave first isn't 
> > adequate.
> 
> Err --- Gary Kline was the OP asking how to do this: I think you mean 
> Bernard El-Hagin's solution?
> 
>     % perl -i.bak -pe 'tr/_/ /' <files>
> 
> That doesn't do the right thing.  It turns:
> 
>     "This is a sample ordinary sentence.  This_is_joined_up_with_underscores."
> 
> into:
> 
>     "This is a sample ordinary sentence.  This is joined up with underscores."
> 
> but the requirement is to produce:
> 
>     "This is a sample ordinary sentence."
> 

	Exactly so.  I could easily tr '_' to ' ', but not delete //g
	and entire string that contained undrscores.  BTW, this 
	kind of technique would be useful in filtering 
	^ Subject: lines like "get.a.bigger.bustline" or other such
	garbage.  --But then the people who hack the antispam 
	programs are do doubt expert at this... .

	gary




-- 
   Gary Kline     kline at thought.org   www.thought.org     Public service Unix



More information about the freebsd-questions mailing list