sub return_string{ my @temp = (12,23,34,4,5); my $seq; foreach my $key(@temp){ $seq = $seq.$key.','; } return substr($seq, 0, -1); }