How to add pause in Perl?

Hi.
I converted my perl script to EXE usng perl2exe. Now when I double click on my exe it runs great. I am also printing error messages in that. But as soon as the execution gets over , the window shuts down. How can I give some time of pause , so I can see the error messages while executing the script?
niravdesai23Asked:
Who is Participating?
 
LinkyConnect With a Mentor Commented:
You can do:

system("pause");

It will say, "Press Any Key to Continue . . ."

0
 
Kim RyanIT ConsultantCommented:
Use the sleep command to specify how many seconds to wait for.
sleep(5);   # do nothing for 5 seconds
0
 
Perl_DiverCommented:
You can maybe add a prompt for some user input at the end of the script (after all the output is generated and displayed) so the winodw does not close until you direct it to close. Or try using sleep() and see if it works OK.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
alexsergeyevCommented:
Effective way to make "unblocking" pauses is "alrm" function with SIGALRM handler.
more - "perldoc alrm" and "perldoc perlipc"
0
 
Adam314Commented:
Or if you start your program from a command prompt (instead of double-clicking an icon), the window won't close, and you'll be able to see the error messages.
0
 
Adam314Commented:
Or you could redirect the output to a file, which you could then view in any text editor, using this syntax:

program.exe > output.txt
0
 
tong111797Commented:
print "Press Any Key to Continue . . .";
getc(STDIN);
0
All Courses

From novice to tech pro — start learning today.