Right. I often added debug out using printf "\r%d\t", $loopVariable unless $loopVariable % 1000, but if STDOUT is buffered, then you have to wait for the buffer to fill before you "see" the first output, and then it increments in leaps and bounds. You can see this with:

c:\test>perl -lwe" Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 .. 1 +e6"

Which appears to display (overlaid of course):

841 1550 2232 2915 ...

Update: Once you get to 4-digit numbers, the interval is 682. With 4-digits, "\r" & "\t", that is 6 * 682 = 4092. A 4kb buffer.

Whereas if you disable the buffering

c:\test>perl -lwe"$|=1;Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 +.. 1e6"

You see the number increment from 1, quickly and continuously.

I guess the buffering doesn't consider "\r" as a line ending -- probably rightly. It is useful for monitoring the progress of long running processes. Leaving the buffering enabled means that the IO has a negligable effect upon the speed of the code, and has the beneficial side effect that I can 'pause' and 'resume' the long running process by using the left and right mouse buttons alternately. Mouse equivalent of ^S.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: control-C to "jumpstart" windows process (line) by BrowserUk
in thread control-C to "jumpstart" windows process by jimt

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.