\n newline doesn't work in your situation because HTML-rendering browsers don't respect newline characters, except probably within <pre></pre> tags. If you want a new line in general HTML documents, you have to use a HTML tag or set of tags. For example, wrap the text in <p>...</p> tags, or for a line break use <br />.

If you're trying to get tabular data to render in HTML form, your script needs to output the proper HTML to do that too. More often than not, that means using tables. You do that by outputting <table></table><tr></tr><td></td> and so on.. tags, in accordance with proper HTML formatting practices.

Update for clarification:
This actually has a lot less to do with array manipulation than it does with understanding the interplay between a Perl based CGI script, and the client's browser. Think of what you would write in a static HTML web page, and then understand that Perl must output that. If you would write a web page like this:

<head> <title>My page</title> <h1>My page</h1> </head> <body> <p>Hello world!</p> </body>

...then you need your Perl script to output all that, tags and all. If you want the browser to render data in table format, output the html tags for a table, intersperced with the actual data.

Update 2: Sorry, I keep thinking of more to say.
Regarding the use of strictures (use strict;): Strict is basically a tool that helps you to make sure you're not accidentally breaking tried and proven rules of conduct. With strictures enabled you can't, for example, accidentally stumble into the trap of using symbolic references. A misspelled variable or function name will become more easily apparent. And it encourages you to learn to use lexical scoping, or at very least to declare your globals. With time you'll learn more about how it helps you to live a clean and healthy life.

Welcome to the Monastery!


Dave


In reply to Re: Array manipulation by davido
in thread Array manipulation by loop362

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.