Re: help on how to split a string

2001-12-29 Thread Michael R. Wolf
"Peter Cornelius" <[EMAIL PROTECTED]> writes: > @val = m/".*?",?/g; # m//g in list context returns all matches > # list gets all matches of things that begin with a double quote > # followed by any character zero or more times matching the > # minimal amount before

RE: help on how to split a string

2001-12-29 Thread Peter Cornelius
To get the output you want from the input you listed, you probably don't want to use split(). Take a look at the m// construct. use strict; #Always use strict and warnings use warnings; my @val; #declare myself an array. while () { # DATA is a special file handle that reads from t

Re: help on how to split a string

2001-12-29 Thread John W. Krahn
"Jonathan e. paton" wrote: > > Jean-Louis wrote: > > > > Now, how can I explode the line. I'd like: > > $val[0]="a", $val[1]="bcd, efg, h", $val[2]="c" (or > > equivalent). > > C4 or TNT? Or if you are a DIY kind of guy just mix together some potassium nitrate, sulfer, and charcoal. :-) John

Re: help on how to split a string

2001-12-29 Thread Jonathan E. Paton
> > I cannot figure out how to use split when the delimiter > > is the double quote. > > @var = split /\"/, $line; I am of course wrong, you need something more akin to: @var = split /\".*?\"/, $line; but as Michael says this isn't the best way to solve the problem... unless you are looking fo

Re: help on how to split a string

2001-12-29 Thread Michael R. Wolf
To: "Jean-Louis" <[EMAIL PROTECTED]> Subject: Re: help on how to split a string References: <003701c1909a$e125aab0$74d2fea9@JEANLOUIS> --text follows this line-- "Jean-Louis" <[EMAIL PROTECTED]> writes: > I found that $l=readline($filehandle) gives me t

Re: help on how to split a string

2001-12-29 Thread Jonathan E. Paton
> I'm just starting Perl, since... a few hours ago... You'll be interested in: www.perl.com www.perl.org www.perldoc.com > > I have a text files to analyze. Each line looks like : > "a", "bcd, efg, h", "c" > > I found that $l=readline($filehandle) gives me the > content of the current line.