cursesを使ってみる

端末のウィンドウサイズを表示する

#!/usr/bin/env perl

use Curses;

initscr;

$win = new Curses;
$r = rand;
$win->addstr(1,1,$r);
$x = getmaxx();
$y = getmaxy();
$win->addstr(2,1,"x: $x, y: $y");
$win->refresh;
while(1){
  sleep 2;
  $r = rand;
  $win->addstr(1,1,$r);
  $x = getmaxx();
  $y = getmaxy();
  $location = "x: $x, y: $y\n";
  $win->addstr(2,1,$location);
  $win->refresh;
};

endwin;

こんな書き方でいいのか?


実行結果


参照したURL:
http://www.perlmonks.org/?node_id=732771