my $chars = 5; my $pattern = "A$chars " x int(length($string) / $chars) . "A*"; my @strings = unpack($pattern, $string);