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 ?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.