SuicideJunkie and ikegami have provided answers to your nominal question but even with their corrections, I'm not quite sure why your test script produces any content renderable in the browser, since it lacks several elements required by html standards, notably <html>, <head>, <title>, </title>,</head> and <body>:

The CGI.pm doc (available on your local machine at perldoc CGI.pm) provides a simple example of (one way) to do so (and throws in a recommended-but-not-required DTD for free):

use CGI qw/:standard/;
print header,
start_html('A Simple Example'),
...

which will provide, for rendering:

Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>A Simple Example</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body>

Note that the print header, took care of the required Content-Type: text/html; charset=ISO-8859-1-followed-by-two-newlines. Since you didn't use print header your manual print of the Content-Type is NOT redundant (if interested in the issue, you can read numerous nodes here where the problem was coding in such a way as to emit Content-Type... twice).

If you chose to avoid print header, you MUST supply the <html>, <head>, <title>, title-content, </title>, </head><c> and <c><body>. (IMO, the best reason to eschew print header,... is to allow you to select another DTD and add additional meta data.)

Update: edited html to fix cut'n'paste error which doubled "<!DOCTYPE html" - thanks ikegami!


In reply to Re: Arrays with CGI perl help (More fundamental issues) by ww
in thread Arrays with CGI perl help by perlnewb123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.