home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!mbeattie
- From: mbeattie@black.ox.ac.uk (Malcolm Beattie)
- Newsgroups: comp.lang.perl
- Subject: Re: programming challenge
- Message-ID: <1992Dec15.160559.20946@black.ox.ac.uk>
- Date: 15 Dec 92 16:05:59 GMT
- References: <1992Dec12.100131.11703@zooid.guild.org> <mcook.724208660@fendahl.dev.cdx.mot.com>
- Organization: Oxford University Computing Service, 13 Banbury Rd, Oxford, U
- Lines: 52
- Originator: mbeattie@black
-
- In article <mcook.724208660@fendahl.dev.cdx.mot.com> mcook@fendahl.dev.cdx.mot.com (Michael Cook) writes:
- >Mike Stramba <stramba@zooid.guild.org> writes:
- >
- >>Ok, all you perl wizards out there.
- >
- >>This out'a be a snap for ya.
- >
- >> If I have the string :
- >
- >> Exxxxppppppprrrrrrreeeeesssssiiiiiiiiioooooonnnnnnnnnsssssssss
- >
- >> and I want to kill the duplicated letters and end up with:
- >
- >> Expressions
- >
- >You mean "Expresions", right?
- >
- >> Lets' see some of your elegant solutions !
- >
- >> Btw, this problem came up as a result of trying to edit a formatted man
- >> page ... for guess what program ? (starts with 'P ... ends with 'l')
- >
- >> Why am I editing a man page? ... because my computer, an Atari doesn't know
- >> about them.
- >
- >> I'm interested in seeing solutions to the above, anyway.
- >
- >>Mike
- >
- [reply deleted]
-
- The orginal post with the question hasn't reached here yet so
- I'll reply to the reply. How about:
-
- tr/\0-\377//s
-
- or you can restrict the range if you wish. My first attempt
- was to complement the null SEARCHLIST and do tr///cs in order
- to save using \0-\377 but the complement is done before the
- searchlist gets copied in place of the null replacelist.
-
- A little further playing turned up the short incantation
- tr/*//c
- which turns all the characters in $_ into asterisks. Probably
- useless but rather neat, I thought.
-
- --Malcolm
- --
- Malcolm Beattie <mbeattie@black.ox.ac.uk> | I'm not a kernel hacker
- Oxford University Computing Services | I'm a kernel hacker's mate
- 13 Banbury Road, Oxford, OX2 6NN (U.K.) | And I'm only hacking kernels
- Tel: +44 865 273232 Fax: +44 865 273275 | 'Cos the kernel hacker's late
-