$ perl -Mstrict -Mwarnings -E ' > my $text = > q{2013020400000000006810083610022013068100200220130688000200494}; > my @offs = ( 17, 6, 31, 3, 3 ); > my @cums = ( 0 ); > push @cums, $_ + $cums[ -1 ] for @offs; > substr $text, $_, 0, q{-} for reverse @cums[ 1 .. $#cums ]; > say $text;' 20130204000000000-068100-8361002201306810020022013068800-020-049-4