home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5618 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1.2 KB  |  42 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!gumby!destroyer!ubc-cs!dhami
  3. From: dhami@cs.ubc.ca (Mandeep S Dhami)
  4. Subject: >split !!
  5. Message-ID: <1992Aug31.013131.16385@cs.ubc.ca>
  6. Summary: use an impossible char.
  7. Keywords: split, \:,
  8. Sender: usenet@cs.ubc.ca (Usenet News)
  9. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  10. Date: Mon, 31 Aug 92 01:31:31 GMT
  11. Lines: 29
  12.  
  13. > What I am looking for, is something like in lex:
  14. > [^\\]/:    {split();}
  15. > Where the split will only be done if the perceading
  16. > character is not a \.
  17. > Any ideas?
  18. >
  19.  
  20. Try:
  21. $x='a:b:c\:d:e";     # Or any other way!
  22. $x=~s/\\\:/\377/g;   # Or any other char NOT in input domain
  23. @x=grep(s/\377/\:/g||1,split(':',$x));
  24.              # ^^ or \\\: depending on if you want c\:d or c:d
  25.  
  26. Also, instead of substituting \: (as in your posting
  27. you may substitute \377 and save a step).
  28.  
  29. Hope this helps.
  30.  
  31. Mandeep.
  32. dhami@cs.ubc.ca
  33. --
  34. __________________________________________________________________
  35. "I'm very brave generally," he went on in a low voice:
  36. "only to-day I happen to have a headache."
  37.                                       -- Lewis Carroll
  38.