Dear Monks,

I began learning Perl a few years ago as a hobby. I would like to write a script that compares two directories and prints the differences. My question is, do you know any existing Perl scripts that can do this?

More Details of how this would work:

$DIR1 will contain the full path to directory 1
$DIR2 will contain the full path to directory 2
$RECURSIVE=1 compares subdirectories too
$MODE=0 Prints a quick summary of both directories. Shows you the total size of both directories and the number of files/directories they contain.
$MODE=1 compares whether the same files exist in both places.
$MODE=2 Also compares file sizes and dates and tells you which file is younger/older or larger/smaller.
$MODE=3 Compares the MD5 hash of files that appear to be same. If the MD5 hash does not match, then those files are listed along with the hash values.
$MODE=4 If the two directories contain two files with the same name, same size, then the program will compare those files byte for byte and display the difference in detail for each file. This option could generate a very long report and may take a long time.


In reply to perl script to compare two directories by harangzsolt33

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.