($part1, $part2) = split(/_/, $str); ($part1, $part2) = split(/_/, $str1); # or possibly better depending on context: @parts = split(/_/, $str);