in reply to Better way to print text appended to a file "syntax problem"?

VinsWorldCom has already mentioned that you need to escape backslashes in a double-quoted string, but you may not realise that you are using a double-quoted string in your here-doc your here-doc is being treated as a double-quoted string. Specifically,
my $qqstring = <<"HERE"; This text is subject to double-quoted interpolation. It can include e +scapes like \t, and $variables. HERE my $string = <<HERE; This text is also subject to double-quoted interpolation. HERE my $qstring = <<'HERE'; This text is treated like a single-quoted string, except that it can c +ontain embedded single quotes. \t is just a backslash followed by a +'t', and $variables is just a dollar sign followed by the string 'var +iables'. HERE