in reply to Re: Compare Binary Files
in thread Compare Binary Files

sub files_differ { system "cmp file1 file2"; return $? >> 8; }

Windows has no "cmp" command. $? is set to 0x0100, files_differ always returns 1, even with missing files, even with identical files. Instant fail.

H:\>perl -e "system 'cmp file1 file2';print $?,' ',$? >> 8" 'cmp' is not recognized as an internal or external command, operable program or batch file. 256 1 H:\>

And by the way: Omitting quotes around the file name begs for trouble as soon as you replace the constants with variables. Using the multiple argument form of system would prevent that problem.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: Compare Binary Files
by BrowserUk (Patriarch) on Sep 08, 2011 at 05:31 UTC

    I have a cmp command on my windows system. There is also the comp command which has been available on all versions of windows:

    C:\test>cmp cmp: missing operand cmp: Try `cmp --help' for more information. C:\test>comp /? Compares the contents of two files or sets of files. COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]] data1 Specifies location and name(s) of first file(s) to compar +e. data2 Specifies location and name(s) of second files to compare +. /D Displays differences in decimal format. /A Displays differences in ASCII characters. /L Displays line numbers for differences. /N=number Compares only the first specified number of lines in each + file. /C Disregards case of ASCII letters when comparing files. /OFF[LINE] Do not skip files with offline attribute set. To compare sets of files, use wildcards in data1 and data2 parameters.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      have a cmp command on my windows system.

      Because you installed it? At least the DOS-based Windows versions (1.x, 2.x, 3.x, 95, 98, ME), Windows 2000 and Windows XP lack a cmp command after a fresh installation.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Compare Binary Files
by pemungkah (Priest) on Sep 17, 2011 at 02:44 UTC
    Quite agree on the list form invocation; that's a much better choice. I always forget it, for some reason.

    Re no cmp on Windows: that just means this isn't the simplest possible thing for Windows. I'm sure there is an equivalent.