Perl Module or Script for difference of two files 
Author Message
 Perl Module or Script for difference of two files

Hi out there,

I already asked this question before, but I didn't get an answer.
Is there a unix-like "diff" command available as a Perl-Module or is there
a Perl-Script available, which does the same.

Unfortunatly I was forced to move from SUN's to Windows-NT 4.0, and there is
really no adequate system command like the "unix - diff".

Help is appreciated

Burkhard



Mon, 02 Oct 2000 03:00:00 GMT  
 Perl Module or Script for difference of two files

   [posted and mailed to cited author]

Quote:

> Unfortunatly I was forced to move from SUN's to Windows-NT 4.0, and there is
> really no adequate system command like the "unix - diff".

The "Unix diff" itself is available as part of the Cygwin32 user tools
distribution, along with many other of your favorite command-line
tools.

       http://www.cygnus.com/misc/gnu-win32/

--



Mon, 02 Oct 2000 03:00:00 GMT  
 Perl Module or Script for difference of two files

[snip]

Quote:
> Is there a unix-like "diff" command available as a Perl-Module or is there
> a Perl-Script available, which does the same.[snip]

Here is a dumb but functional script...

#!/usr/gnu/bin/perl -w
#
# Name:
#       diff.pl.
#
# Purpose:
#       A diff which ignores differences in comments.
#

use integer;
use strict;

# ----------------------------------------------------------------------

my($file1) = shift;
my($file2) = shift;

open(INX1, $file1) || die("Can't open($file1): \nFailure: $!");
open(INX2, $file2) || die("Can't open($file2): \nFailure: $!");


$i = 0;

while (! eof(INX1) )
{
        $i++;
        $one = <INX1>;
        chomp($one);

        if (eof(INX2) )
        {

                next;
        }

        $two = <INX2>;
        chomp($two);

        # Ignore differences in comments.
        next if ( ($one =~ /^\s*#/) && ($two =~ /^\s*#/) );

        if ($one ne $two)
        {

        }

Quote:
}

while (! eof(INX2) )
{
        $i++;
        $two = <INX2>;
        chomp($two);


Quote:
}

close(INX1);
close(INX2);

if ($#log >= 0)
{

        # Failure.
        exit(-1);

Quote:
}

# Success.
exit(0);

--
Cheers,
Ron Savage


Web: http://www.ozemail.com.au/~rpsavage



Sat, 07 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Use perl to find the differences between two text files

2. Use perl to find the differences between two text files

3. difference of two files?

4. SUMMARY: difference of two files

5. check difference of two files

6. Comparing two folders then writing difference to file.

7. Differences between two files?

8. Combining two files into a two-column file

9. perl module to compare two files?

10. difference between two dates using perl.

11. perl script to swap the first two columns of the file /etc/hosts

12. perl script to swap the first two columns of the file /etc/hosts

 

 
Powered by phpBB® Forum Software