File::Compare - Compare files or filehandles


        use File::Compare;

        if (compare("file1","file2") == 0) {
            print "They're equal\n";


The File::Compare::compare function compares the contents of two sources, each of which can be a file or a file handle. It is exported from File::Compare by default.

File::Compare::cmp is a synonym for File::Compare::compare. It is exported from File::Compare only by request.


File::Compare::compare return 0 if the files are equal, 1 if the files are unequal, or -1 if an error was encountered.


File::Compare was written by Nick Ing-Simmons. Its original documentation was written by Chip Salzenberg.


We are painfully aware that these documents may contain incorrect links and misformatted HTML. Such bugs lie in the automatic translation process that automatically created the hundreds and hundreds of separate documents that you find here. Please do not report link or formatting bugs, because we cannot fix per-document problems. The only bug reports that will help us are those that supply working patches to the installhtml or pod2html programs, or to the Pod::HTML module itself, for which I and the entire Perl community will shower you with thanks and praises.

If rather than formatting bugs, you encounter substantive content errors in these documents, such as mistakes in the explanations or code, please use the perlbug utility included with the Perl distribution.

--Tom Christiansen, Perl Documentation Compiler and Editor

Return to the Perl Documentation Index.
Return to the Perl Home Page.