Teodor Zlatanov > Every > Every

Download:
Every-0.06.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View Bugs
Report a bug
Module Version: 0.06   Source  

NAME ^

Every - return true every N cycles or S seconds

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( $number [, @id] )

every( seconds => $number [, @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).

DESCRIPTION ^

 Returns true when the conditions (cycles or seconds elapsed) are met.

 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.

BUGS ^

 None known.

COPYRIGHT ^

Copyright 2008, Ted Zlatanov (Теодор Златанов). All Rights Reserved. This module can be redistributed under the same terms as Perl itself.

AUTHOR ^

Ted Zlatanov <tzz@lifelogs.com>

SEE ALSO ^