in reply to Perl vs. PHP in streaming a file

I was going to try different things, but a file being printed by the code you provided downloaded at 280KBs!!! (That's 1MB in 3.6 seconds!) I don't want to get into trouble with my employer or my web host, so I'm not going to do further testing.

Things I was going to try:

  1. Unbuffered (sysread and syswrite instead of read and print).
  2. Autoflushed STDOUT.
  3. Using the NPH feature of CGI.
  4. Combination of 1 and 3.
  5. Combination of 2 and 3.

Actual code used:

#!/usr/bin/perl use strict; use warnings; print("Content-Type: application/x-octect-stream\n"); print("\n"); use IO::File (); my $data = IO::File->new('< file') or die("Can't open data file: $!$/"); binmode($data); my $block = ''; while ($data->read($block, 1024)) { print $block; }