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.

In reply to tie(...) bug or select(...) bug? by SankoR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.