in reply to Creating Unix Friendly files in win32

Apart from what its said above you can create unix files by using the following idiom:
open OUT, ">>", "test.txt"; binmode OUT; print OUT "some text\x0A"; close OUT;
\x0A is the linefeed characted in hex notation.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Creating Unix Friendly files in win32
by polettix (Vicar) on Sep 26, 2005 at 10:24 UTC
    Just curious: why use \x0A instead of \n? Does the latter get converted even if binmode is set on the filehandle?

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      Ugh. No. \n and binmode works just fine. But \x0A gets converted to \x0D\x0A if binmode is not present.

      That's a pitfall and I must have mixed it up in my memory.


      holli, /regexed monk/
        But \x0A gets converted to \x0D\x0A if binmode is not present.
        Seriously? By who? I'm not doubting you (as I have no Windows machine handy to test it out on), but that seems a little odd...

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come