Re: print on the same line

2009-01-06 Thread John W. Krahn
h3xx wrote: I find it's easier (and in this case totally doable) if you make something like this: for my $count (10 .. 0) { You can't do that in Perl. The range operator has to have the smaller number on the left and the larger number on the right otherwise it will return an empty list and

Re: print on the same line

2009-01-06 Thread Mr. Shawn H. Corey
On Tue, 2009-01-06 at 06:23 -0800, h3xx wrote: > I find it's easier (and in this case totally doable) if you make > something like this: > > for my $count (10 .. 0) { > printf STDERR "%2d seconds remaining...\n", $count; > sleep 1; > print STDERR "\e[A"; > } > > ^ "\e[A" is the VT-100 code

Re: print on the same line

2009-01-06 Thread h3xx
I find it's easier (and in this case totally doable) if you make something like this: for my $count (10 .. 0) { printf STDERR "%2d seconds remaining...\n", $count; sleep 1; print STDERR "\e[A"; } ^ "\e[A" is the VT-100 code to move the cursor up one line. ^ Also, expanding the number of se

Re: print on the same line

2009-01-04 Thread Chas. Owens
On Sun, Jan 4, 2009 at 23:11, Eric Krause wrote: snip > Thank you for the reply, but I tried \b and that was one of the escape > characters activeState perl has trouble with. snip What version of ActivePerl are you using? I just tested this code against build 1004 (Perl 5.10) on WinXP SP3 and it

Re: print on the same line

2009-01-04 Thread Chas. Owens
On Sun, Jan 4, 2009 at 22:36, Mr. Shawn H. Corey wrote: snip > my $Backup_Count = 0; > > sub back_and_print { > my $text = shift @_; # no tabs, no newlines! > > print "\b" x $Backup_Count; > print " " x $Backup_Count; > print "\b" x $Backup_Count; > $Backup_Count = length $text; > print $te

Re: print on the same line

2009-01-04 Thread Eric Krause
Mr. Shawn H. Corey wrote: On Sun, 2009-01-04 at 19:33 -0700, bft wrote: Hello all, I am on a windows box and I am trying to have a count down timer print out the seconds remaining without new lining it. i.e. I do not want a screen that looks like this... 19 seconds remaining 18 seconds r

Re: print on the same line

2009-01-04 Thread Mr. Shawn H. Corey
On Sun, 2009-01-04 at 19:33 -0700, bft wrote: > Hello all, > I am on a windows box and I am trying to have a count down timer print > out the seconds remaining without new lining it. i.e. I do not want a > screen that looks like this... > > > 19 seconds remaining > 18 seconds remaining > 17 ...