Netscape will only display HTML code if Netscape has been told
it's HTML. (Quite surprisingly, Netscape follows the standard -
that must have been by accident). You have to tell on the browser
what the content-type of the document is, by issueing the correct
HTTP header. CGI.pm has functions for that (although you could
print them yourself). But that vital piece of code is missing
from your code fragment (which only includes code that's totally
irrelevant for the question).
Abigail