A few years ago, I followed a weeklong Java course. One of
the exercises was to create a simple graphical chat client.
It wasn't hard to do - but it wouldn't an exercise I would
student do during a week long Perl course (I've given many
Perl courses).
Some aspects may be easier in Java than in Perl. Other aspects
will be easier in Perl. So, the answer is, yes, you can do this in Perl, but it's not clear whether that's a better choice than Java.