in reply to Re: tie() weirdness
in thread tie() weirdness

But from that thread seems to refer to a (possible) bug in tied arrays, whereas I found a (possibly) anomalous behaviour with tied scalars.

However, this particular post from that thread brings me to

Both hint at the fact that tied vars may... well, evaluate twice under some circumstances. In particular the former seems to refer to a different situation, but the latter portraits exactly the same one as mine. 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:

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: here

May it be that the patch never made its way in the next releases or that the same bug has been reintroduced subsequently?

Remark: more importantly, it seems that the FETCH method is not called twice:

#!/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__
FETCH called! FETCH called! FETCH called! 112