The above works find on Windows - Are you using a Cygwin build?

I'm running the program under plain Windows at the moment...

But programming is a black art, really. When I came back to work today, with some ideas how to test it, I found that the program runs fine, without any modifications - no extra \r anymore on output! Of course I still had the bug of extra \n, because of the way I read in my data, but this was trivial to correct. In short: I have no idea why it didn't work yesterday, but works well today. Creepy.

For completeness, here is the full code (unmodified) which I'm using to test. In particular, I did not yet try the (neat) idea of using raw mode. It turned out to be unnecessary in this case:

use strict; use warnings; use IO::File; # copy \n delimited file from Windows to # Samba share on Unix. Output is also # supposed to be delimited by \n my $par='c:/tmp/dev.cs'; my $file=new IO::File $par,'r' or die "$!"; my $data=join '',<$file>; # !!!! undef $file; my $_path_local='u:/transfer/devc.cs'; my $handle=IO::File->new($_path_local,'w') or die "$!"; $handle->binmode; print $handle $data; $handle->close;
My best explanation for the fact that it suddenly turned out to work overnight is that I mistakingly grabbed an old version of my application from our source control system (a version which did not have the binmode set), and used *that* one instead of the version I had in my editor. Not likely, but the best explanation aside from a miracle having happened.

Thank you to everyone for contributing ideas.

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^2: Can't get rid of \r - SOLVED (Kind of) by rovf
in thread Can't get rid of \r by rovf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.