Gossamer Forum
Home : General : Perl Programming :

facing problem in pattern matching

Quote Reply
facing problem in pattern matching
i am facing problem in this particular program.
the setup of the program is like this..
its an algorithm where a pattern is searched in a particular string.
for eg:
if the string @string="BIOINFORMBIOINFORM";
if the pattern is @pat="INFO";
the program has to assign values to INFO in the reverse order,
like, I N F O shud have values 4 3 2 1.
ie., I=> 4, N=>3, F=>2, O=>1
incase if the pattern is BIOINFO, the values shud be, 5 4 1 4 3 2 1.
ie.,B=>5, I=>4,O=>1,I=>4,N=>3,F=>2,O=>1
so that each alphabet shud have a unique value in this order only.ie., in the reverse order.so, if $m wud be the scalar value of @pat=INFO, then $m=4. for BIOINFO example it shud be $m=7.The values of all the pattern elements have been assigned as above...the rest of the alpabets apart from the pattern alphabets in the string shud be assigned as $m+1.so let us take the INFO example.$m+1=5 or 4+1=5.
so, now the string values are
B=>5, I=>4, O=>1, I=>4, N=>3, F=>2,O=>1,R=>5,M=>5, B=>5, I=>4, O=>1, I=>4, N=>3, F=>2, O=>1,R=>5,M=>5.
the abv said is alphabets in KEYS and the numbers in VALUES.
how do i do this ????
Post deleted by mkp In reply to