home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7432 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.7 KB  |  63 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!uunet.ca!geac!zooid!stramba
  3. From: Mike Stramba <stramba@zooid.guild.org>
  4. Subject: Re: programming challenge
  5. Organization: The Zoo of Ids
  6. Date: Tue, 15 Dec 1992 07:06:53 GMT
  7. Message-ID: <1992Dec15.070653.7276@zooid.guild.org>
  8. References: <1992Dec12.100131.11703@zooid.guild.org> <1992Dec14.114044.22303@cs.ruu.nl>
  9.     <1992Dec14.185822.7058@wdl.loral.com>
  10. Lines: 51
  11.  
  12.   In article <1992Dec14.185822.7058@wdl.loral.com>,
  13.   mab@wdl39.wdl.loral.com (Mark A Biggar) writes:
  14.  
  15. >This looks like a job for s.... oops he's dead, oh well how about the 
  16. >'s' modifier of the tr command like so:
  17. >
  18. >perl -pie 'tr///cs/;' <files>
  19. >
  20. >which zaps all consecutive chars in the files.  
  21. >To limit it to just letters use:
  22. >
  23. >perl -pie 'tr/a-zA-Z//s;' <files>
  24. >
  25. >but of course this doesn't really solve the 'Goofy' problem which doesn't
  26. >have a general solution even with the addition of dictionary lookup because
  27. >word pairs like 'met' vs 'meet'.  That problem looks like it take a full
  28. >English understanding AI to solve.
  29. >
  30.  
  31. Yup, the 'tr.../s' command is the solution, as far as what I needed.
  32.  
  33. I just got the Camel book (now I know why it's called that !) and there it was
  34. under 'Common Tasks with Perl'.
  35.  
  36. It may be in the man page as well, but I haven't managed to read it all yet !
  37.  
  38. I noticed the 'Goofy' problem as well, but that isn't too important.
  39.  
  40. What I was puzzling over tonight was whether there was a single line 's/'
  41. command syntax to delete all '_' characters but not '$_'. I did it with 
  42. two lines:
  43.  
  44.   s/( )_/$1/g;             # change ' _'  to ' '
  45.   
  46.   s/(\w)_/$1/g;            # change '\w_' to '\w'
  47.  
  48. There probably wouldn't be any advantage to having it in one line ???
  49.  
  50. Mike
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.