http://www.perlmonks.org?node_id=1011019

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

I have a requirement of matching the files installed in different environments and do some operation based on that. For eg: Lets say I have a file called  domains/abcd/xyz/1.txt. In two different installed environments, this file is available at
env 1 :
 /home/instance/domains/abcd/xyz/1.txt
env 2 :
 /a1234/domains/abcd/xyz/1.txt
paths. Now I have the env 3 in which I have this file at  /a1234/topfolder/instance/domains/abcd/xyz/1.txt
If observed, the three environments have the identical file installed in different parent folders. So my question is how can I determine that  /a1234/topfolder/instance/domains/abcd/xyz/1.txt is identical to  /home/instance/domains/abcd/xyz/1.txt and  /a1234/domains/abcd/xyz/1.txt. My idea is that if I can find the longest common substring of above three filenames, I can have the solution to my requirement. Is there any API available in perl to find longest common substring of two strings? or is there any other solution ?