What you want to do is to select on STDIN every so often. Say, every time a certain loop starts over or every section or whatever. The code you're looking for is:
That should work. It's best if you write a subroutine and return either undef (if nothing) or what was read. You can even chomp in the subroutine, as well.# Whenever you want to actually see if there's something waiting my $rin = ''; my $input = ''; vec($rin, fileno(STDIN), 1) = 1; $input = <STDIN> if select($rin, undef, undef, 0.1);
Oh - you'll have to hit RETURN so that the filesystem can pass in the values. There's no native keypressed-type thing. (You can get it with Term::ReadLine and the like, but that's more complex than I think you want.)
And, this will not work under Win32 without significant changes, due to how select is implemented there. Unless you're planning on migrating, don't worry about it. :)
------
/me wants to be the brightest bulb in the chandelier!
In reply to Re: keyboard input during runtime...
by dragonchild
in thread keyboard input during runtime...
by Shadowfax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |