in reply to finding visible length of string?

Why not bypass the problem of the length by using \r?

 print "\r\033[32m coloured! \033[m           ";

Note the extra spaces on the end to ensure that if one string is shorter than that which preceeded it, the remnents of the preceeding one get erased.


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: finding visible length of string?
by sauoq (Abbot) on Sep 19, 2002 at 00:16 UTC

    A variation on this would be to just clear the whole line between prints. Something like:

    $|++; my $clear = "\r" . ' 'x80 . "\r"; print "quux"; sleep 1; print $clear, "foo"; sleep 1; print "\n";

    -sauoq
    "My two cents aren't worth a dime.";
    
      I was using "\b" x $i , but I was deleting up to a point which changed as the script progressed, with or without colours in the string (Aaarrgh!). A horrible mess!

      Removing the whole line seems the simplest way.

      <slaps forhead!>

      Thanks, O'holy ones!