CGI Animation

Animation

#!/usr/bin/perl

$times = "1";
$basefile = "/images/";
@files = ("begin.gif","second.gif","third.gif","last.gif");
$con_type = "gif";

# Unbuffer the output so it streams through faster and better

select (STDOUT);
$| = 1;

# Print out a HTTP/1.0 compatible header. Comment this line out if you 
# change the name to not have an nph in front of it.

print "HTTP/1.0 200 Okay\n";

# Start the multipart content

print "Content-Type: multipart/x-mixed-replace;boundary=myboundary\n\n";
print "--myboundary\n";

# For each file print the image out, and then loop back and print the next 
# image.  Do this for all images as many times as $times is defined as.

for ($num=1;$num<=$times;$num++) {
   foreach $file (@files) {
      print "Content-Type: image/$con_type\n\n";
      open(PIC,"$basefile$file");
      print <PIC>;
      close(PIC);
      print "\n--myboundary\n";
   }
}