title: How can I send multiple images in a server push Perl CGI program?
body: <p>I am a beginner in Perl CGI etc. I was experimenting with server-push concept with a piece of Perl code. It is supposed to send a jpeg image to the client every three seconds.</p>
  
  <p>Unfortunately nothing seems to work. Can somebody help identify the problem?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>use strict;
  # turn off io buffering
  $|=1;
  print "Content-type: multipart/x-mixed-replace;";
  print "boundary=magicalboundarystring\n\n";
  print "--magicalboundarystring\n";
  
  #list the jpg images
  my(@file_list) = glob "*.jpg";
  my($file) = "";
  
  foreach $file(@file_list ) 
  {
       open FILE,"&gt;", $file or die "Cannot open file $file: $!";
       print "Content-type: image/jpeg\n\n";
  
      while ( &lt;FILE&gt; )
      { 
          print "$_";
      }
  
      close FILE;
       print "\n--magicalboundarystring\n";
       sleep 3;
      next;
  
  }
  </code></pre>
  
  <p>EDIT: added turn off i/o buffering, added "use strict" and "@file_list", "$file" are made local</p>