perlquestion
fletcher_the_dog
Hi all,
I am trying to come up with a way to compare two arrays. I don't want to just find the intersection and such, I want to end up with map of where each element in the second array was derived from in the first array. Something like this:
<CODE>
my @array1=qw(I like to eat tacos);
my @array2=qw(Do you like to eat burritoes);
my @diff=get_diff(\@array1,\@array2);
@diff=(
['Do',0,0],
['you',1,0],
['like',2,1],
['to',3,2],
['eat',4,3],
['burritoes',5,4]
);
</CODE>
Note that if one element appears to have replaced another such as "burritoes" replaces "tacos", those elements are mapped together.
I was wondering if there was some module out there that did something like this. I have been playing around with different algorthims, but I wanted to be sure I am not just reinventing the wheel.