![]() |
Perl substrings
Hello everybody,
I have been dealing with this problem in PERL a few days now, and it has get into my nerves, so, if anyone has a hint on how to procceed, it would be more than welcome. Say you have one file that contains a sequence of letters, eg : SGFEFHGYARSGVIMNDSGASTKSGAYITPAGETGGAIGRLGNQADTYVEMNLEHKQTLDN [file 1] the same sequence is also in the [file 2], but, with "." and "-" in it, like: ...---SGFEF....HG-.--YARSGVI---MNDSGAS..--TKSGAY--....--ITPAG--ETGGAI..GRLGN--Q..AD---TY--V..EMNL--EHKQTLDN [file 2] Let's say I want to check how two substrings (namely SGASTK and GNQADT) have become in file 2 compared to what they were in file1. I see that SGASTK, that was substring 19-24 in file1 is now SGAS..--TK and substring 36-41. GNQADT which was substring 42-48 in file1 is now GN--Q..AD---T and substring 76-82. My question is how can i find the old substrings from file 1 in file 2 and how can i store the new begginings and endings of the new substrings in file2... |
I have no clue.
So, did you think of this problem yourself or is it a homework problem which the Forum Rules forbid you from posting? |
Well, your description of what you need absolutely sucks. If I understand you, I would pull off the seach for the garfled substring by treating '.' and '-' as nonexistent symbols (ignored in comparisons), find the substring, and Bob's yer auntie. If it's homework, and you're explaining it jus' lak de teacher did, run like hell.
|
yeah DaWei is about right, just strip off the . and -. Then it's really just a simple regular expression search.
i doubt that this is a homework question, since there are ~very~ few schools that teach perl. |
i would use the substitution method and then compare the two files.
|
| All times are GMT -5. The time now is 4:08 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC