I want to ask something and hope that someone can shed some light in my direction. I started writing a script that at the time seemed like it was gonna be a breeze lol. but the deeper i got into the script the more complex i seen that it got. I have two arrays. One array has the md5 directory/all sub directories and filename of the first directory (without . and ..). The second one has the md5 directory/and all its sub directories with the filenames (without . and ..).

what i am trying to do is compare both directories like:
for my $data0(@array0){ my ($md50, $filepath0, $filename0)= split (/\s+, $data0); for my $data1(@array1){ my ($md51, $filepath1, $filename1) = split (/\s+/, $data1); if ($md50 !~ $md51 && $filename0 =~ $filename1){ make_path($filepath0); copy("$filepath0$filename0, $filepath1); } else{ #do nothing } } }
now to the question. i am trying to compare each file in the directories and sub directories of 2 args. but i am only trying to copy the ones that do NOT match and to that particular directory only. both args have different directory trees as well and i think that is the kicker and is why it is confusing me so badly :l i cannot for the life of me figure this out lol. i can get it to copy files but its either all files get copied into all directories, or none. It would be optimum if i could indeed preserve the filepath as well...
what am i doing wrong? ive used strict and warnings and diagnostics, but it is not returning any errors at all, so i am out of options because the script runs and completes, but it will not copied the files.

In reply to File copy based on conditions in two arrays by james28909

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.