First off, I agree with the other posts!

If you are looking for a pattern that has first a quotation mark, then any characters to another quotation mark, an = sign, and finally a comma.

The next pattern being the same as the first without the quotation marks

And finally, any characters, and = sign, and the newline character, then try the re-write and see if you get better results and tweek it from there.

The * and the ? next to each other are redundant especially after the wildcard . (which means any character), and the * meaning 0 or more them.

split /(\".*?\"(?=,))|(.*?(?=,))|(.*?(?=\n))/

I think you are looking something more like this. The second pattern and the first end up being redundant, so I removed the first pattern. Please not that it has been a long time since I have worked on this type of pattern matching, and I may completely missed the mark

$some_value = split (/.*\=,|.*\=\n$/, $some_scalar);


In reply to Re: Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that. by Sagacity
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.