I am writing a program to run in a DOS command shell (please don't tell me to switch to linux :) - I want to add functionality to display a progress report when the user presses [SPACEBAR], and increase verbosity when user presses [V], decrease it when they press [SHIFT] + [V]. This functions similarly to nmap if you're familiar.

I can't get the process to run silently until a keypress, it either waits for a keypress each loop, or it just ignores them until the end.

I've tried Term::Readkey with no luck.
In previous programs I've caught SIG{INT}, but apparently that only registers with [CTRL]+[C].

For clarity, the basic structure would be this:

While (1) { # Do work here... $keyPressed = CatchTheInput(); # This is where I'm stuck if( $keyPressed =~ /[Vv]/ ){ $verbosity++; } if( $keyPressed == spacebar ){ GiveProgressReport(); } }

In reply to Capture keypress while process running by jcsoybomb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.