in reply to print dropping a line?

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 ]

Replies are listed 'Best First'.
Re: Re: print dropping a line?
by Anonymous Monk on Jun 02, 2003 at 18:55 UTC
    Thanks everyone. I'm not at home right now, so I can't check out any of the stuff you suggested. And the reason the code is unreadable is becuase I spent an hour trying unsuccessfully to get various things to work. Again, thanks for your help.