Two notes:

First, please run perltidy on your script. The code should be as easy for the human eye to parse as it is for the interpreter to parse. People have been trying to read your code and getting tripped up on the brace matching.

Second, though I haven't got a Linux box here to try it, I think your problem is a lack of a final newline. This can trip up some of Linux's terminal windows, for example.

The desperate final line print ",,,,,,,,,\n,,,,,,,,,\n"; should print both groups of commas and a final newline, but maybe your output as demonstrated was from a test run without that line. When I ran your code verbatim (and the example %Tests above), the last output had no newline following the last item. Your terminal prompt probably just printed on top of your last and unterminated line of output.

To diagnose this in the future, run your script and output it to a file: (foo >foo.txt). Then edit the file to see if it has the last line. If so, then it's your terminal's problem: it's obliterating the last bit of output to print your interactive shell prompt.

The construct { $" = "\n"; print "@array"; } is equivalent to the construct: { print join("\n", @array); }. Neither one will follow the last item with your separator.

Always print a newline last.

--
[ e d @ h a l l e y . c c ]


In reply to Re: print dropping a line? by halley
in thread print dropping a line? by Anonymous Monk

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.