1File::Compare(3pm) Perl Programmers Reference Guide File::Compare(3pm)
2
3
4
6 File::Compare - Compare files or filehandles
7
9 use File::Compare;
10
11 if (compare("file1","file2") == 0) {
12 print "They're equal\n";
13 }
14
16 The File::Compare::compare function compares the contents of two
17 sources, each of which can be a file or a file handle. It is exported
18 from File::Compare by default.
19
20 File::Compare::cmp is a synonym for File::Compare::compare. It is
21 exported from File::Compare only by request.
22
23 File::Compare::compare_text does a line by line comparison of the two
24 files. It stops as soon as a difference is detected. compare_text()
25 accepts an optional third argument: This must be a CODE reference to a
26 line comparison function, which returns 0 when both lines are
27 considered equal. For example:
28
29 compare_text($file1, $file2)
30
31 is basically equivalent to
32
33 compare_text($file1, $file2, sub {$_[0] ne $_[1]} )
34
36 File::Compare::compare and its sibling functions return 0 if the files
37 are equal, 1 if the files are unequal, or -1 if an error was
38 encountered.
39
41 File::Compare was written by Nick Ing-Simmons. Its original
42 documentation was written by Chip Salzenberg.
43
44
45
46perl v5.26.3 2018-03-01 File::Compare(3pm)