Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    File::DirCompare 0.3

    Download button

    No screenshots available
    Downloads: 395  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Gavin Carr | More programs
    Perl Artistic License / FREE
    July 5th, 2007, 18:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    File::DirCompare description

    File::DirCompare is a Perl module to compare two directories using callbacks.

    File::DirCompare is a Perl module to compare two directories using callbacks.

    SYNOPSIS

    use File::DirCompare;

    # Simple diff -r --brief replacement
    use File::Basename;
    File::DirCompare->compare($dir1, $dir2, sub {
    my ($a, $b) = @_;
    if (! $b) {
    printf "Only in %s: %sn", dirname($a), basename($a);
    } elsif (! $a) {
    printf "Only in %s: %sn", dirname($b), basename($b);
    } else {
    print "Files $a and $b differn";
    }
    });

    # Version-control like Deleted/Added/Modified listing
    my (@listing, @modified); # use closure to collect results
    File::DirCompare->compare('old_tree', 'new_tree'), sub {
    my ($a, $b) = @_;
    if (! $b) {
    push @listing, "D $a";
    } elsif (! $a) {
    push @listing, "A $b";
    } else {
    if (-f $a && -f $b) {
    push @listing, "M $b";
    push @modified, $b;
    } else {
    # One file, one directory - treat as delete + add
    push @listing, "D $a";
    push @listing, "A $b";
    }
    }
    });

    File::DirCompare is a perl module to compare two directories using a callback, invoked for all files that are 'different' between the two directories, and for any files that exist only in one or other directory ('unique' files).
    File::DirCompare has a single public compare() method, with the following signature:

    File::DirCompare->compare($dir1, $dir2, $sub, $opts);

    The first three arguments are required - $dir1 and $dir2 are paths to the two directories to be compared, and $sub is the subroutine reference called for all unique or different files. $opts is an optional hashref of options - see OPTIONS below.

    The provided subroutine is called for all unique files, and for every pair of 'different' files encountered, with the following signature:

    $sub->($file1, $file2)

    where $file1 and $file2 are the paths to the two files. For 'unique' files i.e. where a file exists in only one directory, the subroutine is called with the other argument 'undef' i.e. for:

    $sub->($file1, undef)
    $sub->(undef, $file2)

    the first indicates $file1 exists only in the first directory given ($dir1), and the second indicates $file2 exists only in the second directory given ($dir2).

    Requirements:

    · Perl



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    compare directories | Perl callbacks | Perl module | File::DirCompare | compare | directories

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM