Fogle Cpl Shawn B wrote: > I'm writing my first perl script with the llama (the beginner o'riley > book) but the one thing I need to make a complete program that I don't see > in the book or the perl faqs (although I'd bet it's there somewhere) is a > acceptable way to cause the script to terminate. I have been having to > goto another VC and kill the perl script. It would be nice for me to be > able to press "Q" but that, to my little bit of knowledge of perl, would > require a <STDIN> that was somewhat passive. Any suggestions? (I won't be > asking many more newbie questions, as this is the only one that has seemed > to stump me for the last week two). > > tia > shawn
if you have a tight loop that is executing and eating up CPU. you probably want to set up a signal handler to catch your keystroke since the OS pay more attention to signal. for example: #!/usr/bin/perl -w use strict; #-- press control-c to get here $SIG{INT} = sub { print "what? "; my $c = <STDIN>; exit if($c =~ /^q/i); print "ignored. continue..\n"; }; #-- tight loop while(1){ print "hi\n"; } __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]