Well , the script should read all the files from the first directory and all its subdirectories and compare to its corresponding files in second directory.The two directory name are command line arguments
Result:
FAIL - If atleast one file is not bitwise equal to the corresponding file in the second directory or the second directory has no file. Otherwise it is passed.
| [reply] |
kelly,
Based on this explanation, you are going to want to take a look at File::Find. There are other modules on CPAN that try to make up for the horrendous call-back interface but the point is - don't try and walk the directory structure yourself - you will make a mistake.
You are also going to want to take a look at File::Spec. There are a bunch of functions that will help you say things like chop off this portion of the path and replace it with this other path in order to determine if the file even exists in the other directory prior to comparing the actual file contents.
You probably also want to take a look at Digest::MD5. It isn't a great choice for cryptographical reasons but in order to determine if two files are or are not the same, it has a really simple interface and should work just fine.
If you want more help than that, you are going to have to show some more effort first.
| [reply] |
Thanks a lot guys, i will pursue the headsup . Basically my intention is not to simulate diff -r in Perl, rather the contents of the file bit-by-bit. Thanks once again.
| [reply] |
Ah, so you want something else that what you first described. Hence, instead of using just diff, you should use diff -r, as in:
diff -r directory1 directory2
That's much faster than figuring out how to use File::Find, and doing all the comparison yourself. | [reply] [d/l] [select] |
If all you want to know is if there are any differences between the two directories, it might make sense to hash the tarballs of the directories and just see if the hashes match up.
| [reply] |
| [reply] [d/l] |