in reply to Perl suddenly pauses for key input

Without seeing your code, we can only guess.

You can for example have opened a filehandle to the name -:

perl -we "open F,'-';while (<F>){}"

or you can have opened a filehandle to the console (Windows version):

perl -we "open F,'CON:';while (<F>){}"

Or your program might have used a weid combination of fork() and exec() and one of the children crashed.

Without showing us any of your (reduced) code, all you can do is investigate yourself.

Replies are listed 'Best First'.
Re^2: Perl suddenly pauses for key input
by KHLeow (Novice) on Apr 17, 2009 at 11:46 UTC
    The program is around 10,000 lines and I don't know exactly which part of it is the culprit. Sometimes the problem happens twice a day. In other times, just once a week.

    I thought it might be a stability issue when calling certain perl built-in functions. I'm running on Windows XP with ActivePerl 5.8.8 installed.
      The program is around 10,000 lines and I don't know exactly which part of it is the culprit.
      Perhaps a few debug statements with time stamps in a log file would help
      sub logger{ $time=localtime(); print LOGFILE "$time : @_\n"; } sub parseElement{ logger("I am in UR parseElement starting"); ...
      that way you should be able to isolate where the issue arises

      Is it possible that XP is hibernating or going into standby?

      Are other applications affected at the same time?

      Perhaps you could add a sig handler to your code. Something like the sig handler here:
      #! use Carp; use strict; use warnings; $SIG{INT}=\&CtrlC; sub CtrlC { $SIG{INT}=\&CtrlC; Carp::carp('Caught a CTRL/C'); }; sub mySub { for (1..10) { <STDIN>; }; }; for (1..10) { <STDIN>; }; mySub(); exit;
      When it hangs again, just give it a ctrl/c and see where it carps from.
        vroom: That was quite helpful. However, in Perl 5.8.8 in Windows environment, any attempt to override SIGINT or SIGBREAK will be ignored. Furthermore, my program communicates with another interface, which is old, and must be installed on Perl 5.8.8 to work. I can't upgrade my Perl version to 5.10.0.

        Anyway, the whole program is actually running within a huge Event-1.10 loop. I've setup a test environment with Perl 5.10.0 installed to experiment with your suggestion, and was letdown when Carp merely reports that CTRL/C was caught at this line:
        Event::loop;