kepler has asked for the wisdom of the Perl Monks concerning the following question:
from where I wish to extract several fields; as you can see they are separated by commas - but some have commas inside them; so split is outside the question... I'm trying this:ci,14938340,2,"Monday, February 21, 2011 19:58:06 UTC",34.6953,-118.53 +50,2.2,17.40, 9,"Southern California"
also tryed@data1 = ($line =~ m/ *([a-z]+) *, *(\d+) *, *(\d+) *, *\"(.*?)\" *, * +([\d\.]*) *, *([\d\.]*) *, *([\d\.]*) *, *([\d\.] *) *, *([\d\.]*) *, + *\"(.*?)\" */gi); $d = $4; $g = $7; $j = $10; $h = $8; $e = $5; $f = $6;
But I get null strings in the first case, and a full one - in $a - in the second. Can someone help me out? Kind regards, Keplermy ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j) = @data1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing a string
by CountZero (Bishop) on Feb 22, 2011 at 16:34 UTC | |
by ikegami (Patriarch) on Feb 22, 2011 at 16:47 UTC | |
by tilly (Archbishop) on Feb 22, 2011 at 17:42 UTC | |
by Anonymous Monk on Feb 22, 2011 at 18:00 UTC | |
by tilly (Archbishop) on Feb 22, 2011 at 18:46 UTC | |
by CountZero (Bishop) on Feb 23, 2011 at 07:07 UTC | |
|
Re: Parsing a string
by BrowserUk (Patriarch) on Feb 22, 2011 at 16:41 UTC | |
by kepler (Scribe) on Feb 22, 2011 at 17:26 UTC | |
by samarzone (Pilgrim) on Feb 23, 2011 at 07:17 UTC | |
by Monkomatic (Sexton) on Feb 22, 2011 at 18:27 UTC | |
|
Re: Parsing a string
by kennethk (Abbot) on Feb 22, 2011 at 16:46 UTC | |
|
Re: Parsing a string
by johna (Monk) on Feb 22, 2011 at 18:38 UTC | |
|
Re: Parsing a string
by Monkomatic (Sexton) on Feb 22, 2011 at 18:39 UTC | |
by aartist (Pilgrim) on Feb 22, 2011 at 20:27 UTC |