On Sep 3, Edward Wijaya said:

>@arr1 =    ('GATGGATTAAAGGAGAGGTACTTACAGG',
>             'CGCCCAAGAGGCCAGAGCGGAGCGGGGA',
>             'CGTTAATGCATTAATTTTAGTTAAAACT');
>
>    @arr2 = ('tcctcta',
>             'aggccac',
>             'agctgcg');
>
>
>Is there any efficient way to copy each element
>of @arr2 as part of each elements in @arr1
>such that it gives result:
>
>@arr3 =    ('GAtcctctaAAGGAGAGGTACTTACAGG',
>             'CGCCCAAGAGGCCAGaggccacCGGGGA',
>             'CGTTAAagctgcgATTTTAGTTAAAACT');

Use substr($str, $pos, 0, $addition) to insert $addition into $str at
position $pos.

  $a = "perl";
  $b = "t ea";
  substr($a, 2, 0, $b);
  print $a;  # "pet earl"

To get a random position, I'd use:

  substr($big, rand(length $big), 0, $small);

-- 
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to