Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!ogicse!hakanson From: hakanson@ogicse.ogi.edu (Marion Hakanson) Newsgroups: comp.lang.perl Subject: Re: Quoting and Splitting Message-ID: <12396@ogicse.ogi.edu> Date: 25 Sep 90 21:28:41 GMT References: Distribution: comp Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 25 In article adler@betwixt..caltech.edu (B. Thomas Adler) writes: >. . . >spacing. My question is, is there a way to have split() split on >white-space, while respecting the restrictions imposed by any double quoting? > >ie, I'd like the line > Field_1 parm_1 "This is example one" > >to split into three components, rather than 6. This has been discussed several times before. If you allow the quotes to be escaped (with a backslash, which can also be escaped by a backslash, etc.), then you aren't going to be able to do this with a regular expression. Even if you don't, the r.e. will be ugly. Since you mentioned nameserver files, you may find the approach I took to be of use to you. Use anonymous FTP to retrieve from host cse.ogi.edu the file pub/dnsparse-2.0.tar.Z. Briefly, there is a lexical analyzer (tokenizer) written in C, which is used by Perl code to fully parse DNS master files. The lex-er deals with quotes, etc., and the Perl code does the rest. -- Marion Hakanson Domain: hakanson@cse.ogi.edu UUCP : {hp-pcd,tektronix}!ogicse!hakanson