GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  EVERY (3)

.ds Aq ’

NAME

Every - return true every N cycles or S seconds

CONTENTS

SYNOPSIS



 for (0..200)
 {
  print_stats() if every(20);           # every 20 cycles
  print_times() if every(seconds => 5); # every 5 or more seconds
  sleep 3;
 }



FUNCTION-ORIENTED INTERFACE

every( CW$number [, CW@id] )

every( seconds => CW$number [, CW@id] )

Returns true every $number times it’s called, or every time $number seconds have elapsed since the last time it was called.

The every() function keeps track of where it was called by line, even if you call it twice on the same line, e.g.



 print "hello" if every(5) or every(6);



The every() function will use the Devel::Callsite module to find the opcode and interpreter context (both unique numbers).

The optional @id is a list of arguments that compose a unique identifier. In other words, every(100, x) will run its 100 cycles independently of every(100, x, y).

DESCRIPTION

Returns true when the conditions (cycles or seconds elapsed) are met. The first cycle doesn’t count (so e.g. every(100) will be true at 100, 200, etc.)

Thanks to Dr.Ruud on comp.lang.perl.misc for helping with this idea, and to Jerry Hedden for cleaning it up. Thanks to Ben Morrow for getting Devel::Callsite started, which module is essential to Every.

Thanks to Jerrad Pierce and ikegami for the bug reports and help.

BUGS

None known.

COPYRIGHT

Copyright 2008, Ted Zlatanov (XXXXXX XXXXXXXX). All Rights Reserved. This module can be redistributed under the same terms as Perl itself.

AUTHOR

Ted Zlatanov <tzz@lifelogs.com>

SEE ALSO

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 EVERY (3) 2010-04-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.