in reply to What is responsible for a

Ths is just a guess, since nobody else seems to have any ideas yet...

I used to have problems when I would create/edit a Perl script on my Windows 9x box and FTP it to the *nix server... the line break characters were all encoded in PC file format. I save the files in Unix format and that fixes it. Could something like that be your problem? The fact that it is fixed when you open/save the file without any changes makes me think it may be this or something similar.

Good luck...

Alan "Hot Pastrami" Bellows

Replies are listed 'Best First'.
Line\nbreaks
by orkysoft (Friar) on Dec 15, 2000 at 04:18 UTC

    Linebreaks shouldn't scare the Perl interpreter too much (except with comments), but here's my XP with the troubles Windows pc's have when confronted with Unix textfiles:

    They'll appear as one long line in programs like Notepad, with their original linebreaks displayed as a couple of black block-like character.

    To solve this, there are two solutions:

    • FTP in ASCII mode
    • Open and Save the file in EDIT.COM (which is, IMHO, the only 'not-entirely-bad' MS program ;-)

    To my knowledge, Windows textfiles (with \n\r) display correctly on Unix systems, but there is usually a script to convert to and fro these formats.

      > there is usually a script to convert to and fro these formats

      Of course, there's always perl:

      perl -pi -e 's/\r//' file.txt # for windows to unix perl -pi -e 's/\n/\r\n/g' file.txt # for unix to windows

      If you use this frequently under unix, you can alias it to something like:

      alias w2u="perl -pi -e 's/\n/\r\n/g' "

      Then you'll be able to just do w2u file every time you want to convert a file.

      Please note: I haven't been able to check the unix to dos way as I don't have perl installed on my windows machine at home. Please let me know if it doesn't work.

      My usual solution is to open in vim on both platforms.
      Perl doesn't care about types of white space, so why should my editor?
      I'd assume emacs does the right thing as well.