Hi there,
I've got a question concerning interruption of user input
with CTRL-C. What I'm trying to do is this:
# Main part
while (1)
{
&get_input
}
sub get_input
{
# Give prompt
$reply = <STDIN>;
if ( .."CTRL-C pressed".. ) { return 0; }
else
{
# continue...
}
}
But if I use $SIG{'INT'} I can only assign a subroutine as
handler, not a command like 'return' or 'last'. Now the
only way it works is if the user presses CTRL-C, finishes
his/her input and presses
enter. What I would
like to see is that the input is interrupted and the
get_input subroutine 'aborts' or returns.
Is there a way to do this with normal <STDIN> input
without having to use Term::ReadLine or some equivalent
(which I'm not familiar with)?