#!/usr/local/bin/perl # this is a simple example to serve up a multipart # document in perl. you'll need to use the "non-parsed" # feature of your web server to prevent it from buffering # output from this script. to do that in apache, just # use "nph-" as the first characters of the filename. # turn off io buffering $|=1; # beceause this runs in non-parsed mode, we'll need to # supply all the http response headers: print "HTTP/1.0 200\n"; print "Content-type: multipart/x-mixed-replace;"; print "boundary=magicalboundarystring\n\n"; print "--magicalboundarystring\n"; # get a list of stuff to serve up. change the path # to something on your server: foreach (glob "/path/to/images/and/stuff/*") { # determine the content type: if (/\.jpe?g$/i) { print "Content-type: image/jpeg\n\n"; } elsif (/\.gif$/i) { print "Content-type: image/gif\n\n"; } elsif (/\.html?$/i) { print "Content-type: text/html\n\n"; } elsif (/\.txt$/i) { print "Content-type: text/plain\n\n"; } elsif (/\.au$/i) { print "Content-type: audio/basic\n\n"; } else { # skip it next; } # spit out the file if (open FILE, $_) { while () { print; } close FILE; } # end this section print "\n--magicalboundarystring\n"; # wait a little bit sleep 5; } # that's all exit 0;