Thanks for taking the time to study my code and provide feedback.

"your original solution handles lines like this properly:

    Bangladesh,"Claire, Laura, Phillip, Pascale",70016,"5,6,7,8"

whereas s/$re,/$+{field}\037/g will never dequote the last field."

I made reference to the fact that we're dealing with "very specific input" in "Re^4: Suggestions to make this code more Perlish". I also alluded to the fact that different code would be required if the input changed.

You're correct in saying that it "will never dequote the last field"; however, the last field (in this "very specific input") is an unquoted integer, so no dequoting is required.

"One other minor observation: \037 is an atom, ..."

Yes, that's how I used \037 (along with \036 and \012) in:

$ perl -pe 'y/\036\037/\012|/' pm_1080161_output.tff
"... so no brackets are needed in s/[\037]+$//;"

The use of brackets here was a conscious decision to make it more obvious what the '+' quantifier referred to.

You're correct in saying that 's/\037+$//' would have worked as well as 's/[\037]+$//'.

-- Ken


In reply to Re^3: Suggestions to make this code more Perlish by kcott
in thread Suggestions to make this code more Perlish by ricardo_sdl

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.