"$Bill Luebkert" wrote:
> 
> Charles Lu wrote:
> >
> > If I wanted to print say 10 numbers but instead of
> > printing each number on a line, I want each successive
> > number to REPLACE the previous number so it appears
> > that the number is changing in place.
> 
> I assume you've turned off buffering with $| = 1;
> 
> > foreach(1..10){
> >   print "$_";
> 
>     printf "%2u";       # force print to 2 char width or %02u for leading zeros

Whoops, left off the arg:

      printf "%2u", $_;

you could also put some space around it so the blinking cursor 
doesn't obscure the number:

      printf " %2u ", $_;  

> >   sleep(1);    #delay so i can see the change
> >   print "\r";
> > }
> >
> > This code works only for increasing numbers, but when
> > I try to go from 2-digit to 1 digit i.e. (11,10,9)the
> > final output would be "90".  It appears that only the
> > first digit is replaced with 9.   Anyone have any
> > suggestions?  This would be useful in printing out
> > progress of your program.


-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.todbe.com/
  / ) /--<  o // //      Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to