G'day georgecarlin,

The select(undef, undef, undef, $float_seconds); construct was a Perl4 (and earlier) solution for sleeping for fractional seconds.

The usleep() function of Time::HiRes has been available since 1996 (earliest CPAN reference I could find: Time::HiRes v1.02) and has been part of the Perl distribution since Perl v5.8.0 (perl58delta - what is new for perl v5.8.0). It should be available for your immediate use without requiring any installation or other activity on your part. If you're using an earlier version of Perl (perl -v on the command line will tell you), I'd recommend upgrading: v5.18.1 is the current version.

Add this line near the top of your code:

use Time::HiRes qw{usleep};

The usleep() function takes an argument in microseconds, so replace instances of

select(undef, undef, undef, 0.25);

with

usleep 250000;

You can do this in your current code, the ++solution provided by smis (above) or in whatever other solution you might choose.

[Update: Oops! I wrote "microseconds" and then provided a number in milliseconds: s/250/250000/]

-- Ken


In reply to Re: abstract expect call by kcott
in thread abstract expect call by georgecarlin

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.