splice operates on array elements. 'ATCGC' is a string in Perl, not an array. A string can be converted into an array and operated on as such, but in this case it seems like a lot of wasted motion:
c:\@Work\Perl\monks>perl -wMstrict -le
"use Test::More 'no_plan';
use Test::NoWarnings;
;;
my $DNA3 = 'ATCGC';
my @DNA3 = split '', $DNA3;
;;
my $DNA4 = 'AAATTGC';
my @DNA4 = split '', $DNA4;
;;
my $offset = 1;
splice @DNA3, $offset, 0, @DNA4;
my $newDNA3 = join '', @DNA3;
;;
is $newDNA3, 'AAAATTGCTCGC', 'array splice ok';
;;
done_testing;
"
ok 1 - array splice ok
1..1
ok 2 - no warnings
1..2
Give a man a fish: <%-{-{-{-<
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.