home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7437 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  2.1 KB

  1. Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!mbeattie
  2. From: mbeattie@black.ox.ac.uk (Malcolm Beattie)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: programming challenge
  5. Message-ID: <1992Dec15.160559.20946@black.ox.ac.uk>
  6. Date: 15 Dec 92 16:05:59 GMT
  7. References: <1992Dec12.100131.11703@zooid.guild.org> <mcook.724208660@fendahl.dev.cdx.mot.com>
  8. Organization: Oxford University Computing Service, 13 Banbury Rd, Oxford, U
  9. Lines: 52
  10. Originator: mbeattie@black
  11.  
  12. In article <mcook.724208660@fendahl.dev.cdx.mot.com> mcook@fendahl.dev.cdx.mot.com (Michael Cook) writes:
  13. >Mike Stramba <stramba@zooid.guild.org> writes:
  14. >
  15. >>Ok, all you perl wizards out there.
  16. >
  17. >>This out'a be a snap for ya.
  18. >
  19. >> If I have the string :
  20. >
  21. >>          Exxxxppppppprrrrrrreeeeesssssiiiiiiiiioooooonnnnnnnnnsssssssss
  22. >
  23. >> and I want to kill the duplicated letters and end up with:
  24. >
  25. >>          Expressions
  26. >
  27. >You mean "Expresions", right?
  28. >
  29. >> Lets' see some of your elegant solutions !
  30. >
  31. >> Btw, this problem came up as a result of trying to edit a formatted man
  32. >> page ... for guess what program ?  (starts with 'P ... ends with 'l')
  33. >
  34. >> Why am I editing a man page? ... because my computer, an Atari doesn't know
  35. >> about them.
  36. >
  37. >> I'm interested in seeing solutions to the above, anyway.
  38. >
  39. >>Mike
  40. >
  41. [reply deleted]
  42.  
  43. The orginal post with the question hasn't reached here yet so
  44. I'll reply to the reply. How about:
  45.  
  46. tr/\0-\377//s
  47.  
  48. or you can restrict the range if you wish. My first attempt
  49. was to complement the null SEARCHLIST and do tr///cs in order
  50. to save using \0-\377 but the complement is done before the
  51. searchlist gets copied in place of the null replacelist.
  52.  
  53. A little further playing turned up the short incantation
  54. tr/*//c
  55. which turns all the characters in $_ into asterisks. Probably
  56. useless but rather neat, I thought.
  57.  
  58. --Malcolm
  59. -- 
  60. Malcolm Beattie <mbeattie@black.ox.ac.uk> | I'm not a kernel hacker
  61. Oxford University Computing Services      | I'm a kernel hacker's mate
  62. 13 Banbury Road, Oxford, OX2 6NN (U.K.)   | And I'm only hacking kernels
  63. Tel: +44 865 273232 Fax: +44 865 273275   | 'Cos the kernel hacker's late
  64.