Roy Johnson has asked for the wisdom of the Perl Monks concerning the following question:

Off on another flight of fancy (almost a meditation, but there is a question):
My thoughts went back to Re: Finding string for patterns, and it struck me that maybe there was a Quantum::Superpositions solution that was, if not fast, at least elegantly simple. Of course, the docs of Q::S don't say anything about using regexen, but that doesn't mean it won't Do The Right Thing if you ask it, does it? It's a Damian Conway module, fer cryin' out loud!

I will spare you the pain seeing my first clueless stab at it. Suffice to say, Perl thought. And it thought. It thought so long that I was a little worried it would come back with "42". And then it crashed. Apparently regexen can destroy the universe. Thank God it's only a model.

After more trial and error, I find that the thinking and crashing syndrome occurs when I try to get the eigenstates of a relatively large disjunction. I finally got sensible behavior with

#!perl -l use strict; use warnings; my $MIN_NUMBER = 4; my $MAX_NUMBER = 30; my $string = q(5973821902497150366459738219024971503664); sub match { index($string, $_[0]) >= 0 ? $_[0] : undef } use Quantum::Superpositions UNARY => ['main::match']; my $squares = any(map {$_ * $_} $MIN_NUMBER..$MAX_NUMBER); my $superhits = match($squares); print for eigenstates($superhits);
My question is: is there any way to do super-regexen and super-matching?

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re: Quantum::Superpositions regex match
by Limbic~Region (Chancellor) on Apr 06, 2005 at 20:33 UTC