#!/usr/local/bin/perl
#
#
# anim-e.pl, by Satoshi Abumi (v91101@vgenda.kyushu-id.ac.jp).
#
# Ver 0.03
#
# This script provides a INLINE ANIMATION on a web page by using
# the server push mechanism only netscape is supporting.

# It works, but there is a little bug, and maybe more problems.
# I'm a beginner to write scripts, so please let me know any 
# problems and suggestions :-).
# Your help would be great appreciated.

# ---------------------------------------------------------------
# Please modify numerical gif file name for animation.
# Default name is "hogehoge.XXX.GIF", and XXX is a ordered number.
#
$HEADER = "Content-Type: multipart/x-mixed-replace;boundary=sometext\n" ;
$RANDOMSTRING = "\n--sometext\n" ;
$CTSTRING = "Content-type: image/gif\n\n" ;


# Set a first number of images. 
# If it is a "hogehoge.001.GIF", set like this:
$count_s = 1 ;

# Set a last number of images
# If it is a "hogehoge.010.GIF", set like this:
$count_e = 10 ;

# Set a full path and a image file name without a number and a extension.
# Images are in /home directory, and their names are "hogehoge.XXX.GIF",
# then set like following:
$f_name = "/home/hogehoge" ;

# Set a image extension:
$exet = ".GIF" ;

# Set a number of times for animation loop.
# Deafult set is "1":
$co2= 1 ;

print "HTTP/1.0 200 Okay\n" ;
print $HEADER ;
print $RANDOMSTRING ;

for ($coa = 1;$coa <  $co2; $coa++) {
for ($co = $count_s; $co < $count_e+1; $co++){

print $CTSTRING;

$co3 = "000".$co;
$co3 = substr($co3,-3) ;

# If your name structure of images is different 
# from "hogehoge.XXX.GIF", change here:
$fn = $f_name.$co3.$exet ;


open(F,$fn) || die "Cannot open $file: $!" ;

$size = -s $fn ;
seek(F,0,0) ;
read(F,$buf,$size) ;
print $buf ;
close(F);

print"\n" ;
print $RANDOMSTRING ;

}
}

