in reply to Why doesnt it work

Well, the first thing you need to change is the content type line: print "Content-type: text/html\n\n"; is what most people usually use. It can be tricky to get that just right in a here-doc, so I never do it that way. You could also use the header method in CGI, which will take care of it in a platform-independent fashion. That's the biggest and best reason for errors I can see.