Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:39:21+00:00 2026-05-26T20:39:21+00:00

#!/usr/bin/env perl use warnings; use 5.014; use Term::Cap; use POSIX; my $termios = new

  • 0
#!/usr/bin/env perl
use warnings;
use 5.014;
use Term::Cap;
use POSIX;

my $termios = new POSIX::Termios;
$termios->getattr;
my $ospeed = $termios->getospeed;

my $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
$terminal->Trequire("ku");  # move cursor up
my $UP = $terminal->Tputs("ku");
my $t = 500;
while ($t > 0) {
    printf "Hour: %d    \n", $t/3600;
    printf "Minute: %d    \n", ($t/60)%60;
    printf "Second: %d    \n", $t%60;
    print $UP,$UP,$UP;
    sleep 5;
    $t -= 5;
}

When I try this (found here: How can I update values on the screen without clearing it in Perl?) I get this output:

Hour: 0    
Minute: 8    
Second: 20    
AAAHour: 0    
Minute: 8    
Second: 15    
AAAHour: 0    
Minute: 8    
Second: 10    
AAAHour: 0    
Minute: 8    
Second: 5 

Does this mean, that key-up doesn’t work with my terminal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:39:21+00:00Added an answer on May 26, 2026 at 8:39 pm

    You’ve misunderstood the ku capability. That’s the character sequence generated when the user presses the up arrow key on the terminal. To actually move the cursor up on the screen, you print the up capability. (Also, it’s best to avoid the indirect object syntax, although that had nothing to do with your problem.)

    Here’s a corrected version:

    #!/usr/bin/env perl
    use warnings;
    use 5.014;
    use Term::Cap;
    use POSIX;
    
    my $termios = POSIX::Termios->new;
    $termios->getattr;
    my $ospeed = $termios->getospeed;
    
    my $terminal = Term::Cap->Tgetent({ TERM => undef, OSPEED => $ospeed });
    $terminal->Trequire("up");  # move cursor up
    my $UP = $terminal->Tputs("up");
    
    my $t = 500;
    while ($t > 0) {
        printf "Hour: %d    \n", $t/3600;
        printf "Minute: %d    \n", ($t/60)%60;
        printf "Second: %d    \n", $t%60;
        print $UP,$UP,$UP;
        sleep 5;
        $t -= 5;
    }
    

    You may find the Termcap manual helpful. It explains what all the capabilities mean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/bin/env perl use warnings; use 5.12.0; use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new(
#!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML::Reader; my $reader = XML::LibXML::Reader->new(
!/usr/bin/env perl use warnings; use strict; my $text = 'hello ' x 30; printf
Which version would you prefer? #!/usr/bin/env perl use warnings; use strict; use 5.010; my
The Term::Size-module jumbles up the encoding. How can I fix this? #!/usr/bin/env perl use
#!/usr/bin/env perl use warnings; use strict; use 5.012; use IPC::System::Simple qw(system); system( 'xterm', '-geometry',
Why do I get the error-message? #!/usr/bin/env perl use warnings; use 5.012; use ORLite
the following code #!/usr/bin/env perl use strict; use warnings; my @foo = (0,1,2,3,4); foreach
#!/usr/bin/env perl use warnings; use 5.012; my $var = 1 << 31; say unpack(
This works: #!/usr/bin/env perl use warnings; use 5.012; use Curses; initscr(); addstr( 5, 5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.