http://qs1969.pair.com?node_id=263238

anjiro has asked for the wisdom of the Perl Monks concerning the following question:

Given two lists, such as
@a = qw(fred bob joe jim mary elaine); @b = qw(frank joe jim mary bob);
What's the best way to find the largest subset of @b in @a? Here I mean the largest ordered subset: (joe, jim, mary) would be correct, but (bob, joe, jim, mary) would not.

The best (read "easiest") solution I could come up with is to join(',', @a) and then join(',', @b[$start..$end]), and then use the index function to see if (and where) the join from @b occurs in the join from @a. There must be some perl magic to do this in a more clean, faster way.

And yes, I know that what I'm asking is of quite high computational complexity. Thanks for any suggestions!