The script is not outputting a "newline" character, "\n". Without that, it's possible that either the output buffer isn't being flushed (unlikely), or that the print is there, but without a new line, when the program terminates your command-line prompt is getting printed over your "Hello world".

This might happen, for example, if no newline is output, and yet when the command shell takes over upon program termination, it starts the prompt with a return to the leftmost screen column... on the same line that you just printed "Hello world".

Just to be on the safe side, until you get used to how buffering and newlines work, end your print statements with a '\n'. That's an overgeneralization, but you'll quickly catch on to when/where you need newlines after you've tinkered a few more hours.

I know this is probably not the right teaching example, but I used the technique of printing with \r (return), without \n (newline) to accomplish a JAPH that gave the visual impression of text sliding across the bottom of the screen. It's at: Slipery JAPH, if you're interested. ...just an aside; it's nothing serious.

The need to output newlines is not entirely foriegn to people familiar with C. The buffering is a little different, IIRC, but the principle is along the same lines.


Dave


In reply to Re: Messed up printing by davido
in thread Messed up printing by vect0r

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.