Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 $/; }

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 making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2016-09-30 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (563 votes). Check out past polls.