in reply to File copy based on conditions in two arrays

Hello james28909,

First, the code snippet provided is incomplete, and contains at least one, and probably two, syntax errors. Second, to understand what you are trying to do, I think we will need to see sample input data, together with the desired output. In the meantime I will make one observation: this line:

if ($md50 !~ $md51 && $filename0 =~ $filename1){

is unlikely to work correctly across all cases. For example, if $md50 is '123456' and $md51 is '12345', the first condition will evaluate to false (because the match succeeds); but (I’m guessing) the logic of your code requires it to be true. Much simpler to use ne and eq here in place of !~ and =~, respectively:

if ($md50 ne $md51 && $filename0 eq $filename1){

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: File copy based on conditions in two arrays
by james28909 (Deacon) on Oct 09, 2014 at 06:00 UTC
    ok, i will clean the code up some and post it. but like i say, it completes fine, and will even copy files while preserving the original directorys to a new path eg: new_path/$filepath0/$filename0. the problem does come in when i try to copy the $filename0 to $filepath1. also $filepath1 has the same directory structure, but the base foldername is a little different. i want to copy /$filename0 to $filepath1/. it just doesnt make any sense. ive tried everything i can imagine lol. Ill get this code cleaned up and posted. ill try to post a zip file with everything in it as well. so you can just unzip and run the script.