in reply to Re: What is responsible for a
in thread What is responsible for a

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:

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.

Replies are listed 'Best First'.
Re: Line\nbreaks
by mischief (Hermit) on Dec 15, 2000 at 12:53 UTC
    > 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.

Re: Line\nbreaks
by repson (Chaplain) on Dec 15, 2000 at 09:45 UTC
    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.