in reply to Variable blasphemy

Hi SixTheCat,

this looks like using under Unix a file prepared under Windows.

Under Unix, new line characters are \n (line feed). Under Windows, new line is a combination of two characters: \r\n (carriage return and line feed).

If you chomp a line under Unix (or Linux), it will remove only \n (line feed).

If the file was prepared under Windows, this will leave the carriage return, meaning that the cursor will go back to the start of the line without doing a line feed, thereby clobbering the beginning of the line.

If that's your problem, you could change chomp to:

s/[\r\n]+$//;
to remove any combination of the two end-of-line characters at line end.

Replies are listed 'Best First'.
Re^2: Variable blasphemy
by SixTheCat (Novice) on Jul 24, 2015 at 15:54 UTC
    Thanks! It's all good now. Curse my use of windows!

      Nah, Perl plays Unix and Windows well. If you have both in your environment, it would behoove you to remember the small handful of portability issues you encounter, and make handling them part of your default programming habits.

      Modules often help with this.