home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!s5!is1.is.morgan.com!is0!chetal
- From: chetal@is.morgan.com (Pradeep Chetal)
- Subject: Re: PERL PARSING
- In-Reply-To: holger@is.morgan.com's message of Tue, 15 Dec 1992 22:20:48 GMT
- Message-ID: <CHETAL.92Dec15194638@poundcake.is.morgan.com>
- Sender: news@is.morgan.com
- Nntp-Posting-Host: poundcake
- Organization: Information Services, Morgan Stanley, NYC
- References: <1992Dec15.172048@is.morgan.com>
- Date: Tue, 15 Dec 1992 10:46:38 GMT
- Lines: 39
-
- 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'
-
-
- Thank you,
-
- Holger.
-
-
- require "shellwords.pl";
- $x='Please "help me split" this line';
- @X=&shellwords($x);
- print "X[0]=$X[0],X[1]=$X[1]\n";
-
-
- /Pradeep
- --
- ----------------------------------------------------------------------------
- Pradeep Chetal UUCP: ...!uunet!is.morgan.com!chetal
- Morgan Stanley Internet: chetal@is.morgan.com
- 1633 Broadway, Phone: (212) 703-2220 (O)
- NY, NY 10019 (212) 703-2371 (FAX)
- _______________ __o
- _________________ -\<,
- ......O/ O
-