Delete line in Windows CMD in Perl

I am trying to format the output inside Perl Script. So I want to rewrite the text in the console. I already got it to rewrite the line, but I cannot go back to another line. for example

print "test\ntest";
print "\rhi  ";

Will be displayed

 Test
 Hi

What I know, wants to do, goes further, so that instead of the second test, the first test can be replaced. \ b does nothing in my console, is there any other way to get back to the line on Windows CMD?

+4
source share
2 answers
print  "\e[H";              # Put the cursor on the first line
print  "\e[J";              # Clear from cursor to end of screen
print  "\e[H\e[J";          # Clear entire screen (just a combination of the above)
print  "\e[K";              # Clear to end of current line (as stated previously)
print  "\e[m";              # Turn off character attributes (eg. colors)
printf "\e[%dm", $N;        # Set color to $N (for values of 30-37, or 100-107)
printf "\e[%d;%dH", $R, $C; # Put cursor at row $R, column $C (good for "drawing")

Also see

+1
source

, , , . .

#!/usr/bin/perl -w

use strict;
my $output="Hi";
#local $| = 1;

print "test\ntest";
print ("\b" x length("test"));
for(my $i=0;$i<length("test");$i++)
{
    $output .=" ";
}
print $output;

:

D:\Study\perl>perl test1.pl
test
Hi

\b 4 , "" 4., , , 4 . "hi" 4, 2 , , "Hist";

0

Source: https://habr.com/ru/post/1605705/


All Articles