Algorithm-HowSimilar
view release on metacpan or search on metacpan
HowSimilar.pm view on Meta::CPAN
the default tokenization of strings (a simple split on null) to whatever you
need. The strings are passed to you callback in $_ and the sub is expected to
return an array ref. So for example to ignore all
whitespace you could:
@res = compare( 'this is a string',
'this is a string ',
sub { s/\s+//g; [split //] }
);
You already get the intersection of the strings or arrays. You can get the
union like this:
@res = compare( $str1, $str2 );
$intersection = $res[3];
$union = $res[3].$res[4].$res[5];
@res = compare( \@ary1, \@ary2 );
@intersection = @{$res[3]};
@union = ( @{$res[3]}, @{$res[4]}, @{$res[5]} );
=head2 EXPORT
None by default.
=head1 AUTHOR
Dr James Freeman <james.freeman@id3.org.uk>
html/HowSimilar.html view on Meta::CPAN
<P>When called with two string you can specify an optional callback that changes
the default tokenization of strings (a simple split on null) to whatever you
need. The strings are passed to you callback in $_ and the sub is expected to
return an array ref. So for example to ignore all
whitespace you could:</P>
<PRE>
@res = compare( 'this is a string',
'this is a string ',
sub { s/\s+//g; [split //] }
);</PRE>
<P>You already get the intersection of the strings or arrays. You can get the
union like this:</P>
<PRE>
@res = compare( $str1, $str2 );
$intersection = $res[3];
$union = $res[3].$res[4].$res[5];
@res = compare( \@ary1, \@ary2 );
@intersection = @{$res[3]};
@union = ( @{$res[3]}, @{$res[4]}, @{$res[5]} );</PRE>
<P>
<H2><A NAME="export">EXPORT</A></H2>
<P>None by default.</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Dr James Freeman <<A HREF="mailto:james.freeman@id3.org.uk">james.freeman@id3.org.uk</A>></P>
<P>
<HR>
( run in 0.636 second using v1.01-cache-2.11-cpan-39bf76dae61 )