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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!chx400!bernina!neptune!weingart
  3. From: weingart@inf.ethz.ch (Tobias Weingartner)
  4. Subject: split !!
  5. Message-ID: <1992Aug30.172231.11281@neptune.inf.ethz.ch>
  6. Followup-To: weingart@inf.ethz.ch
  7. Keywords: split, GRRR
  8. Sender: news@neptune.inf.ethz.ch (Mr News)
  9. Nntp-Posting-Host: tau.inf.ethz.ch
  10. Reply-To: weingart@inf.ethz.ch
  11. Organization: ETH - Switzerland
  12. Date: Sun, 30 Aug 1992 17:22:31 GMT
  13. Lines: 45
  14.  
  15.  
  16. Hello, I have run into a little trouble here.
  17. I have a database, made up like the following:
  18.  
  19. field:field:etc:etc:etc
  20.  
  21. Well, the split operation (a la split(/:/, $foobar)) works
  22. quite nicely on this.  The trouble comes from the users here.
  23.  
  24. What if the use types in a : for part of his neato reply?
  25. You guessed it! Ka-Boom.
  26.  
  27. I thought that I could do something like this:
  28.  
  29. print "Enter response: ";
  30. chop(@line[0] = <STDIN>);
  31. @line[0] =~ s/:/\\:/;
  32.  
  33. ...
  34.  
  35. $data = join(':', @line);
  36. print FILE $data.'\n';
  37.  
  38. ...
  39.  
  40. Then to read it in:
  41.  
  42. chop($data = <FILE>);
  43. @line = split(/[^\\]:/, $data);
  44.  
  45.  
  46. This splits the lines appropriately, but there is a
  47. character chopped off.
  48.  
  49. What I am looking for, is something like in lex:
  50.  
  51. [^\\]/:    {split();}
  52.  
  53. Where the split will only be done if the perceading
  54. character is not a \.
  55.  
  56. Any ideas?
  57.  
  58. --Toby.
  59.  
  60.