Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found