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 ????

20061009 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips


In reply to problem in assigning values to keys by tweety

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.