Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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]
[Discipulus]: a fabolous mornig shall be with you monks and nuns!
[marto]: Morning, looks like our client office will be closed due to bad weather

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-01-17 07:49 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (196 votes). Check out past polls.