The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

testcmp -- compare two files line-by-line

SYNOPSIS

    $is_diff = testcmp($file1, $file2);

or

    $is_diff = testcmp({-cmplines => \&mycmp}, $file1, $file2);

DESCRIPTION

Compare two text files line-by-line and return 0 if they are the same, 1 if they differ. Each of $file1 and $file2 may be a filenames, or a filehandles (in which case it must already be open for reading).

If the first argument is a hashref, then the -cmplines key in the hash may have a subroutine reference as its corresponding value. The referenced user-defined subroutine should be a line-comparator function that takes two pre-chomped text-lines as its arguments (the first is from $file1 and the second is from $file2). It should return 0 if it considers the two lines equivalent, and non-zero otherwise.