in reply to Won't print unless newline is included?

That's perl's buffering. Just like the C stdio library, it buffers its output; when it's printing to the terminal it flushes the buffers every time it prints a newline character, and printing to a pipe or a file only when it finishes writes a full block of bytes. It does one final flush right before the program exits.

The easiest way to fix this is to turn on autoflush, with this assignment: $|=1;