Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 13th, 2005, 4:23 AM   #1
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 3 ktsirig is on a distinguished road
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...
ktsirig is offline   Reply With Quote
Old Dec 13th, 2005, 6:35 AM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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?
__________________

tempest is offline   Reply With Quote
Old Dec 13th, 2005, 7:38 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Dec 13th, 2005, 9:00 AM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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!
Pizentios is offline   Reply With Quote
Old Dec 20th, 2005, 1:01 PM   #5
eclipsed4utoo
Newbie
 
Join Date: Dec 2005
Posts: 7
Rep Power: 0 eclipsed4utoo is on a distinguished road
i would use the substitution method and then compare the two files.
eclipsed4utoo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC