Search:
www.rocket99.com : Technical Guides Sybase Oracle UNIX Javascript


Technical Guides
Sybase
Oracle
UNIX
Javascript




After Work

Highlife Adventures
The best club in Chicago
for Chicago Singles is Highlife Adventures!


Jersey Girl Shirts
Are you looking for a
Jersey Girl T-Shirt ?



Kyoto Sushi
in Chicago, on Lincoln Ave.
Moody's Pub
in Chicago, has great burgers
Skylark
in Chicago, on Halsted .. excellent Friday fish fry!


UNIX » Perl » Coding »

Compare Two Binary Files

     




#!/usr/bin/perl
#----------------------------------------
# Compare two binary files
# See comments below for modifications
#----------------------------------------

$file1 = $ARGV[0];
$file2 = $ARGV[1];

$size1 = -s $file1 ;

open(FILE1,"<$file1") or die "Input file: Cannot open file1\n\n";
open(FILE2,"<$file2") or die "Input file: Cannot open file2\n\n";

$i = 0 ;
$j = 0 ;

while ($i < $size1 )
{
$i ++ ;

$ch1 = getc(FILE1);

$ch2 = getc(FILE2);

print $ch1 . $ch2 . "\n" ;

if (!($ch1 eq $ch2))
{
print "Difference detected at character: " . $i . "\n" ;

$j ++ ;
}

# diff limiter: edit this line to modify
# the number of differences before exiting program
if ($j > 15)
{
exit ;
}

}


close(FILE1);
close(FILE2);









UNIX : Related Topics

UNIX : Perl : Text file processor - sewing paragraphs together
UNIX : Perl : CSV File Processor
UNIX : Perl : Replace characters in a file via Perl utility
UNIX : Perl : Remove exponents in a floating number
UNIX : Perl : Set precision of a numeric string
UNIX : Perl : Parse command line options
UNIX : Perl : HTML directive for Perl CGI
UNIX : Perl : Binary File Viewer
UNIX : Perl : Binary File Cutter
UNIX : Perl : Arrays and Lists

Sybase Web Site
Sybase Mobile Web Site
Oracle Web Site





Site Index About this Guide to Sybase, Oracle, and UNIX Contact Us Advertise on this site




Copyright © 2008 Citisoft Inc All Rights Reserved.