On Thu, 31 Jan 2002, Dan Sugalski wrote:
> There is an issue of time--what do we do, for example, in the case:
>
> my $pi = Pi::Generate;
> if ($pi =~ /[a-z]) {
> print "There's a letter in here!\n";
> }
>
> if Pi::Generate returns a generator object that will calculate pi for
> you to however far you want, that regex will run forever or until it
> runs out of memory, whichever comes first.
> --
Just a thought...the following would be *really* cool:
my $pi = Pi::Generate;
# Check the first 200 characters only; halt w/success if NO match
print "There's a letter in here!\n" if ($pi =~ /[a-z]/h200t);
# Check the first 200 characters only; halt w/failure if NO match
print "There's a letter in here!\n" if ($pi =~ /[a-z]/h200f);
This would be useful for cases where you might be dealing with
infinite data, or when you are only going to need to use the first section
of a string.
Dave