On Sun Jun 05 16:04:53 2011, sprout wrote: > On Sun Oct 03 14:08:37 2010, sprout wrote: > > $ perl -le' for( "$y" ){print \$_.\$_}' > > SCALAR(0x8039f0)SCALAR(0x8038d0) > > > > (The same address should be printed twice.) > > > > It looks as though the TARG ought to be stolen by S_refto, and then > > replaced via pad_swipe or something similar. > > It might be cleaner for not only S_refto, but also any op that aliases a > PADTMP to copy it. That would include for, map, grep, arguments to > subroutines, and the lhs of (...)x... Here is a difficult case: $ ./perl -Ilib -e 'use Devel::Peek; "$_" =~ /(?{ Dump $_ })/;' SV = PVMG(0x824b78) at 0x826ba0 REFCNT = 1 FLAGS = (PADTMP,SMG,POK,pPOK) ... Fixing the operators I mentioned above is easy. Fixing patterns without a speed hit (since regexps are used so often) is not so easy. Are regular expressions with code blocks in them flagged somehow, so we can avoid making a copy for every PADTMP =~ // ? In case it’s not obvious, this is the bug I’m trying to fix: $ ./perl -Ilib -le '"$_" =~ /(?{ print \$_; print \$_ })/;' SCALAR(0x803a10) SCALAR(0x803b50) Taking a reference to $_ twice should not create references to two different variables. The implementation details are leaking through. -- Father ChrysostomosThread Previous | Thread Next