You'll need to setup a signal handler to catch the ctrl-c.
my $num_ctrlc = 0;
$SIG{'INT'} = sub {
$num_ctrlc++;
print "Got $num_ctrlc ctrl-c\n";
exit if $num_ctrlc > 2;
};
# rest of program
The $SIG{'INT'} part creates a signal handler for 'interrupt' (control-c) with your code. In this case, a little sub that increments a global counter, prints a message, and exists if the counter is above a certain number
BTW, your while loop is only going to run once, since @a will contain ALL of STDIN on the first pass...
Perhaps you meant something more like:
while ($a = <STDIN>) {
print $a;
}
HTH
/\/\averick
OmG! They killed tilly! You *bleep*!!