st4k, as rchiav stated and as I showed you earlier, you probably don't want to store the newline characters in your array. In my example using print join("\n",@out); I demonstrated a way to manipulate the array (without changing its contents) and printing the results each element on a new line. By storing the data without newlines you could also do something slightly different:
my @out = qw(one two three four five six seven eight nine); my $i = 0; foreach (@out) { print "\$out[",$i++,"] = '$_'\n"; } =output= $out[0] = 'one' $out[1] = 'two' $out[2] = 'three' $out[3] = 'four' $out[4] = 'five' $out[5] = 'six' $out[6] = 'seven' $out[7] = 'eight' $out[8] = 'nine'
But if you had stored the newlines in the array, the last ' in each line would've been pushed to the next line by the newline character stored in the array:
=output= $out[0] = 'one ' $out[1] = 'two ' $out[2] = 'three ' $out[3] = 'four ' $out[4] = 'five ' $out[5] = 'six ' $out[6] = 'seven ' $out[7] = 'eight ' $out[8] = 'nine '
You have more flexibility if you store only the data.

In your example @out = join "\n", @out; you are destroying your array. Instead of the output above you would get the following output using the same print loop:

my @out = qw(one two three four five six seven eight nine); @out = join "\n", @out; my $i = 0; foreach (@out) { print "\$out[",$i++,"] = '$_'\n"; } =output= $out[0] = 'one two three four five six seven eight nine'
Instead of having 9 rows you now have only one row made up of a string with interspersed newlines. As a rule, most people don't print an array using   print @array; except when debugging.

Try playing around with the print loop above to test other types of array manipulation. It will give you a better idea of how your data is stored in the array structure.

--Jim


In reply to Re: Re: Re: Re: I'm so confused by jlongino
in thread I'm so confused by st4k

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.