in reply to CGI redirection after headers sent

I think Image::ParseGIF would be a nice module to use for your animated gif, check it out.

For your HTTP header issue, maybe you can settup that page to refresh in some amount of time after refreshing it checks to see what it should do, if it should start all over or do the next action.

Good Luck