#!/usr/local/bin/perl # Bare CGI program which runs an animation for a set of images with # a fixed "base" URL. This achieves true animation, but it is # very jerky. # # You execute this program as follows: in the ADDRESS field of # IE 4 you enter this URL: # # staff.washington.edu/larryg/Classes/Rwebl/zz-anim.cgi?f=xxx&d=nnn # # where "xxx" is the path name of a file and "nnn" is the delay between # animations. For example, # # staff.washington.edu/larryg/Classes/Rwebl/zz-anim.cgi?f=../../Image/ # bldg&d=0.2 # # where"../Image/bldg" is the path name of the set of files (minus # the "1.gif, 2.gif, etc) and "0.2" is the delay time. # # Note: this assumes that there exists a file named "bldg.cnt" in the # same directory which keeps track of the number of images. # $request_meth = $ENV{'REQUEST_METHOD'}; $query_string = $ENV{'QUERY_STRING'}; # get the args delimited by "&" ($imageEQ,$delayEQ) = split(/&/,$query_string); ($dmy,$image_base) = split(/=/,$imageEQ); # 1st arg after "?" ($dmy,$delay) = split(/=/,$delayEQ); # 2nd arg after "?" $image_to_read = &increment_image_number( $image_base ); open(FILE, "<" . $image_to_read); print "Refresh: $delay \n"; print "Content-type: image/gif", "\n\n"; print ; close (FILE); exit(0); # ^^^^^ gets the next number in the set of images ^^^^^^^^^^^^^^^^^^^^^^^^ sub increment_image_number { local ($image_base ) = @_; local ($image_count_file); # File that tracks current GIF image local ($image_number); # Number of the current image local ($image_to_read); # Identifies the actual image $image_count_file = $image_base . ".cnt"; if (open(FILE, "<" . $image_count_file)) { $image_number = ; close(FILE); $image_to_read = $image_base . $image_number . ".gif"; if (open(FILE2, "<" . $image_to_read)) { close (FILE2); } else { $image_number = 1; } open(FILE, ">" . $image_count_file); print FILE ($image_number+1); close(FILE); $image_to_read = $image_base . $image_number . ".gif"; return $image_to_read; } else { print "Content-type: text/html", "\n\n"; print "ERROR: cannot find $image_count_file
"; } } # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv