Hi guys,

As the title says, what I wanted to do is take one DNA file and put it into an array, do the same to a second DNA file and then insert one of the files somewhere in the other.

I have 2 files, DNA3 and DNA4

The content within the DNA3 file is: ATCGC

The content within the DNA4 file is: AAATTGC

What I want to do is to insert DNA4 into position #1 in DNA3, so the result would look like this: AAAATTGCTCGC

Currently my code looks like this:

#!/usr/bin/perl -w $DNA3file = 'testDNA3'; open(DNA3handle, $DNA3file); @DNA3 = <DNA3handle>; $DNA4file = 'testDNA4'; open(DNA4handle, $DNA4file); @DNA4 = <DNA4handle>; splice (@DNA3, 1, 0, @DNA4); print @DNA3, "\n"; exit;

However, what is displayed really puzzled me:

ATCGC

AAATTGC

*Note, in my complier there isn't the space in between the output*

For the life of me I can't figure out what is wrong, I can run the above operation fine if I manually insert the DNA sequences into an array, but for large DNA set that is simply not possible. Really appreciate any help here, thanks for your time!


In reply to Splice an array into another array by Smeb

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.