#!/usr/bin/perl -w # 1999-06 # http://www.cyut.edu.tw/~ckhung/b/mi/ use Curses; initscr; cbreak; noecho; keypad(1); getmaxyx($height, $width); addstr(0, 0, "press arrow keys to move the cursor;"); addstr(1, 0, "press any other key to quit"); $x = $y = 0; while (1) { move($y, $x); $c = getch; if ($c eq KEY_LEFT) { --$x; } elsif ($c eq KEY_RIGHT) { ++$x; } elsif ($c eq KEY_UP) { --$y; } elsif ($c eq KEY_DOWN) { ++$y; } else { last; } $x += $width while $x < 0; $x -= $width while $x >= $width; $y += $height while $y < 0; $y -= $height while $y >= $height; } endwin;