http://qs321.pair.com?node_id=674137


in reply to bidirectional challange

I couldn't figure a way to channel STDIN->TNOUT, but you could use $SIG{INT} as something to "listen for" along with the alarm, so the user can interrupt and input a line. That means you need a new way to conviently kill the whole thing (input DONE). Since TNIN is triggered initially by im2 starting the timer:
$SIG{ALRM}=sub{rearm()};
insert this line after that:
$SIG{INT}=sub{process()};
and for the sub:
sub process { print color("black on_white"), ">"; print color("reset"); my $input=<>; if ($input eq "DONE\n") {exit 0} else {print TNOUT "$input"} }
now, when you press ctrl-c, instead of death you get a little ">" prompt so you can talk.

I just tried it and it werx dandy. ROLL ON