in reply to Re: Trying to find missing closing quotes in CSV
in thread Trying to find missing closing quotes in CSV
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
|
|---|