my $text = "[Part1,Part2],[Part3],[Part4, Part5],[Part6]"; my @data = $text =~ m{\[([^\]]+)\]}g; print join "\n", @data, '';