$_ = ":aa2bb4cc6dd8"; my @result; if (/ : /gx) { $result[0] .= $&; while (/ \G (\w\w) (\d) /gx) { $result[0] .= $&; push @{$result[1]}, $1; push @{$result[2]}, $2; } } dd $result[0]; #-> ":aa2bb4cc6dd8" dd $result[1]; #-> ["aa", "bb", "cc", "dd"] dd $result[2]; #-> [2, 4, 6, 8]