Solved

How to add pause in Perl?

Posted on 2006-07-11
7
10,432 Views
Last Modified: 2012-06-22
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?
0
Comment
Question by:niravdesai23
7 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 17086240
Use the sleep command to specify how many seconds to wait for.
sleep(5);   # do nothing for 5 seconds
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 17086551
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
 
LVL 2

Expert Comment

by:alexsergeyev
ID: 17088848
Effective way to make "unblocking" pauses is "alrm" function with SIGALRM handler.
more - "perldoc alrm" and "perldoc perlipc"
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 39

Expert Comment

by:Adam314
ID: 17090498
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
 
LVL 39

Expert Comment

by:Adam314
ID: 17090505
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
 
LVL 2

Accepted Solution

by:
Linky earned 100 total points
ID: 17094346
You can do:

system("pause");

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

0
 

Expert Comment

by:tong111797
ID: 28877370
print "Press Any Key to Continue . . .";
getc(STDIN);
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now