in reply to Splice an array into another array

@DNA3 = <DNA3handle>; creates an array with one member containing "ATCGC" and any line endings.

use strict; use warnings; my $dna3='ATCGC'; my $dna4='AAATTGC'; my $after=0; $dna3=substr($dna3,$after,1).$dna4.substr($dna3,$after+1); print $dna3."\n";

Replies are listed 'Best First'.
Re^2: Splice an array into another array
by AnomalousMonk (Archbishop) on Jun 23, 2017 at 23:10 UTC

    Could also be:

    c:\@Work\Perl\monks>perl -wMstrict -le "my $dna3 = 'ATCGC'; my $dna4 = 'AAATTGC'; ;; my $offset = 1; substr $dna3, $offset, 0, $dna4; print qq{'$dna3'}; " 'AAAATTGCTCGC'

Re^2: Splice an array into another array
by Smeb (Novice) on Jun 23, 2017 at 22:54 UTC

    Thanks for the reply, really appreciate it.

    So are you saying that, I cannot store DNA files I downloaded from Genbank as arrays via the filehandler, and then modify them? Because all of the example I have seen where people modify arrays (in my case I am obviously interested in the splice function) amounts to the user manually type in some elements, store them as array and then modify them (like the code you provided).

      Let me try again

      @DNA3 = <DNA3handle>; creates an array where the contents of each line of DNAHANDLE (along with any line endings) becomes its own element of the array

      It is not an array where each element is a single character of the file

      @DNA3 = <DNA3handle>; chomp @DNA3; @DNA3=split('',join('',@DNA3));
      Would be that kind of array (without line endings (chomp))

        THANK YOU!!! If I could give you a kiss over the monitor I would, thank you so much for your explanations(+ others as well), you have no idea how much you helped me. Once again thanks for the solutions, you are the best!