You might want to study Unrolling the loop technique
which is an interesting post about the Friedl's technique...
I really believe that Regex is a Perl killer-feature.
(If you agree you definitly, need to read Mastering Regular expression
and the upcoming Japhy's book)