in reply to Perl CGI output in PDF

print $query->header(-expires=>'now', -type=$mimetype, -disposition=>" +inline:filename=sample.pdf", -filename=>'sample.pdf');

In addition to Joost's reply, I also notice that you have some ='s instead of =>'s, which should issue an error. I deduce that you either did not run the code or more probably retyped it. Which shows why it is a good practice not to, but to copy and paste it instead.