Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: overwritting print in same line

by quester (Vicar)
on Nov 14, 2011 at 06:30 UTC ( #937871=note: print w/replies, xml ) Need Help??

in reply to overwritting print in same line

I'm not entirely sure that I understand your question, but if you just want to show that the script is running without using up screen space, consider using a "spinner" which twirls in place:
use warnings; use strict; my $spin; while (1) { print substr( "-/|\\", $spin++ % 4, 1 ), "\b"; $| = 1; select undef, undef, undef, 0.05; }
I changed your "sleep .05" to "select undef, undef, undef, 0.05" because the normal Perl sleep function works in seconds, so "sleep .05" is the same as "sleep 0". See sleep for an explanation and other alternatives. I also added "$|=1" to avoid having the output getting buffered and not displaying anything for long periods of time; see $OUTPUT_AUTOFLUSH.

Replies are listed 'Best First'.
Re^2: overwritting print in same line
by Anonymous Monk on Nov 14, 2011 at 07:22 UTC
Re^2: overwritting print in same line
by raybies (Chaplain) on Nov 14, 2011 at 13:39 UTC

    Cool spinner code. Thanks for sharing. Fun.

    Btw, The autoflush  $| = 1; can actually be put outside the while loop (above it, obviously), as it's a flag not a function in and of itself and so it doesn't require being repeatedly called for each spin segment...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://937871]
[choroba]: bare SQL seems to work differently. Failing a prepared statement doesn't abort the transaction. So it's a behaviour of the DBD driver
[choroba]: and smells like a bug
[choroba]: oh wait
[choroba]: it doesn't abort, but it blocks any other operations than aborting
[choroba]: so it kind of makes sense

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-09-19 14:08 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (222 votes). Check out past polls.