Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hi PerlMonks,

I have a string like "ATCGGCGCCTAT" consisting of four 3-letter words (ATC,GGC,GCC,TAT). I am interested to count the number and the kinds of letters (A,T,G,C) at 1st, 2nd and 3rd positions of these four words. I am a beginner in perl programming. I shall be glad if any perl monk can help me by providing the syntax/perl code that can count letters and their kinds in 1st, 2nd and 3rd position of 3-letter words. Separate scalar variable may be used for each position and letter. For instance, for the 1st position the scalar variables may be $A1, $T1, $G1 and $C1. Similarly, for 2nd the scalar variables may be $A2,$T2,$G2,$C2 and for 3rd position $A3,$T3,$G3 and $C3.

#!usr/bin/perl-w $a="ATCGGCGCCTAT"; code?? print" Letters at 1st position:\n A1=$A1; T1=$T1; G1=$G1; C1=$C1; \n Letters at 2nd position:\n A2=$A2; T2=$T2; G2=$G2; C2=$C2; \n Letters at 3rd position:\n A3=$A3; T3=$T3; G3=$G3; C3=$C3; \n"; exit;

Expected results are:

The result of counting from the string should look like: Letters at 1st position: A1=1; T1=1; G1=2; C1=0; Letters at 2nd position: A2=1; T2=1; G2=1; C2=1; Letters at 3rd position: A3=0; T3=1; G3=0; C3=3;

In reply to How can I count the number and kinds of letters at 1st, 2nd and 3rd positions of 3-letter words in a string? by supriyoch_2008

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (12)
    As of 2015-11-30 16:31 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (777 votes), past polls