While trying to clear up a few older bugs in a module I'm planning to take over, I found one I can't seem to wrap my head around. Take this:
use Tie::Scalar;
tie (my $SLEEP_TIME, 'Tie::StdScalar', 0.25);
select (undef, undef, undef, $SLEEP_TIME);
Tie::StdScalar is part of Tie::Scalar and does virtually nothing so parsing that mentally should result in a .25s sleep and then exit. But it doesn't. The code blocks as if $SLEEP_TIME was undefined. However, this...
use Tie::Scalar;
tie (my $SLEEP_TIME, 'Tie::StdScalar', 0.25);
print $SLEEP_TIME;
select (undef, undef, undef, $SLEEP_TIME);
...works exactly as expected. The value of $SLEEP_TIME is printed and then select(...) sleeps a quarter second. According to Devel::Trace, my first example never calls the tied scalar's FETCH method but in my second example, it's correctly called twice: once for the print and again in the select statement.
I only have perl v5.16.3 installed so I'm not sure if this is a newly introduced bug or an old one. Before I bother fending off the dragons that inhabit p5p, anyone else have an idea or see this same behavior with newer/older versions of perl?
Update: Reported as RT#
120102.