develooper Front page | perl.perl6.language | Postings from January 2004

Re: run-once code

Thread Previous | Thread Next
From:
David Storrs
Date:
January 14, 2004 09:35
Subject:
Re: run-once code
Message ID:
20040114173512.GD11134@megazone.bigpanda.com
On Wed, Jan 14, 2004 at 11:57:05AM +0000, Richard Nuttall wrote:

> How about
> 
> $test = sub
> {
>     if ( some_expensive_lookup_function() >= $MAX_RECORDS )
> 
> 	   mark_that_we_have_reached_max_records();       
> 
>        $test = sub{};
> };
> 
> Then call &$test() as needed;


Neat.  I wouldn't have thought of that; thank you.

--Dks

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About