Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
So there I am, writing my regex book. I document split() rather extensively, and then someone tells me I got it wrong. How disappointing.

So there I am, at TPC, listening to Damian Conway talk about "Data Munging" in his tutorial on Monday. He starts talking about split(), and I correct him. It turns out that I'm wrong (in the same way I was wrong in my book). So I've got two strikes.

One would think, at this point, I'd cash in my chips, correct the text in my book, and sink back into my cave. Nuh-uh.

Some people would fix their book to be consistent with the language. I fixed the language to be consistent with my book! Let me explain:

In Perl 5.005_02, split /(A)|B/, "1A2B3" returned a five-element list of (1, 'A', 2, undef, 3). In 5.005_03, it returned (1, 'A', 2, '', 3); a subtle, but meaningful, difference. There's only one way to get an undef from split(), and that's from the underlying regex match. A capturing paren that does not match has undef as its $DIGIT value.

A tiny bit of incorrectly written code in pp.c:pp_split() caused these undefs to become empty strings. Bah. I corrected it, documented it, and tested it.

So that's my story of being a pretentious bastard, and insisting Perl work the way I think it should (and the way it worked before, and that makes more sense, and that is now tested and documented).

Jeff japhy Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

In reply to Being pretentious, and getting away with it. by japhy

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (7)
    As of 2018-06-24 03:43 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.