Something like this might be what you're looking for:
#! perl -slw use strict; sub common { die 'Bad args' unless @_ == 2; my $output = $_[ 0 ] ^ $_[ 1 ]; $output =~ s[([^\0]+|[\0]+)]{ my $p = $-[0]; my $l = $+[0] - $-[ 0 ]; ord( $1 ) == 0 ? substr( $_[ 0 ], $p, $l ) : join '', map{ '[' . substr( $_, $p, $l ) . ']' } @_ }ge; return $output; } while( my $str1 = <DATA> ) { my $str2 = <DATA>; print common( $str1, $str2 ); } __END__ a11211b123 a11222b123 The quick brown fox jumps over the lazy dog the quiet green fir looms over the lazy dog Send reinforcements; we're going to advance Send 3 and sixpence; we're going to a dance Time flies like an arrow Dung flies like a brick
Output:
c:\test>junk1 a112[11][22]b123 [T][t]he qui[ck][et] [b][g]r[ow][ee]n f[ox][ir] [jump][loom]s over the + lazy dog Send [rei][3 a]n[forcem][d sixp]en[ts][ce]; we're going to a[dv][ d]an +ce [Time][Dung] flies like a[n][ ] [a][b]r[row][ick]
Not sure about the usefulness of the output format though.
In reply to Re: Finding Overlapping between 2 strings
by BrowserUk
in thread Finding Overlapping between 2 strings
by typsy_in
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |