in reply to how can i align two two strings

Although it looks suspiciously like home-work, it is also Sunday evening and I am feeling generous.
use strict; use Algorithm::LCSS qw( LCSS ); use Data::Dump qw /dump/; my @first_sequence = (1,2,3,6,7,9,1,-7,2,6); my @second_sequence = (7,6,7,9,12,-22,-3); my $lcss_ary_ref = LCSS( \@first_sequence, \@second_sequence ); {local $" = ','; print "The aligned sequence is @$lcss_ary_ref\n";}

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: how can i align two two strings
by Anonymous Monk on Dec 10, 2007 at 07:29 UTC
    generosity killed the cat (false buddha)
      #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use List::Compare; my $a = '1,2,3,6,7,9,1,-7,2,6'; my $b = '7,6,7,9,12,-22,-3'; my @a = split ',', $a; my @b = split ',', $b; my $lc = List::Compare->new( \@a, \@b ); my @intersection = $lc->get_intersection; print Dumper(@intersection);
      output :
      $VAR1 = '6'; $VAR2 = '7'; $VAR3 = '9';
      voilą ;)
      PooLPi