Most Wise and Esteemed Monks, i have the following query: Suppose i have the following in a text file: atgcatccctttaat The following line will break up the string in the file into an array where each element of the array consists of three characters of the string.(Where the string in the file has been captured in $line).
@triplets = unpack ("a3" x (length($line)/3), $line);
Now suppose i wish to change the reading frame. Consider the string once again:
atccatccctttaat
to which i obtained as array elements:
atc cat ccc ttt aat
But what if i also wish to obtain the following array elements from the same string(using a different reading frame):
tcc atc cct tta
(Discard the final at in this reading frame) And a third reading frame should give me the following array:
cca tcc ctt taa
(Discard the final t in this reading frame) Is it possible to obtain all the three different kinds of arrays i've outlined using unpack? Or would i have to turn to regex's.

In reply to variation on splitting a string into elements of an array by Anonymous Monk
in thread splitting a sequence using unpack by Rashmun

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.