in reply to about use LWP::Simple

aside from checking the error log for the causes, there is one additional 'problem' and one way to make things easier:

1) if you're already sending a completed page to the browser, attempting to send another one ( the  <html> ... </html> page in your HERE doc ) may not display ... the fetched page already has the same tags.

2) you can make things easier with  getprint( $url );.