home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!uunet.ca!geac!zooid!stramba
- From: Mike Stramba <stramba@zooid.guild.org>
- Subject: Re: programming challenge
- Organization: The Zoo of Ids
- Date: Tue, 15 Dec 1992 07:06:53 GMT
- Message-ID: <1992Dec15.070653.7276@zooid.guild.org>
- References: <1992Dec12.100131.11703@zooid.guild.org> <1992Dec14.114044.22303@cs.ruu.nl>
- <1992Dec14.185822.7058@wdl.loral.com>
- Lines: 51
-
- In article <1992Dec14.185822.7058@wdl.loral.com>,
- mab@wdl39.wdl.loral.com (Mark A Biggar) writes:
-
- >This looks like a job for s.... oops he's dead, oh well how about the
- >'s' modifier of the tr command like so:
- >
- >perl -pie 'tr///cs/;' <files>
- >
- >which zaps all consecutive chars in the files.
- >To limit it to just letters use:
- >
- >perl -pie 'tr/a-zA-Z//s;' <files>
- >
- >but of course this doesn't really solve the 'Goofy' problem which doesn't
- >have a general solution even with the addition of dictionary lookup because
- >word pairs like 'met' vs 'meet'. That problem looks like it take a full
- >English understanding AI to solve.
- >
-
- Yup, the 'tr.../s' command is the solution, as far as what I needed.
-
- I just got the Camel book (now I know why it's called that !) and there it was
- under 'Common Tasks with Perl'.
-
- It may be in the man page as well, but I haven't managed to read it all yet !
-
- I noticed the 'Goofy' problem as well, but that isn't too important.
-
- What I was puzzling over tonight was whether there was a single line 's/'
- command syntax to delete all '_' characters but not '$_'. I did it with
- two lines:
-
- s/( )_/$1/g; # change ' _' to ' '
-
- s/(\w)_/$1/g; # change '\w_' to '\w'
-
- There probably wouldn't be any advantage to having it in one line ???
-
- Mike
-
-
-
-
-
-
-
-
-
-
-
-
-