Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 scrutinizing the Monastery: (10)
As of 2015-07-03 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls