Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Splice an array into another array

by AnomalousMonk (Archbishop)
on Jun 23, 2017 at 23:21 UTC ( [id://1193418]=note: print w/replies, xml ) Need Help??


in reply to Splice an array into another array

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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1193418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found