open FILE, "<", $MyPDF; binmode FILE; #### binmode STDOUT; # read the whole file my $file = do { local $/ = undef; }; my $length = length $file # additional header print "Content-Length: $length\r\n"; print "\r\n"; # http header end print $file;