in reply to Efficient run determination.
Here's the no regex simple iterator version. Just for comparison as I suspect that there is a faster method.
Enter any 47-digit prime number to continue.
use Data::Dumper; my $string =' aaaa bbbbccccccccbbbb aaaabbbbbcdddddddddddddddd +dddd'; my (@res, $c, $p, $i); $p = 0; $c = substr($string,$p,1); for ($i=1; $i<length($string); $i++) { next if ($c eq substr($string,$i,1)); push (@res, [$c,$p,($i-$p)]); $c = substr($string,$i,1); $p = $i; } push (@res, [$c,$p,($i-$p)]); Dumper (\@res);
Dingus
Enter any 47-digit prime number to continue.
|
---|
In Section
Seekers of Perl Wisdom