Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to add pause in Perl?

Posted on 2006-07-11
7
Medium Priority
?
10,700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 400 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Six Sigma Control Plans

722 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