perlmeditation
japhy
So there I am, writing my regex book. I document <tt>split()</tt> rather extensively, and then someone tells me I got it wrong. How disappointing.
<p>
So there I am, at TPC, listening to Damian Conway talk about "Data Munging" in his tutorial on Monday. He starts talking about <tt>split()</tt>, 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.
<p>
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.
<p>
Some people would fix their book to be consistent with the language. I fixed the <i>language</i> to be consistent with my <i>book</i>! Let me explain:
<blockquote>
In Perl 5.005_02, <tt>split /(A)|B/, "1A2B3"</tt> returned a five-element list of <tt>(1, 'A', 2, undef, 3)</tt>. In 5.005_03, it returned <tt>(1, 'A', 2, '', 3)</tt>; a subtle, but meaningful, difference. There's only one way to get an <tt>undef</tt> from <tt>split()</tt>, and that's from the underlying regex match. A capturing paren that does not match has <tt>undef</tt> as its <tt>$DIGIT</tt> value.
<p>
A tiny bit of incorrectly written code in <tt>pp.c:pp_split()</tt> caused these <tt>undef</tt>s to become empty strings. Bah. I corrected it, documented it, and tested it.
</blockquote>
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 <i>tested and documented</i>).
<p>
<font color="#ff0000">_____________________________________________________</font><br>
Jeff <tt><font color="#0000ff"><A HREF="/index.pl?node=japhy&lastnode_id=1072">japhy</A></font></tt> Pinyan:
<a href="http://www.pobox.com/~japhy/modules/">Perl</a>,
<a href="http://www.pobox.com/~japhy/docs/book.html">regex</a>,
and <a href="http://lists.perl.org/showlist.cgi?name=perl5-porters"><i>perl</i></a>
<a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=hacker">hacker</a>.
<br>
<tt>s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;</tt>