Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a Perl program from closing its window when it is finished?

Tags:

windows

perl

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.

like image 343
Brian Avatar asked Apr 09 '11 20:04

Brian


2 Answers

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>
like image 164
Greg Hewgill Avatar answered Nov 02 '22 23:11

Greg Hewgill


print "Hello, world\n";
print "Press RETURN to continue ";
<STDIN>;
like image 20
shawnhcorey Avatar answered Nov 02 '22 23:11

shawnhcorey