From owner-freebsd-questions@FreeBSD.ORG Sat Jan 10 17:44:21 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B10E16A4CE for ; Sat, 10 Jan 2004 17:44:21 -0800 (PST) Received: from sage.thought.org (dsl231-043-140.sea1.dsl.speakeasy.net [216.231.43.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id D01CD43D1F for ; Sat, 10 Jan 2004 17:44:11 -0800 (PST) (envelope-from kline@thought.org) Received: from thought.org (root@tao [10.0.0.247]) by sage.thought.org (8.12.9/8.11.4) with ESMTP id i0B1jeGH015595; Sat, 10 Jan 2004 17:45:43 -0800 (PST) (envelope-from kline@thought.org) Received: (from kline@localhost) by thought.org (8.12.6/8.11.3) id i0B1htKY044820; Sat, 10 Jan 2004 17:43:55 -0800 (PST) (envelope-from kline) Date: Sat, 10 Jan 2004 17:43:54 -0800 From: Gary Kline To: Matthew Seaman , Marty Landman , FreeBSD Mailing List , Gary Kline Message-ID: <20040111014354.GD44177@tao.thought.org> References: <20040110221036.GA44130@tao.thought.org> <20040110223308.GA4881@happy-idiot-talk.infracaninophile.co.uk> <20040110223907.GA16659@Uruk-Hai.Sanitarium.mine.nu> <20040110230218.GA5347@happy-idiot-talk.infracaninophile.co.uk> <6.0.0.22.0.20040110182450.0a09ce58@pop.face2interface.com> <20040110233645.GA5668@happy-idiot-talk.infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040110233645.GA5668@happy-idiot-talk.infracaninophile.co.uk> X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: Observing 17 years of service to the Unix community User-Agent: Mutt/1.5.5.1i Subject: Re: perl script question. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jan 2004 01:44:21 -0000 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/_/ /' > > 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@thought.org www.thought.org Public service Unix