Problem 1.7.10 in Engelking's General Topology gives the following hint how to solve prove this result:
Show that if each member of a family $\mathcal A$ of subset of a space $X$ is dense
in itself, then the union $\bigcup \mathcal A$ is dense in itself. Note that if
$A\subset X$ is dense in itself, then the closure $\overline A$ is dense in itself.
Deduce from the above that every topological space can be represented as the union of two
disjoint sets, one of which is perfect and the second one is scattered.
A set is called dense in itself if $A\subseteq A'$.
perfect set = dense in itself and closed
scattered set = contains no non-empty dense in itself subset
If you simply take $A$ to be the set of all isolated points than for $X=\{0\}\cup\{1/n; n=1,2,\dots\}$ (with the usual Euclidean topology) you would bet $A=\{1/n; n=1,2,\dots\}$ and $B=\{0\}$, which is not the desired decomposition.