in reply to Adding gaps to a sequence

Here's another approach -- still using substr(), but differently.
sub gapify { my $s = shift; return join '-', map(substr($s, 0, $_, ''), @_), # runs of the string $s; # the remainder of the string }


japhy -- Perl and Regex Hacker