#!/usr/bin/env perl use warnings; use 5.012; use Time::HiRes qw(sleep); use Curses; initscr(); noecho(); cbreak(); nodelay( 1 ); sub done { endwin(); say "@_"; exit; } sub my_print { my @data = `ps aux 2>&1`; for my $i ( 0 .. $LINES - 1 ) { addstr( $i, 0, $data[$i] || ' ' x $COLS ); sleep 0.1; refresh(); } } my $timeout = 2; my_print(); while ( 1 ) { my ( $in, $out ) = ( '', '' ); vec( $in, fileno( STDIN ), 1 ) = 1; my $retval = select( $out = $in, undef, undef, $timeout ); if ( $retval == -1 ) { die "select-error"; } elsif ( $retval ) { while ( ( my $key = getch() ) ne ERR ) { done( "See ya" ) if $key eq 'q'; } } else { my_print(); } }