note
blazar
<p>But from that thread seems to refer to a (possible) bug in [doc://tie]d <em>arrays</em>, whereas I found a (possibly) anomalous behaviour with [doc://tie]d <em>scalars</em>.</p>
<p>However, [id://210493|this particular post] from that thread brings me to</p>
<ul>
<li>[id://114940],</li>
<li>[id://92531].</li>
</ul>
<p>Both hint at the fact that tied vars may... well, <em>evaluate twice</em> under some circumstances. In particular the former seems to refer to a different situation, but the latter portraits <em>exactly the same one as mine</em>. But the same article claims that it was a 5.6.1 specific bug and that it should have been patched - here's the relevant quote:</p>
<blockquote>I searched p5p and it appears to have been reported and patched in development versions --- I just wanted to let people here know so they might avoid some confusion if they run into it. A relevant p5p link (from which the patch is linked) is: [http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-05/msg01568.html|here]</blockquote>
<p><em>May it be that the patch never made its way in the next releases or that the same bug has been reintroduced subsequently?</em></p>
<p><strong>Remark:</strong> more importantly, it seems that the <em>FETCH</em> method is <em>not</em> called twice:
<c>
#!/usr/bin/perl -l
use strict;
use warnings;
sub TIESCALAR { bless \my $i, shift }
sub FETCH { warn "FETCH called!\n"; ${shift,}++ }
tie my $s, 'main';
print "$s$s$s";
__END__
</c>
Output:
<c>
FETCH called!
FETCH called!
FETCH called!
112
</c></p>
510411
510418