A perfect finite dimensional Lie algebra with nontrivial center $\renewcommand{\g}{{\mathfrak g}}
$ We say that a Lie algebra $\g$  is perfect if $[\g,\g]=\g$.

Question. Does there exist a finite dimensional, perfect Lie algebra $\g$ over $\Bbb C$ with nontrivial center?

If the answer is "Yes", I would like to see a nice example.
 A: The $6$-dimensional Lie algebra $\mathfrak{sl}_2(\Bbb C)\ltimes_{\phi} \mathfrak{n}_3(\Bbb C)$, which appears in the classification of all complex $6$-dimensional Lie algebras here is perfect and has $1$-dimensional center. Here $\mathfrak{n}_3(\Bbb C)$ is the $3$-dimensional Heisenberg Lie algebra. It seems that this is also the example from the other answer. In fact, the other Lie algebras from the classification list in dimension $6$ are either not perfect, or have trivial center.
A: Here's a nice simple example:
Let $\frak{g}$ be a Lie algebra with Levi decomposition $\mathfrak{g} = \mathfrak{sl}_2 \oplus \frak{n}$ where $\mathfrak{n} = V \oplus V^* \oplus Z$. Here $V$ is a non-trivial irreducible $\mathfrak{sl}_2$ representation and $Z =\langle z \rangle$ is a $1$-dimensional trivial representation.
Define a bracket on $\mathfrak{sl}_2 \times \frak{n}$ by these representations and one on $\mathfrak{n} \times \frak{n}$ such that $[v, f]:= v(f)z$ and all other brackets are $0$. Note this makes $\mathfrak{n}$ a Heisenberg Lie algebra.
Then $\frak{g}$ is perfect since $[\mathfrak{sl}_2,\mathfrak{sl}_2] = \mathfrak{sl}_2$, $[\mathfrak{sl}_2,\mathfrak{n}] = V \oplus V^*$, $[\mathfrak{n},\mathfrak{n}] = Z$. Then $Z$ is the centre of $\frak{g}$.
Edit: Note this example is actually distinct from the others given here despite also being the semidirect product of $\mathfrak{sl}_2$ and a Heisenberg Lie algebra. This construction only gives Heisenberg Lie algebras $\mathfrak{n}_{2n+1}$ for $n>1$ (i.e. $V$ is non-trivial). If $V$ is trivial this produces a non-perfect Lie algebra: $[\mathfrak{g},\mathfrak{g}] = \mathfrak{sl}_2 \oplus Z$.
