in reply to Perl match

use warnings; use strict; my $str = 'ac-t-c-t-g'; my $s2; my $i = 0; for (split //, $str) { $s2 .= $_; $i++ if $_ ne '-'; last if $i == 4; } print "$s2\n";