|
NAMEFile::Cmp - compare two files character by characterSYNOPSISuse File::Cmp qw/fcmp/; print "identical" if fcmp("/tmp/foo", "/tmp/bar"); fcmp( $fh1, $fh2, binmode => ':raw', # a good default fscheck => 1, # ... but beware network fs/portability RS => \"4096" # handy for binary ); Among other optional parameters. DESCRIPTIONThis module offers a fcmp function that checks whether the contents of two files are identical, in the spirit of the Unix cmp(1) utility. A single subroutine, fcmp, is offered for optional export. It expects at minimum two files or file handles, along with various optional parameters following those filenames. Any errors encountered will cause an exception to be thrown; consider "eval" or Try::Tiny to catch these. Otherwise, the return value will be true if the files are identical, false if not.Note that if passed a file handle, the code will read to the end of the handle, and will not rewind. This will require "tell" and "seek" function calls before and after fcmp to return to the same position, if necessary. Likewise, if entire file contents are to be compared, file handles may need "SEEK_SET" performed on them to move to the beginning prior to the fcmp call. None of this is a concern if file names are passed instead of file handles. "readline" calls are used on the filehandle. This means the usual "do not mix sys* and non-sys* calls on the same filehandle" advice applies for any passed filehandles. (See the "sysread" function perldocs for details in perlfunc.) Available parameters include:
BUGSNo attempt at portability is made; in particular, this module assumes Unix file system semantics for the "fscheck" parameter.Newer versions of this module may be available from CPAN. If the bug is in the latest version, check: <http://github.com/thrig/File-Cmp> HISTORYAs a historical note, there was an old File::Cmp module from 1996-10-21 that exported "cmp_file". That old interface is not replicated in this implementation, though would not be difficult to add, if necessary.<http://backpan.perl.org/authors/id/J/JN/JNH/> SEE ALSOcmp(1), perlfunc, perlport, perlvarAUTHORthrig - Jeremy Mates (cpan:JMATES) "<jmates at cpan.org>"COPYRIGHT AND LICENSECopyright (C) 2013-2015 by Jeremy MatesThis module is free software; you can redistribute it and/or modify it under the Artistic License (2.0).
Visit the GSP FreeBSD Man Page Interface. |