As I already said, I'm far from being an expert in this field of application. But apart that
- (I'd switch to a more recent perl if possible and) use warnings instead of -w;
- use a lexical filehandle and the 3-args (with "<:raw") form of open,
at first sight the only thing that I can guess is that
Content-Type: application/msword;
doesn't play well with a gif file: indeed the header is recognized as a GIF89a as printed in the error message. Did you try with an actual word doc? How 'bout a plain application/octet-stream if that doesn't work either? I for one would be happier to just download it rather than to directly open it even if I were on a Windows box...