Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Comparison Of Files

by mdillon (Priest)
on Dec 05, 2000 at 21:42 UTC ( #45034=note: print w/ replies, xml ) Need Help??


in reply to Comparison Of Files

since the data files are effectively presorted...

ObAlgorithmDiff:
#!/usr/bin/perl -w use strict; use Algorithm::Diff qw(traverse_sequences); die unless @ARGV == 2 and $ARGV[0] ne $ARGV[1]; my @files = @ARGV; my %data; push @{$data{$ARGV}}, $_ while <>; my $a = $data{$files[0]}; my $b = $data{$files[1]}; my (@additions, @deletions); traverse_sequences $a, $b, { DISCARD_A => sub { push @deletions, $a->[$_[0]] }, DISCARD_B => sub { push @additions, $b->[$_[0]] }, }; if (@deletions) { print "Deletions:", $/; print for @deletions; print $/; } if (@additions) { print "Additions:", $/; print for @additions; print $/; }


Comment on Re: Comparison Of Files
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://45034]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-11-26 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls