ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
Every.pm on CPAN
by Ted Zlatanov other posts by this author
Jul 18 2008 7:05AM messages near this date
Re: [perl #57080] Problem in Exporter | Re: Every.pm on CPAN
I put a module Every.pm on CPAN, which lets you do

print "hi" if every(5);

which will print "hi" once every 5 times it's called.  There's a form
for seconds elapsed as well, which will run if N seconds have elapsed.

(it came to be with help from c.l.p.misc regulars, it's not just mine)

I wonder if:

1) there's any chance of including it in the core in some form; I think
it's really useful and the common (if $i % 5 == 0) format has lots of
shortcomings;

2) there's a way to know not just the line, but also the character
position of a function call, so we can do

if (every(5) || every(6)) {}

without resorting to shenanigans like using \5 and \6 or passing a
special identifier in addition to the number.

Thanks
Ted
Thread:
Ted Zlatanov
Abigail
Ted Zlatanov
Ben Morrow
Roland Giersig
David Nicol
Ted Zlatanov
Ted Zlatanov
David Nicol
Ben Morrow
Ted Zlatanov
Chromatic
Aristotle Pagaltzis
Nicholas Clark
Yitzchak Scott-Thoennes
David Nicol
Ted Zlatanov
Abigail
Ted Zlatanov
Abigail
David Nicol
Ted Zlatanov
Aristotle Pagaltzis
Ted Zlatanov
David Cantrell
David Nicol
Eric Wilhelm
David Nicol
Ben Morrow
Aristotle Pagaltzis
Paul Johnson
David Nicol
Eric Brine
Gisle Aas
David Nicol
Nicholas Clark

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved