It will cost a lot of memory. Fortunately, $string is rarely large. And if it is large, the regex-iterator solution will probably be slow. You'll probably be better off with a substr solution on large strings.
---- I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated