Feel like I'm back in comp-sci, but this time, they'll actually let me use a
real language (don't get me started on "Turing" ;)).
I wrote this simple script that should work with 5.003...
Jason
#!/usr/bin/perl -w
# call this with 2 params, such as
# > diff.pl [file1] [file2]
use strict;
my ( @filea, @fileb, @inAButNotInB, @inBButNotInA );
open ( FILEA, shift ) || die "Cannot open 1st file: $!\n";
@filea = <FILEA>;
close ( FILEA );
open ( FILEB, shift ) || die "Cannot open 2nd file: $!\n";
@fileb = <FILEB>;
close ( FILEB );
foreach my $object ( @filea ) {
chomp $object;
push @inAButNotInB, $object if ( !grep(/$object/, @fileb) );
}
print "In A, but not in B: " . join(", ", @inAButNotInB) . "\n";
foreach my $object ( @fileb ) {
chomp $object;
push @inBButNotInA, $object if ( !grep(/$object/, @filea) );
}
print "In B, but not in A: " . join(", ", @inBButNotInA) . "\n";
__END__
If memory serves me right, on Tuesday 29 January 2002 12:26,
[EMAIL PROTECTED] wrote:
> I have two lists of objects in two files. I need a way to compare these two
> files and:
>
> 1- report any objects in File A that are not in File B
> 2- report any objects that are in File B but not in File A
>
> 3- Restriction: I am not working with a modern version of Perl, I am
> restricted to the following: 5.003 (yeah...I know...it's not my decision)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]