my $str3 = 'ATGATG'; my $str4 = 'ATGATG'; my $catted = "$str3 $str4"; $catted =~ s/(.*)(.+) (?=\2)/$1/; print "$catted\n";