Perl : how to interrupt/resume loop by user hitting a key?
Posted
by Michael Mao
on Stack Overflow
See other posts from Stack Overflow
or by Michael Mao
Published on 2010-05-24T06:06:17Z
Indexed on
2010/05/24
6:11 UTC
Read the original article
Hit count: 281
Hi all:
This is for debugging purpose. I've got a for loop that generates some output to Cygwin bash's CLI.
I know that I can redirect outputs to text files and use Perl or even just a normal text editor to inspect the values printed out for a particular iteration, just feel that a bit painful.
What I am now thinking is, to place a special subroutine inside the for loop, so that it would be "interrupted" at the beginning of each iteration, and Perl script should only resume to run after user/programmer hits a key(the Enter Key from keyboard?)
In this way I can directly inspect the values printed out during each iteration.
Is there a simple way to do this, without using additional libraries/CPAN ?
Many thanks to the hints/suggestions in advance.
© Stack Overflow or respective owner