Unfortunately, pretty much everything you wrote in that last paragraph is wrong in way or another. Perhaps you misread something then propagated that misreading throughout.

"/[^"]$/ looks for (and your code will print) all lines that do not contain a double quote before a new line."

Clearly that's not the case. See my response to the OP below, or this specific example which does "contain a double quote before a new line":

$ perl -Mstrict -Mwarnings -E '$_ = qq{"\n}; say if /[^"]$/' "
"/[^"] is a character class meaning any character but the double quote, ..."

That's the opening delimiter for the regex (/) followed by a character class ([^"]). I thought that may have been a simple typo, and perhaps I was being pedantic, but as I continue to read that sentence:

"... and $/ is the input record separator, defaulted to new line if not specified otherwise."

No, that's not what $/ is in this context. It's an assertion anchoring the end of the line ($) followed by the closing delimiter for the regex (/).

"So, basically, your code prints any input line not ending with a double quote. This is very unlikely to be what you wanted."

Given the title, "Trying to find missing closing quotes in CSV", code which "prints any input line not ending with a double quote" seems more likely than "very unlikely" in terms of what the OP wants.

-- Ken


In reply to Re^2: Trying to find missing closing quotes in CSV by kcott
in thread Trying to find missing closing quotes in CSV by spstansbury

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.