File: tctrl-c.pl

package info (click to toggle)
libpdl-perldl2-perl 2.002-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 416; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings;
use Term::ReadLine;

$| = 1;
my $cnt = 0;
sub handler {
	print "Caught a SIG '$_[0]' - continuing\n";
	die "Got three" if ++$cnt > 2;
}
$SIG{INT}  = \&handler;

my $term = Term::ReadLine->new('ProgramName');
while (1) {
	my $input = $term->readline('prompt> ');
	if (not defined $input) {
		print "EOF on input\n";
	} elsif ($input eq 'q') {
		print "quitting\n"; exit;
	} else {
		printf "Got: '%s'\n", $input;
	}
	Win32::Sleep(1000);	# stop runaway console
}

__END__