Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: bidirectional challange

by halfcountplus (Hermit)
on Mar 14, 2008 at 03:48 UTC ( #674137=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://674137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2020-05-26 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (149 votes). Check out past polls.

    Notices?