With mode-compile, which is no not core but the default in cperl-mode.
That would have been helpful to know. That entry is disabled in my Emacs because I don't have mode-compile. Heck, that thing is pretty stale and can't be byte-compiled nor M-x eval-buffered in Emacs 27...
Anyway, mode-compile is the culprit. Contrary to its name, it runs the program, using a mechanism which does not make STDIN of the Perl process available to you.
What you could do is wrap the following lisp snippet into a command which suits you:
(compile "perl your_script.pl" t)
Replacing the program name perl and script name your_script.pl by variables is left as an exercise to the reader. The t parameter does the trick to give you what Emacs calls a "comint" environment. So, you end up in a buffer *compilation* in compilation-mode with "clickable" error messages, but the buffer is not read-only, you can just enter text after the prompt.