in reply to Re^2: Runs and Sequences
in thread Runs and Sequences

I read a stat that said there was some kind of record for an individual sitting there and fliiping a coin over and over, apparently the longest recorded run was 16 heads. I was curious how long (and how many tries) it took this individual.
Then, if you're also generating the sequence with Perl, which is not clear from your first post, and if you used rand to obtain random values, which is probable in case your did, then be warned that they won't be truly random. Which is the reason why modules like Math::TrulyRandom exist.

It's not entirely clear to me what it is that you want to get, but as a general rule I suspect you may need a pattern matching like this:

/((.)\2*)/; # slightly more general than your requirements, but shoul +dn't do harm.
Or some variation of it that best fits your needs.

HTH