Solved

How to split using  Perl?

Posted on 2004-08-25
1
296 Views
Last Modified: 2010-04-17
I have the following query on spliting using perl:

sample input :

1234,3,"testing , sample"$

if i use: @field = split /,/;
the outoput will be :
field[0] = 1234
field[1] = 3
field [2] = testing
however, i need the whole string "testing , sample"  to store in the field [2]

expected output:
1234 ,3 ,testing sample

Could anyone advise how to split the record to get the expected output?
0
Comment
Question by:jescho
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 11899854
use Text::ParseWords;
@field = quotewords(",", 0, $text);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question