http://www.perlmonks.org?node_id=1064633

loris has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Wanting to use a heredoc in a one-liner is obviously a bit daft, but here's my problem:

I'm trying to create a hash of text blocks to autogenerate mail texts in multiple languages. For this I have something like:

my %text_blocks; $text_blocks{en}{prolog} =<<'PROLOG'; You have received this email because something happened. Please send feedback and suggestions to tldr@nohelp.org. PROLOG

This works in a script, but when I run the tests for my module I get:

# Error: syntax error at Automailer.pm line 32, near "tldr@nohelp +" # Global symbol "@nohelp" requires explicit package name at Automailer +.pm line 32.

To see whether the heredoc with an "@" behaves differently in a script and a module, I wanted to try something goofy like:

perl -e 'package test;$text <<'TEST';test@heredoc;\r\nTEST;print "$tex +t\n"'

The carriage return and newline obviously don't get interpolated, but I hope you get the idea. Is this at all possible, or is the only way to just write a minimal module?

Thanks,

loris