![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Posts: 54
Rep Power: 3
![]() |
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... |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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?
__________________
|
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
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.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Dec 2005
Posts: 7
Rep Power: 0
![]() |
i would use the substitution method and then compare the two files.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|