in reply to Keyboard Input Interrupt
I've only used this code on win2k, so I can't say that it will work on *nix boxes. You'll have to try that for yourself.#!/usr/bin/perl -w use strict; use vars qw($ret $reply); # Signal handler $SIG{INT} = 'intSub'; while (1) { $ret=get_input(); print "\nget_input returned: $ret\n"; } sub get_input { # Give prompt print "Enter value: "; $reply=<STDIN>; return 0 unless $reply; chomp($reply); print "You typed: $reply\n"; return 1; } sub intSub { # Reset signal handler $SIG{INT} = 'intSub'; };
|
|---|