CGI notwithstanding, the error is in your here-doc syntax. In Perl, here-docs must be created in the following ways:
print <<NO_SPACE_BETWEEN_THE_ANGLE_BRACKETS_AND_THIS_TEXT;
...
NO_SPACE_BETWEEN_THE_ANGLE_BRACKETS_AND_THIS_TEXT
# or
print << "SPACE_ALLOWED_WHEN_THIS_TEXT_IS_QUOTED";
...
SPACE_ALLOWED_WHEN_THIS_TEXT_IS_QUOTED
This is documented in
perlop: "There must be no space between the '<<' and the identifier, unless the identifier is quoted. (If you put a space it will be treated as a null identifier, which is valid, and matches the first empty line.)"