Hi all,
I have one that might not be possible...
What I'm doing is running a program with Open2, but need to send instructions to it when there is a single key-press. For that I'm using HotKey.pm from the Perl Cookbook.
The problem I run into is I need to wait on While which causes my other process to hang untill it gets that key. I want it to just run it and take the key-presses as they come so to speak. Here's a simplified version of what I mean:
Use HotKey.pm;
foreach $i (@things) {
&program_running($i);
while ($keyboard = readkey) { # This is the gotcha
if ($keyboard =~ /b/) {
print "you pressed b \n";
}
}
}
Is there any way to check for a key-press that does not wait? Sort of check it on the fly, or periodicly?
TIA,
Miker
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|