my $line_length = 60; my @strings = ($genome1, $mismatches, $genome2); # Determine the longest string of the group my $length = (reverse sort { $a <=> $b } map { length } @strings)[0]; # Then iterate through for (my $x = 0; $x < $length; $x += $line_length) { print substr ($strings[$_], $x, $line_length),$/ for (0..2); }