Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The example you supplied using <a href="https://metacpan.org/module/File%3a%3aDirCompare">File::DirCompare</a> works as intended.</p> <p>Keep in mind that the callback subroutine is called for every <em>unique</em> file in each directory and for every pair of files <em>which differ in their content</em>. Having the same filename is not enough, the contents of each file in each directory must be exactly the same as well.</p> <p>Furthermore, the cases in which you report "PASSED" aren't a success at all (by your definition) since they detail the cases in which a file exists in one of the directories, but not the other: meaning the directories' contents are not identical.</p> <p>This should be closer to what you want:</p> <pre class="lang-perl prettyprint-override"><code>#!/usr/bin/perl use strict; use warnings; use File::DirCompare; use File::Basename; sub compare_dirs { my ($dir1, $dir2) = @_; my $equal = 1; File::DirCompare-&gt;compare($dir1, $dir2, sub { my ($a,$b) = @_; $equal = 0; # if the callback was called even once, the dirs are not equal if ( !$b ) { printf "File '%s' only exists in dir '%s'.\n", basename($a), dirname($a); } elsif ( !$a ) { printf "File '%s' only exists in dir '%s'.\n", basename($b), dirname($b); } else { printf "File contents for $a and $b are different.\n"; } }); return $equal; } print "Please specify two directory names\n" and exit if (@ARGV &lt; 2); printf "%s\n", &amp;compare_dirs($ARGV[0], $ARGV[1]) ? 'Test: PASSED' : 'Test: FAILED'; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload