note
sauoq
<blockquote><em>Could it be that the one-time compilation of the regex somehow causes the closure?</em></blockquote>
<p>That's exactly what it is. Your <tt>regex()</tt> sub isn't the closure, the code in the regular expression code assertion is.</p>
<blockquote><em>Also, saying <code>local $ret = '';</code> breaks under strict:</em></blockquote>
<p>Well of course it does. :-) (I should have mentioned that though.) Use <code>our $ret = '';</code> or declare <tt>$ret</tt> with <tt>use vars qw( $ret );</tt> instead. And keep in mind that whichever way you choose to declare it, it's still a global variable.</p>
<pre>
-sauoq
"My two cents aren't worth a dime.";
</pre>
267270
267306