I think I see the problem now. The sub force_move() is only going to get file names, not full path names. I.e. $_ is just going to be a file name, not a full path name in force_move(). So the copy will fail without regard to binmode or not. As you descend through the directory structure, you will have to keep track of the current file path.

Another point: a directory is a special type of binary file and cannot be copied with a simple copy.

if (! (-d $filepath) && (-B $filepath) { true if not a directory and otherwise a binary file}
Also in Windows, it is not necessary to use \\, use / for the separators in file path. Perl will convert this the right way for Windows and it is easier to read.

So I would suggest getting this force_move thing working with full file paths: copy full_dest_path, full_src_path.


In reply to Re: bin mode file copy by Marshall
in thread bin mode file copy by smanicka

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.