home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!usc!news.cerf.net!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Subject: Re: PERL PARSING
- Message-ID: <1992Dec16.213713.23851@netlabs.com>
- Sender: news@netlabs.com
- Nntp-Posting-Host: scalpel.netlabs.com
- Organization: NetLabs, Inc.
- References: <1992Dec15.172048@is.morgan.com>
- Date: Wed, 16 Dec 1992 21:37:13 GMT
- Lines: 33
-
- In article <1992Dec15.172048@is.morgan.com> holger@is.morgan.com (Holger Veith) writes:
- : What is the best way to parse a string within PERL where I would like it
- : to behave sort of like ksh.
- :
- : I have used the split command by splitting on white space, but I would
- : like everything enclosed in quotes to be one string.
- :
- : ie.
- :
- : $x='please "help me split" this line';
- :
- : -> $a[1]='please'
- : $a[2]='help me split'
- : $a[3]='this'
- : $a[4]='line'
-
- $ perl
- require "shellwords.pl";
- $x='please "help me split" this line';
- @a = &shellwords($x);
- $" = "\n";
- print "@a\n";
- __END__
- please
- help me split
- this
- line
- $
-
- Larry Wall
- lwall@netlabs.com
-
-
-