in reply to Better way to print text appended to a file "syntax problem"?
Re: here-docs, you may also wish to review quotes in Perl.
HTH,