Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Pause Perl Program?

Reply
Thread Tools

Pause Perl Program?

 
 
still me
Guest
Posts: n/a
 
      07-08-2007
Newbieish question: I have a program that I need to have pause for a
second (or less), then continue.

I RTFM'ed and I found the Sleep function and Win32::Sleep. It seems
like the Win32::Sleep module is a better choice as it allows
millisecond intervals where as the Sleep module only accepts full
seconds. This program will run only on Windows. I also found
Time::HiRes but that looks like overkill for what I need to do this
time.

Do I have this correct? Are there other functions that pause? Any
subtleties I need to know about?
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-08-2007
On Jul 8, 8:33 am, still me <(E-Mail Removed)> wrote:
> Newbieish question: I have a program that I need to have pause for a
> second (or less), then continue.
>
> I RTFM'ed and I found the Sleep function and Win32::Sleep. It seems
> like the Win32::Sleep module is a better choice as it allows
> millisecond intervals where as the Sleep module only accepts full
> seconds. This program will run only on Windows. I also found
> Time::HiRes but that looks like overkill for what I need to do this
> time.
>
> Do I have this correct? Are there other functions that pause? Any
> subtleties I need to know about?


$ perldoc -q sleep
Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq8.pod
How can I sleep() or alarm() for under a second?

If you want finer granularity than the 1 second that the
sleep() function provides, the easiest way is to use the
select() function as documented in "select" in perlfunc.
Try the Time::HiRes and the BSD::Itimer modules (available
from CPAN, and starting from Perl 5.8 Time::HiRes is part of
the standard distribution).

I see no reason to download a non-core non-portable module for such a
simple task.

Paul Lalli

 
Reply With Quote
 
 
 
 
still me
Guest
Posts: n/a
 
      07-08-2007
On Sun, 08 Jul 2007 05:44:41 -0700, Paul Lalli <(E-Mail Removed)>
wrote:

>I see no reason to download a non-core non-portable module for such a
>simple task.
>
>Paul Lalli


Thanks
 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      07-08-2007
On Sun, 08 Jul 2007 12:33:10 GMT, still me <(E-Mail Removed)>
wrote:

>seconds. This program will run only on Windows. I also found
>Time::HiRes but that looks like overkill for what I need to do this


Why an overkill? It's also a core module now...


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
Bart Lateur
Guest
Posts: n/a
 
      07-08-2007
still me wrote:

>I RTFM'ed and I found the Sleep function and Win32::Sleep. It seems
>like the Win32::Sleep module is a better choice as it allows
>millisecond intervals where as the Sleep module only accepts full
>seconds. This program will run only on Windows. I also found
>Time::HiRes but that looks like overkill for what I need to do this
>time.


But Time::HiRes comes with perl.

Alternatively, you can try using the 4 argument select() call to produce
a sleep-like effect. That even doesn't need a module.

--
Bart.
 
Reply With Quote
 
Lambik
Guest
Posts: n/a
 
      07-08-2007

"still me" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Do I have this correct? Are there other functions that pause? Any
> subtleties I need to know about?


Is this like a JAPH? Who can come up with the most useless sleep? How about:

use strict;
use warnings;
use Win32::API;

my $Handler = Win32::API->new( 'kernel32', 'Sleep', 'L', 'V');
$Handler->Call (10000); # Milliseconds


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dramatic pause in PIX 7.0(2) after 'q' on page break in sh conf Michael T. Anderson Cisco 3 09-29-2005 06:26 PM
Suppress more/pause during running config Marv Cisco 3 06-20-2005 05:33 PM
Pause Frames on Catalyst switches? Cisco Fan Cisco 6 12-09-2004 05:51 AM
pause a loop GrantMagic ASP .Net 1 07-28-2004 10:08 AM
how to do a PAUSE in an codebehind function? Jason Shohet ASP .Net 10 06-18-2004 06:42 PM



Advertisments