note
diotalevi
<p>Er... what overhead? You mean of making an array access because that's all it is. @+ and @- don't invoke the $`, $& and $' penalties. Those arrays are <em>just</em> offsets into the string. <code>$-[0]</code> is the offset of the beginning of the string and <code>$+[0]</code> is the offset of the end of the string. Using those doesn't prompt perl to do all the copying that capturing, $`, $&, and $' do. Its just not the same thing.</p><p>Granted, I did miss that scalar /g loops only once and in this usage that'd be the only loop ever used. I find myself avoiding pos() after learning that it doesn't survive a local() on the variable in question. That's just style though.</p>
287394
287556