Search notes:

Perl module Algorithm::Diff

use warnings;
use strict;

use Algorithm::Diff;


my @seq_a = qw(       a x b y c z p d q 1 2 3 4 ! 5 6 7);
my @seq_b = qw( a b c a x b y c z       1 2 3 4 ? 5 6 7);

#
#  Turn seq_a into seq_b
#
#  This is the array that will contain
#  the same values as @seq_b:

my @seq_B = ();


#
#  new computes the smallest set of additions and deletions
#  necessary to turn the first sequence into the second.
#
my $diff = Algorithm::Diff->new(\@seq_a, \@seq_b);

while (my $hunk =   #  A hunk represents a contiguous section
                    #  of items which should be added, deleted
                    #  replaced, or left unchanged.
                    #  ---------------------------------------

           $diff -> Next()

      ) {

     print "\n";

  #  ----------------------------------

     print "$hunk: $hunk ";

     print "Diff: ", $diff->Diff(), " ";

     print "Same " if $diff->Same();

     print "\n";

     my @items_a = $diff -> Items(1);
     my @items_b = $diff -> Items(2);

     push @seq_B, @items_b;

     print "  A: " . (join "-", @items_a) . "\n";
     print "  B: " . (join "-", @items_b) . "\n";
}

print "------------------------\n";

print ((join "-", @seq_b),"\n");
print ((join "-", @seq_B),"\n");
Github repository PerlModules, path: /Algorithm/Diff/script.pl

See also

Algorithm: merging two (sorted) files
Perl module Sort::Merge
Perl modules

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1744801358, '3.147.81.79', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Algorithm/Diff/index(101): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78