Solved

How to split using  Perl?

Posted on 2004-08-25
1
274 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countX 22 81
Export Table to CSV - Access to CSV - using python 18 96
How can i compile this github project?? 2 74
I need an assist with a programming logic math question. 5 55
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now