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_text does a line by line comparison of the two files. It stops as soon as a difference is detected. compare_text() accepts an optional third argument: This must be a CODE reference to a line comparison function, which returns 0 when both lines are considered equal. For example:

    compare_text($file1, $file2)

is basically equivalent to

    compare_text($file1, $file2, sub {$_[0] ne $_[1]} )


File::Compare::compare and its sibling functions 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.

More Linux Commands

gnutls_x509_trust_list_verify_named_crt(3) - API function...
This function will try to find a matching named certificate. If a match is found the certificate is considered valid. In addition to that this function will als

Tcl_UniCharIsAlpha(3) - routines for classification of Tcl_U
All of the routines described examine Tcl_UniChars and return a boolean value. A non-zero return value means that the character does belong to the character cla

XWriteBitmapFile(3) - manipulate bitmaps - Linux man page...
The XReadBitmapFile function reads in a file containing a bitmap. The file is parsed in the encoding of the current locale. The ability to read other than the s

rmdir(1) - remove empty directories - Linux manual page.....
Remove the DIRECTORY(ies), if they are empty. --ignore-fail-on-non-empty ignore each failure that is solely because a directory is non-empty -p, --parents remov

isupper(3) - character classification routines (Man Page)...
These functions check whether c, which must have the value of an unsigned char or EOF, falls into a certain character class according to the specified locale. T

pnmtopclxl(1) - convert a PNM image to an HP LaserJet PCL XL
This program is part of Netpbm(1) pnmtopclxl reads one or more PNM input streams, each containing one or more PNM images, and generates a sequence of output pag

getutmp(3) - copy utmp structure to utmpx, and vice versa...
The getutmp() function copies the fields of the utmpx structure pointed to by ux to the corresponding fields of the utmp structure pointed to by u. The getutmpx

numastat(8) - Print statistics about NUMA memory allocation
numastat with no command options or arguments at all, displays per-node NUMA hit and miss system statistics from the kernel memory allocator. This default numas

glTexCoord1fv(3gl) - set the current texture coordinates....
glTexCoord specifies texture coordinates in one, two, three, or four dimensions. glTexCoord1 sets the current texture coordinates to (s, 0, 0, 1); a call to glT

Tk_GetMMFromObj(3) - translate between strings and screen un
These procedures take as argument a specification of distance on the screen (objPtr or string) and compute the corresponding distance either in integer pixels o

ps2ascii(1) - Ghostscript translator from PostScript or PDF
ps2ascii uses gs(1) to extract ASCII text from PostScript(tm) or Adobe Portable Document Format (PDF) files. If no files are specified on the command line, gs r

timerfd_gettime(2) - timers that notify via file descriptors
These system calls create and operate on a timer that delivers timer expiration notifications via a file descriptor. They provide an alternative to the use of s

We can't live, work or learn in freedom unless the software we use is free.