in reply to Heredoc in one-liner?

The quotes around 'TEST' are matching the quotes around the one liner. The shell is passing

package test;$text <<TEST;test@heredoc;\r\nTEST;print "$text\n"
to perl. The contents of the heredoc are then being interpolated. There are also some funky dealing with the multi-line stuff you will need to work through.

(Update) Perhaps:

perl -e 'package test;$text=q(test@heredoc);print "$text\n"'

--MidLifeXis