</code> oh, and by the way, if you're running your code on windows, note that kill won't work as you think. specifically, kill will *always* abort the program, and force the exit code to the number you send. it will not send a signal to the program, like it does on unix.#!/usr/local/bin/perl -w use strict; $|++; { # global count, closure my $count=0; # initialize count sub inc_count { ++$count } # increment count sub get_count { $count } # get count } $SIG{INT} = \&_SIGINT_; # set signal handler (CTRL-C) sub _SIGINT_ { # handle CTRL-C inc_count(); # increment global count $SIG{INT} = \&_SIGINT_; # reset signal handler (CTRL-C) }; while(1) { # infinite loop my $count = get_count(); # get the count of CTRL-C's $count % 2 # branch (just to do something) ? printf "\b\b\b\b\b\b\b\byes %2d",$count : printf "\b\b\b\b\b\b\b\b no %2d",$count; sleep 1; # take a cat nap $count >= 10 and last; # break loop (not so infinite) } print "\ndone!\n"; # et voila!
~Particle
In reply to Re: (crazyinsomniac) Re: Re: keyboard input during runtime...
by particle
in thread keyboard input during runtime...
by Shadowfax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |