Solved

How to add pause in Perl?

Posted on 2006-07-11
7
10,493 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

763 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