sub merge_data { local($_)= join("-", @_); my($m_str)= $_; if (s/(.+)-\1/$1/) { my $first_result= $_; my $chop_off= length($_[0])-length($1)+1; $_= substr($m_str, $chop_off); if (s/(.+)-\1/$1/) { return substr($m_str, 0, $chop_off) . $_; } return $first_result; } return $_; }