Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Perl (http://www.programmingforums.org/forum21.html)
-   -   system "PAUSE"; (http://www.programmingforums.org/showthread.php?t=11609)

mammothfan Oct 16th, 2006 5:50 PM

system "PAUSE";
 
hello. I have some basic experience in c/c++, but when it comesto perl I am a newb.I was wondering if experienced perl programmers object to using system "PAUSE"; at the end of their programs to eliminate having to run them from a command line. Thnx in advance

niteice Oct 16th, 2006 6:25 PM

Yes. A huge chunk (I'd say over 95%) of Perl code is run on *nix systems, where no such pause command is available. You could try using getc:
:

print "pausing...\n";
getc();

Which generates the effect you want, but since I don't do Perl all that much, I don't know offhand if there's a better way. There probably is.

mammothfan Oct 16th, 2006 6:48 PM

Is that like getchar() in C? if so, if you use that to get a char will it seice to be able to pause the program like in C? Also, what is nix*?

niteice Oct 16th, 2006 7:30 PM

Yes, it does the same thing as getchar() - waits until a character is input, and then returns it.

*nix collectively refers to Unix, Linux, Mac OS X, every OS considered Unix-like - so almost everything but Windows. ;)

mammothfan Oct 16th, 2006 8:05 PM

I see

andro Oct 16th, 2006 9:47 PM

Quote:

Originally Posted by niteice (Post 116715)
...so almost everything but Windows. ;)

I wouldn't be that generous...

Pizentios Oct 17th, 2006 9:21 AM

Quote:

Originally Posted by niteice (Post 116696)
Yes. A huge chunk (I'd say over 95%) of Perl code is run on *nix systems, where no such pause command is available. You could try using getc:
:

print "pausing...\n";
getc();

Which generates the effect you want, but since I don't do Perl all that much, I don't know offhand if there's a better way. There probably is.

i beg to differ. *nix, has such a command. It's called sleep. You maye fine more info about the sleep command, Here

DaWei Oct 17th, 2006 10:58 AM

Quote:

Originally Posted by andro
Quote:

Originally Posted by niteice
...so almost everything but Windows.

I wouldn't be that generous...

Amazing that the tip of the iceberg is viewed as the world, nesty paw? (My best French.)

niteice Oct 17th, 2006 3:41 PM

Quote:

Originally Posted by Pizentios (Post 116769)
i beg to differ. *nix, has such a command. It's called sleep. You maye fine more info about the sleep command, Here

D'oh! That works too, but he's only looking for a way to pause until user input, not for a certain amount of time.

Pizentios Oct 17th, 2006 4:00 PM

Quote:

Originally Posted by niteice (Post 116796)
D'oh! That works too, but he's only looking for a way to pause until user input, not for a certain amount of time.

From the perldoc page for sleep()

Quote:

Originally Posted by perldoc
Causes the script to sleep for EXPR seconds, or forever if no EXPR. May be interrupted if the process receives a signal such as SIGALRM

So if given no amount of seconds, the program will sit there until a interupt is sent. From the orginal posters comments, to me this gives the functionallity that he's looking for. He just wants the window the perl script runs in to not close after the script completes. This will work for what he described above.

BTW, usually the interupt on the systems is sent by hitting ctrl-c. However on SEO linux (and possabily on other linux systems, most should be setup as ctrl-c though) the interupt is tied to the delete key.


All times are GMT -5. The time now is 2:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC