I guess it wasn't clear enough earlier, sorry. This is for a CSV file so I can nab the relevant data, convert it, and spit it out as a different, re-ordered CSV file for importing. I need to be able to convert between the two CSV data formats (accounting application and website), as the two main pieces of software are completely incompatible with each other. They can both import and export CSV, though, so I figured this would probably be the easiest, most flexible option (learning Perl aside).

A few chunks of the CSV file (not complete lines, just representative of all the circumstances that could cause problems, with some extra data) are below:

Bag10x8x24,Poly Bags 10x8x24 gussetted,1,FALSE,FALSE,,"Poly Bags 10x8x +24 gussetted metallocene bags; Assoc. Bag # 264-4-64 (500/carton, 1 c +arton min)",0.00,NC,0,0.00,0.00,NC,0,0.00,0.00,NC Bag2.5x3zip,2.5x3x.004 zip lock bag,1,FALSE,FALSE,,"2-1/2 x 3x .004" z +ip lock bags with hang hole. Assoc Bag item #274-03H",0.00,NC,0,0.00, +0.00,NC,0,0.00,0.00,PL1*0.6700000,0,0.00,0.00 H06045-fullthd,"M6 x 45 hex cap scrw, full thd",1,FALSE,FALSE,"M6 x 45 + hex cap scrw, full thd, class 8.8, zinc (C)","M6 x 45 hex cap scrw, +full thd, class 8.8, zinc, Bossard article # 1049577",0.16,NC,0,0.00, +0.00,NC,0,0.00,0.10,PL1*0.6300000,0,0.00,0.10

There can effectively be any number of quotes or commas inside a quote-delimited field (though I'm not sure what the export does if a quote mark is followed by a comma in a description field... it hasn't happened before though, and it's not really a concern as it's easily enough avoided), and there can effectively be any number of quoted fields per line. There are also many blank (no data at all) fields, ALL of which have to be tracked and accounted for.

As to the split, I noticed while reading through my Perl book that, when given parenthesis, split// returns the results of the matches (normally discarded) and the remaining data (normally retained). If nothing else, I figured it'd be handy for double-checking my regular expressions, as I could see what it dropped too.

Thanks for the reply!


In reply to Re^2: Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that. by Groxx
in thread Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that. by Groxx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.