home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- 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
- From: weingart@inf.ethz.ch (Tobias Weingartner)
- Subject: split !!
- Message-ID: <1992Aug30.172231.11281@neptune.inf.ethz.ch>
- Followup-To: weingart@inf.ethz.ch
- Keywords: split, GRRR
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: tau.inf.ethz.ch
- Reply-To: weingart@inf.ethz.ch
- Organization: ETH - Switzerland
- Date: Sun, 30 Aug 1992 17:22:31 GMT
- Lines: 45
-
-
- Hello, I have run into a little trouble here.
- I have a database, made up like the following:
-
- field:field:etc:etc:etc
-
- Well, the split operation (a la split(/:/, $foobar)) works
- quite nicely on this. The trouble comes from the users here.
-
- What if the use types in a : for part of his neato reply?
- You guessed it! Ka-Boom.
-
- I thought that I could do something like this:
-
- print "Enter response: ";
- chop(@line[0] = <STDIN>);
- @line[0] =~ s/:/\\:/;
-
- ...
-
- $data = join(':', @line);
- print FILE $data.'\n';
-
- ...
-
- Then to read it in:
-
- chop($data = <FILE>);
- @line = split(/[^\\]:/, $data);
-
-
- This splits the lines appropriately, but there is a
- character chopped off.
-
- What I am looking for, is something like in lex:
-
- [^\\]/: {split();}
-
- Where the split will only be done if the perceading
- character is not a \.
-
- Any ideas?
-
- --Toby.
-
-