Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Algorithm::Diff 1.1902

Date Added: February 07, 2010  |  Visits: 549

Algorithm::Diff is a Perl module to compute `intelligent differences between two files / lists. SYNOPSIS require Algorithm::Diff; # This example produces traditional diff output: my \$diff = Algorithm::Diff->new( @seq1, @seq2 ); \$diff->Base( 1 ); # Return line numbers, not indices while( \$diff->Next() ) { next if \$diff->Same(); my \$sep = ; if( ! \$diff->Items(2) ) { printf "%d,%dd%dn", \$diff->Get(qw( Min1 Max1 Max2 )); } elsif( ! \$diff->Items(1) ) { printf "%da%d,%dn", \$diff->Get(qw( Max1 Min2 Max2 )); } else { \$sep = "---n"; printf "%d,%dc%d,%dn", \$diff->Get(qw( Min1 Max1 Min2 Max2 )); } print "< \$_" for \$diff->Items(1); print \$sep; print "> \$_" for \$diff->Items(2); } # Alternate interfaces: use Algorithm::Diff qw( LCS LCS_length LCSidx diff sdiff compact_diff traverse_sequences traverse_balanced ); @lcs = LCS( @seq1, @seq2 ); \$lcsref = LCS( @seq1, @seq2 ); \$count = LCS_length( @seq1, @seq2 ); ( \$seq1idxref, \$seq2idxref ) = LCSidx( @seq1, @seq2 ); # Complicated interfaces: @diffs = diff( @seq1, @seq2 ); @sdiffs = sdiff( @seq1, @seq2 ); @cdiffs = compact_diff( @seq1, @seq2 ); traverse_sequences( @seq1, @seq2, { MATCH => &callback1, DISCARD_A => &callback2, DISCARD_B => &callback3, }, &key_generator, @extra_args, ); traverse_balanced( @seq1, @seq2, { MATCH => &callback1, DISCARD_A => &callback2, DISCARD_B => &callback3, CHANGE => &callback4, }, &key_generator, @extra_args, );.

 Requirements: No special requirements Platforms: Linux Keyword: Algorithmdiff,  Diff,  Discard,  Lcs,  Libraries,  Perl,  Perl Module,  Programming,  Qw,  Traverse Users rating: 0/10