in reply to displaying excel/pdf files in browser

I struggled with the same problem not too long ago. It finally dawned upon me to just do a header redirect and let the browser handle the mime type. No need to read the file into a buffer.
$url = "http://mypdf.pdf"; print "Location: $url\n\n"; exit;

Chris Saylor

Replies are listed 'Best First'.
Re^2: displaying excel/pdf files in browser
by Heffstar (Acolyte) on Jul 10, 2008 at 16:46 UTC
    Being the very novice perl programmer that I am, I've been looking for this solution for a couple months now, off and on. Would anyone have an idea why the following procedure would be used (buffering the file, then printing it to the page) instead of the above?
    open (FILE, "$path"); while (<FILE>) { print $_; }
    Hugh