Greetings all,
Well here is my home-brew solution so to speak.
#!/usr/bin/perl -w
use strict;
use Dumpvalue;
my $dumper = new Dumpvalue;
my @split_elms = map{chomp;
my $line = $_;
my @data = map{my $substr = $_;
$substr =~ s/,/:innerc:/g;
$line =~ s/\Q$_\E/$substr/;} $line =~ /("[^"]*")/g;
@data = map{$_ =~ s/:innerc:/,/g;
$_} split(/,/,$line);
\@data;} <DATA>;
$dumper->dumpValue(\@split_elms);
exit;
__DATA__
"one"," one,two",3,"a like <A HREF="foo"> b</A>"
0,0,0,0
it outputs
0 ARRAY(0x81a89dc)
0 '"one"'
1 '" one,two"'
2 3
3 '"a like <A HREF="foo"> b</A>"'
1 ARRAY(0x8151afc)
0 0
1 0
2 0
3 0
That was fun... I hope that helps a bit. Of course it still fails to catch things like a single " (like for inches) but you get the general idea. Nothing novel.
-Injunjoel
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.