Dearest Monks and Friends, Is there a way to to detect a character typed in STDIN without having pressed the RETURN key...And then take an action if that character is detected. I have a
while(<STDIN>) { }
loop and i can enter input and process the input fine as long as the RETURN key is pressed... but what i'd really like to do is listen for a particular character to be typed at STDIN and then call a subroutine without having pressed the RETURN key at all. for Example I'd like to listen for the character `%` in some text entered at STDIN , say for e.g. `Hello %` and without pressing the RETURN key, call a subroutine since `%` was detected. I'd really, really appreciate any input on this. I'm really new to perl and thus far it has been good learning this amazing language, but i still need some help around the tricky bends, i hope you monks can guide me and show me the path to enlightenment ;).Thanks a lot in advance.

In reply to Action based on Character recieved from STDIN by GNUBee

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.