http://www.perlmonks.org?node_id=96828

FixNEthing has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to print a chr(10) (to a binary file), but it prints 13 10 instead. Is there any around this ?

Originally posted as a Categorized Question.

  • Comment on printing chr(10) to a file adds chr(13) infront

Replies are listed 'Best First'.
Re: printing chr(10) to a file adds chr(13) infront
by BrentDax (Hermit) on Jul 16, 2001 at 09:13 UTC
    The trick here is to call binmode() on the filehandle:
    open(BINARYFILE, ">file") or die "can't open file for writing: $!"; binmode(BINARYFILE);
Re: printing chr(10) to a file adds chr(13) infront
by tilly (Archbishop) on Jul 15, 2001 at 09:06 UTC
    binmode

    Originally posted as a Categorized Answer.