in reply to Finding Overlapping between 2 strings

This is my first adventure with Algorithm::Diff, so perhaps it isn't the best use of the module

use Algorithm::Diff; say diff_str( qw/xa11211b123 a11222b123x/ ); sub diff_str { my $diff = Algorithm::Diff->new( map { [ split // ] } @_ ); my $diff_str = ''; while ( $diff->Next ) { my ($h1, $h2) = map { join "", $diff->Items( $_ ) } 1, 2; $diff_str .= $diff->Diff ? "[$h1][$h2]" : $h1; } return $diff_str; } #Output: [x][]a112[11][22]b123[][x]


Unless I state otherwise, all my code runs with strict and warnings