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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://674137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-20 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found