How to stop a Perl program from closing its window when it is finished?
How can I stop my Perl program from closing the window after finishing execution in windows?
I can run a Hello World Program, but it closes way too quick for me to actually read it.
print "Hello World\n";
while (1){sleep(1)}
Seems to be the only solution I could find, but I'm betting 开发者_如何学运维there is a better way to do this.
Run your script from the Windows command prompt, instead of clicking on an icon in Explorer. When you run console mode programs from clicking on an icon, Windows will open a window for the program, run it, then close the window. When you run console mode programs from a command prompt, the window won't close:
C:\test> perl hello.pl Hello World C:\test>
print "Hello, world\n";
print "Press RETURN to continue ";
<STDIN>;
Add this line to the end of your program:
system("pause");
Windows will prompt with "Press any key to continue . . ."
Check your full file location string.
I was having this problem, but it was only for a specific file, so I thought that it was something about that file. I had an ampersand in one of the parent directories, and the Padre client could not interpret the full file string. Be sure you full file location string does not have spaces or non-alpha-numeric characters.
Not fool-proof, but one pitfall to avoid.
精彩评论