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

Re: Controlling already printed text to console.

by flexvault (Monsignor)
on Aug 02, 2012 at 16:08 UTC ( #985066=note: print w/replies, xml ) Need Help??

in reply to Controlling already printed text to console.


If your working on a *nix system, you could use the 'tput' command. There may be something similar in Windows but someone else will have to answer that. Use 'tput' as below (untested):

my $rows = qx/tput lines/; my $curor_up = qx/tput cuu1/; for my $no ( 0..10 ) { print "$no. Hello World!\n$curor_up"; }

I use this technique to show status of a long running script, but I use 'time' to print the status every so many seconds. I did't use '$rows', but that tells you how many lines are on the screen. So you could move the cursor to the bottom -2 and display the results at the bottom of the screen. Also 'tput' is a system commands, so try to use it outside of loops for performance reasons.

Good Luck!

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re^2: Controlling already printed text to console.
by humble (Acolyte) on Aug 03, 2012 at 19:15 UTC
    Oh, thank You, flexvault.

    The script in question - works on Linux, but I prefer using PERL tools|solutions in my PERL scripting - I have had a lot of BASH scripting already inserted into my PERL code, so I would like rather to remove it w/ PERL code, than adding more OS tools.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985066]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2016-10-21 13:13 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.