Re: Using alarm

2012-10-26 Thread Rob Coops
> if ( $timenow - $start >= $delay ) { > $start = $t; > dumpstats($err); > $err = {}; > } > } > ... > > I wonder if it would be possible to replace this loop with a handler > based on alarm. > If it is possible, which

Re: Using alarm

2012-10-26 Thread Unknown User
> if ( $timenow - $start >= $delay ) { > $start = $t; err, that would be: $start = $timenow; > dumpstats($err); > $err = {}; > } > } > ... > > I wonder if it would be possible to replace this loop w

Using alarm

2012-10-26 Thread Unknown User
$err = {}; } } ... I wonder if it would be possible to replace this loop with a handler based on alarm. If it is possible, which would be more efficient? Thanks -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: test contents of variable using alarm()

2010-08-25 Thread Chas. Owens
ntents of variable using alarm() > > On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL > wrote: >> Hi All, >> >> I want to use timers to check if certain variables are set and if not >> send some data back to a client... >> >> Been

RE: test contents of variable using alarm()

2010-08-24 Thread Kammen van, Marco, Springer SBM NL
Original Message- From: Chas. Owens [mailto:chas.ow...@gmail.com] Sent: Friday, August 20, 2010 4:07 PM To: Kammen van, Marco, Springer SBM NL Cc: beginners@perl.org Subject: Re: test contents of variable using alarm() On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL

Re: test contents of variable using alarm()

2010-08-20 Thread Chas. Owens
On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL wrote: > Hi All, > > I want to use timers to check if certain variables are set and if not > send some data back to a client... > > Been searching for this a while now, but all I can find on alarm are > e

test contents of variable using alarm()

2010-08-20 Thread Kammen van, Marco, Springer SBM NL
Hi All, I want to use timers to check if certain variables are set and if not send some data back to a client... Been searching for this a while now, but all I can find on alarm are examples on timing out commands So something like: sub timeout { $timeout = 5; eval

Re: one or two alarm(0)

2009-07-14 Thread Shawn H. Corey
On Tue, 2009-07-14 at 10:58 -0400, Chas. Owens wrote: > You just removed a major feature of the code. Do you want to explain > why your paranoia has lead you to remove the ability to override the > default $timedout and $error handlers? I could understand if your > paranoia lead you to check to m

Re: one or two alarm(0)

2009-07-14 Thread Chas. Owens
On Tue, Jul 14, 2009 at 07:01, Shawn H. Corey wrote: > On Mon, 2009-07-13 at 23:49 -0400, Chas. Owens wrote: >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> sub timeout { >>         my ($wait, $code, $timedout, $error) = (@_, >>                 sub { warn $@ }, sub { die $@ }); > > # I'

Re: one or two alarm(0)

2009-07-14 Thread Shawn H. Corey
ass my ( $wait, $code ) = @_; my ( $timeout, $error ) = ( sub { warn $@ }, sub { die $@ } ); > > eval { > local $SIG{ALRM} = sub { die "timeout\n" }; > alarm $wait; > $code->(); >

Re: one or two alarm(0)

2009-07-13 Thread Chas. Owens
On Mon, Jul 13, 2009 at 22:57, Jenn G. wrote: > Hello, > > From the code below: > >  eval { >    local $SIG{ALRM} = sub { die "TIMEOUT\n" }; >    alarm($seconds); >    ... code to execute with timeout here ... >    alarm(0);  # cancel alarm (if code ran fast)

one or two alarm(0)

2009-07-13 Thread Jenn G.
Hello, >From the code below: eval { local $SIG{ALRM} = sub { die "TIMEOUT\n" }; alarm($seconds); ... code to execute with timeout here ... alarm(0); # cancel alarm (if code ran fast) }; alarm(0);# cancel alarm (if eval failed) Is the second alarm(0) need

Re: Calling subroutine every second using alarm fails

2009-04-01 Thread Chas. Owens
On Wed, Apr 1, 2009 at 20:28, wrote: > Away from PC so I cannot hookup > Is alarm perls internal function? snip The alarm function is part of Core Perl. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beg

Re: Calling subroutine every second using alarm fails

2009-04-01 Thread rich . japh
Away from PC so I cannot hookup Is alarm perls internal function? -Original Message- From: "Chas. Owens" Date: Wed, 1 Apr 2009 10:18:51 To: Kelly Jones Cc: Subject: Re: Calling subroutine every second using alarm fails On Wed, Apr 1, 2009 at 08:48, Kelly Jones wrote:

Re: Calling subroutine every second using alarm fails

2009-04-01 Thread Chas. Owens
On Wed, Apr 1, 2009 at 08:48, Kelly Jones wrote: > I want a script that constantly accepts user input, but runs a > subroutine every second to do other work. My attempt: > > $|=1; $SIG{'ALRM'}= "\&alarm_sub"; &alarm_sub; > while (<>) {print &qu

Re: Calling subroutine every second using alarm fails

2009-04-01 Thread Kelly Jones
>> Original Message >> Subject: Calling subroutine every second using alarm fails >> From: Kelly Jones >> Date: Wed, April 01, 2009 5:48 am >> To: beginners@perl.org >> >> >> I want a script that constantly accepts user input, b

RE: Calling subroutine every second using alarm fails

2009-04-01 Thread Jeff Pang
> Original Message > Subject: Calling subroutine every second using alarm fails > From: Kelly Jones > Date: Wed, April 01, 2009 5:48 am > To: beginners@perl.org > > > I want a script that constantly accepts user input, but runs a > subroutine ev

Calling subroutine every second using alarm fails

2009-04-01 Thread Kelly Jones
I want a script that constantly accepts user input, but runs a subroutine every second to do other work. My attempt: $|=1; $SIG{'ALRM'}= "\&alarm_sub"; &alarm_sub; while (<>) {print "You typed: $_\n";} sub alarm_sub {print "ALARM!\n"; alarm 1;

Re: Odd problems with alarm()

2008-11-03 Thread Dr.Ruud
"Matthew Tice" schreef: > eval { > local $SIG{ALRM} = sub {die "alarm\n"}; > alarm 2; > $test = `ls @ARGV[0]`; > alarm 0; > }; > > if ($@) { > die unless $@ eq "alarm\n"; > # Timed out - error > exit 1; > } else { &g

Re: Odd problems with alarm()

2008-11-03 Thread John W. Krahn
@ARGV < 1) { print "Usage:\n"; print "$0 \n"; exit 1; } eval { local $SIG{ALRM} = sub {die "alarm\n"}; alarm 2; $test = `ls @ARGV[0]`; If you had warnings enabled then perl would have told you to use $ARGV[0] instead of @ARGV[0]. Why are you

Odd problems with alarm()

2008-11-03 Thread Matthew Tice
print "$0 \n"; exit 1; } eval { local $SIG{ALRM} = sub {die "alarm\n"}; alarm 2; $test = `ls @ARGV[0]`; alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # Timed out - error exit 1; } else { # Okay exit 0; } However, on the machine that experienced th

Re: Help on perl alarm

2008-02-08 Thread Jay Savage
l the code in $cmd, using either system() or exec(), a shell will be spawned to execute the code. We'll call that sh(1). The code executed by sh(1) contains the shell command 'perl' to which you pass the runtime flag -e and the argument 'alarm(5); exec...'. That causes the s

Re: Help on perl alarm

2008-02-07 Thread littlehelphere
On Feb 5, 9:26 pm, [EMAIL PROTECTED] (Rob Dixon) wrote: > [EMAIL PROTECTED] wrote: > > I am using perl alarm within a script and having an issue. I want to > > access a host by first trying rsh and if that fails use ssh. I can > > get the command to run with only one of th

Re: Help on perl alarm

2008-02-05 Thread Rob Dixon
[EMAIL PROTECTED] wrote: I am using perl alarm within a script and having an issue. I want to access a host by first trying rsh and if that fails use ssh. I can get the command to run with only one of the commands but when I add both it fails. I must be missing something simple Here is the

Re: Help on perl alarm

2008-02-05 Thread Jay Savage
On Feb 5, 2008 10:22 AM, <[EMAIL PROTECTED]> wrote: > I am using perl alarm within a script and having an issue. I want to > access a host by first trying rsh and if that fails use ssh. I can > get the command to run with only one of the commands but when I add > both it

Help on perl alarm

2008-02-05 Thread littlehelphere
I am using perl alarm within a script and having an issue. I want to access a host by first trying rsh and if that fails use ssh. I can get the command to run with only one of the commands but when I add both it fails. I must be missing something simple Here is the info: Part of script

Re: why this alarm can't work?

2006-06-06 Thread Tom Phoenix
On 6/6/06, Chas Owens <[EMAIL PROTECTED]> wrote: I used "unless" because flock returns 0 on success and -1 on failure (unless it doesn't work like C version). Nope; it works like Perl. :-) A true value for success, false for failure. Cheers! --Tom Phoenix Stonehenge Perl Training -- To uns

Re: why this alarm can't work?

2006-06-06 Thread Chas Owens
"busy wait": You're keeping the CPU busy during the retries (which is one more than $maxtries). Instead, use sleep() or the four-argument select() to let other processes use the CPU while you're waiting. As to the original problem, some systems may not support using alarm() to i

Re: why this alarm can't work?

2006-06-06 Thread Tom Phoenix
ne more than $maxtries). Instead, use sleep() or the four-argument select() to let other processes use the CPU while you're waiting. As to the original problem, some systems may not support using alarm() to interrupt system calls like flock(), because (I believe) of the way that flock() is emulat

Re: why this alarm can't work?

2006-06-06 Thread Chas Owens
On 6/6/06, Jeff Pang <[EMAIL PROTECTED]> wrote: Hello,lists, See these code piece please: while ($cycles--) { my $c; eval { local $SIG{ALRM} = sub { die "flock timeout" }; alarm 3; open (SOCKLOCK,SOCK_LOCK) or die

why this alarm can't work?

2006-06-06 Thread Jeff Pang
Hello,lists, See these code piece please: while ($cycles--) { my $c; eval { local $SIG{ALRM} = sub { die "flock timeout" }; alarm 3; open (SOCKLOCK,SOCK_LOCK) or die "open lock file fail: $!"; flo

Re: ALARM

2005-11-22 Thread Jay Savage
On 11/22/05, Tom Allison <[EMAIL PROTECTED]> wrote: > John Doe wrote: > > Tom Allison am Dienstag, 22. November 2005 12.24: > > > >>I figured out I can do this: > >> > >>eval { > >> local $SIG{ALRM} = sub { warn("alarm\n"

Re: ALARM

2005-11-22 Thread John Doe
Tom Allison am Dienstag, 22. November 2005 20.59: > John Doe wrote: > > Tom Allison am Dienstag, 22. November 2005 12.24: > >>I figured out I can do this: > >> > >>eval { > >>local $SIG{ALRM} = sub { warn("alarm\n") }; >

Re: ALARM

2005-11-22 Thread Tom Allison
John Doe wrote: Tom Allison am Dienstag, 22. November 2005 12.24: I figured out I can do this: eval { local $SIG{ALRM} = sub { warn("alarm\n") }; alarm 1; for(my $j = 0; $j < 1_000_000, $j++) { my $x = log(rand()*1000+1); }

Re: ALARM

2005-11-22 Thread John Doe
Tom Allison am Dienstag, 22. November 2005 12.24: > I figured out I can do this: > > eval { > local $SIG{ALRM} = sub { warn("alarm\n") }; > alarm 1; > for(my $j = 0; $j < 1_000_000, $j++) { > my $x = log(rand()*1000+1); &g

ALARM

2005-11-22 Thread Tom Allison
I figured out I can do this: eval { local $SIG{ALRM} = sub { warn("alarm\n") }; alarm 1; for(my $j = 0; $j < 1_000_000, $j++) { my $x = log(rand()*1000+1); } alarm 0; }; if ( $@ ) { carp "[EMAIL PROTECTED]"; }

Re: alarm and pcap::loop

2005-08-28 Thread Michael Gale
Hello, This is odd ... if I use Proc::Simple to run the sub routine in the background the alarm works fine. I then simple shutdown the second process using Proc::Simple's kill function. Michael Michael Gale wrote: Hello, I am having a problem with the following piece of

alarm and pcap::loop

2005-08-28 Thread Michael Gale
t occured". But with use of the alarm function, should it not be exiting after 10 seconds even if a packet has not been received ?? --snip-- &packet_cap_setup(); eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm 10; Net::Pcap::loop($pc

RE: Timing out without alarm function

2004-02-03 Thread Sam Masiello
I am currently using >> alarm to enforce the timeout, but I don't want the script to die. I >> want a way to be able to gracefully move onto a different part of the >> script or return some value. > > --As for the rest, it is mine. > > What you need to do i

Re: Timing out without alarm function

2004-02-03 Thread Daniel Staal
--As off Tuesday, February 3, 2004 10:09 AM -0700, Sam Masiello is alleged to have said: I have a script where I am sending some data over a socket, but after X seconds I want the operation to time out. I am currently using alarm to enforce the timeout, but I don't want the script to di

Timing out without alarm function

2004-02-03 Thread Sam Masiello
Hi all! I am new to the list, and have a question which I hope isn't too difficult to answer. I have a script where I am sending some data over a socket, but after X seconds I want the operation to time out. I am currently using alarm to enforce the timeout, but I don't want the scr

Re: alarm(x) question.

2003-07-14 Thread Kevin Pfeiffer
he question.. >> > >> > I'm trying to use perl to read a file and then run a program using the >> > file. I also want to use the alarm(x) function to skip to the next >> > entry in the files if it times out. Here's what Ive go so far: [...] >> D

Re: alarm(x) question.

2003-07-13 Thread denis
Keven.. This looks really good.. Is it the "eval" that keeps the alarm from kicking the script out of the loop? I can tell I'll have some reading to do in the morning.. On Sat, 12 Jul 2003, Kevin Pfeiffer wrote: > In article <[EMAIL PROTECTED]>, > [EMAI

Re: alarm(x) question.

2003-07-13 Thread denis
Maybe I'm missing something.. But when the alarm triggers, the program drops out of the loop.. I think this is normal, what I need is for the next line of the file to be read. I'm I wrong here? On 14 Jul 2003, Ramprasad A Padmanabhan wrote: > > On Sat, 2003-07-12 at 20:34,

Re: alarm(x) question.

2003-07-13 Thread Ramprasad A Padmanabhan
On Sat, 2003-07-12 at 20:34, [EMAIL PROTECTED] wrote: > This will work, but wont solve the problem of the alarm exiting the loop > before the file has been totaly proccessed. > Seems to me that it is exactly what is wanted > On Sat, 12 Jul 2003, Ramprasad wrote: > >

Re: alarm(x) question.

2003-07-12 Thread denis
This will work, but wont solve the problem of the alarm exiting the loop before the file has been totaly proccessed. On Sat, 12 Jul 2003, Ramprasad wrote: > [EMAIL PROTECTED] wrote: > > I'm kind of new to Perl, so please forgive the question.. > > > > I'm trying

Re: alarm(x) question.

2003-07-12 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: Hi, > I'm kind of new to Perl, so please forgive the question.. > > I'm trying to use perl to read a file and then run a program using the > file. I also want to use the alarm(x) function to skip to the nex

Re: alarm(x) question.

2003-07-11 Thread Ramprasad
[EMAIL PROTECTED] wrote: I'm kind of new to Perl, so please forgive the question.. I'm trying to use perl to read a file and then run a program using the file. I also want to use the alarm(x) function to skip to the next entry in the files if it times out. Here's what Ive g

alarm(x) question.

2003-07-11 Thread denis
I'm kind of new to Perl, so please forgive the question.. I'm trying to use perl to read a file and then run a program using the file. I also want to use the alarm(x) function to skip to the next entry in the files if it times out. Here's what Ive go so far: open (TESTFILE

Re: How to alarm under 1 second?

2003-02-10 Thread zentara
On Mon, 10 Feb 2003 12:41:57 +0100, [EMAIL PROTECTED] (Angerstein) wrote: >If I need an alarm signal alarm(), in less than 1 second what can I do? Interestingly enough, this just showed up on perlmonks this morning. http://www.perlmonks.org/index.pl?node_id=23402 Simultaneous alarms unde

Re: How to alarm under 1 second?

2003-02-10 Thread Jeff 'japhy' Pinyan
On Feb 10, Angerstein said: >sub selfalarm { > $waittime = @_; Above is your problem. You are assigning the NUMBER of elements in @_ to $waittime, not the first element. Use one of the following: my $waittime = shift; my ($waittime) = @_; my $waittime = $_[0]; >$ppid = getppid(); >

RE: How to alarm under 1 second?

2003-02-10 Thread NYIMI Jose (BMB)
This is a FAQ : C:\>perldoc -q alarm Found in C:\Perl\lib\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

How to alarm under 1 second?

2003-02-10 Thread Angerstein
Hello, I have aquestions. If I need an alarm signal alarm(), in less than 1 second what can I do? Would that work? sub selfalarm { $waittime = @_; if ($pid = fork){ } else { $ppid = getppid(); select (undef,undef,undef, $waittime); kill 14 => ppid; } } SIG{A

Re: how to use alarm() to properly time out a connection?

2002-12-20 Thread Jenda Krynicky
Date sent: Fri, 20 Dec 2002 13:00:59 -0500 From: Ian Zapczynski <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject:how to use alarm() to properly time out a connection? > I need to use alarm to time out a connection t

Re: how to use alarm() to properly time out a connection?

2002-12-20 Thread Kipp, James
> > eval { > $sftp = Net::SFTP->new($FTPHOST, user=>$FTPUSER, > password=>$FTPPASS); > local $SIG{ALRM} = sub { die "alarm\n" }; > alarm 60; > }; > > if ($@) { > &sendSNMP unless $@ eq &

Re: how to use alarm() to properly time out a connection?

2002-12-20 Thread Ian Zapczynski
Jose, Yes, you are correct. I did not know about placing the alarm prior to the hanging condition (gee, I guess that makes sense) or clearing the alarm afterwards. Thank you! -Ian NYIMI Jose (BMB) wrote: -Original Message- From: Ian Zapczynski [mailto:[EMAIL PROTECTED]] Sent

RE: how to use alarm() to properly time out a connection?

2002-12-20 Thread NYIMI Jose (BMB)
> -Original Message- > From: Ian Zapczynski [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 20, 2002 7:01 PM > To: [EMAIL PROTECTED] > Subject: how to use alarm() to properly time out a connection? > > > Hello all, > > I need to use alarm to time out

how to use alarm() to properly time out a connection?

2002-12-20 Thread Ian Zapczynski
Hello all, I need to use alarm to time out a connection to an SFTP server if the connection hangs (I was able to reproduce such a hang using the Secure Shell Server for Windows, so I thought it would be nice if my script assumed this was a possibility). I think I am not understanding the

RE: alarm function not working

2002-11-28 Thread Paul Johnson
G{ALRM} = sub { $time_to_die=1; }; > > alarm($timeout); > while(!$time_to_die) > > { > while (1) Are you sure you want this infinite loop here? > { foreach (@e) > { > print $_."\b"; > } > } > } -- Paul Johnson -

RE: alarm function not working

2002-11-28 Thread Juban, Nix
ok, i tried in UNIX and got no more errors but it doesnt expire after 30 seconds as expected. -Original Message-From: Timothy Johnson [mailto:[EMAIL PROTECTED]]Sent: Thursday, November 28, 2002 3:38 PMTo: 'Juban, Nix'; '[EMAIL PROTECTED]'Subject: RE:

RE: alarm function not working

2002-11-27 Thread Timothy Johnson
It looks like you tried to use the alarm function on a Win32 machine.  Like your error message says, the alarm() function is not supported on your system. -Original Message-From: Juban, Nix [mailto:[EMAIL PROTECTED]]Sent: Wednesday, November 27, 2002 8:49 PMTo: '[

alarm function not working

2002-11-27 Thread Juban, Nix
I made the script below to have this line tumbling like  cartwheel and i want it to run for 30 seconds. Im receiving the error, "The Unsupported function alarm function is unimplemented at C:\PERL\TRAINING\PERL\timedroutine.pl line 11" for the script below. Need help in knowing

RE: eval and alarm timeout for slow process (XML post)

2002-11-22 Thread NYIMI Jose (BMB)
> -Original Message- > From: jeff loetel [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 22, 2002 9:01 AM > To: Perl beginners > Subject: eval and alarm timeout for slow process (XML post) > > > Does this look correct below. I know that I should test but

eval and alarm timeout for slow process (XML post)

2002-11-21 Thread jeff loetel
connection or a server down. I am using LWP and set the timeout feature but it never really seemed to catch the situation. Any feedback is welcome. eval { local $SIG{ALRM} = sub { die "timeout\n" }; alarm (60); # 60 sec. timeout

Alarm clock program published, website up, and open source mailing lists.

2001-05-25 Thread Adam Theo
in my understanding of XML::Simple and turning me into a die-hard fan of his module (a link to which is on every page of my new website, http://www.theoretic.com). Mr Irving, Mr McCoy, Mr Cope, and Mr Bach, for all helping me on return(), 'use strict', and refrences. thank you! Without these lists,