I can only echo the bemusment of the others in saying that your call to splice seems to be coded correctly and that the problem must lie with the code you aren't showing us.

#! perl -slw use strict; my @blocks = ( [ ['A1',1,2,3,4,5,6], ['B1',1,2,3,4,5,6], ['C1',1,2,3,4,5,6], ['D +1',1,2,3,4,5,6], ], [ ['A2',1,2,3,4,5,6], ['B2',1,2,3,4,5,6], ['C2',1,2,3,4,5,6], ['D +2',1,2,3,4,5,6], ], [ ['A3',1,2,3,4,5,6], ['B3',1,2,3,4,5,6], ['C3',1,2,3,4,5,6], ['D +3',1,2,3,4,5,6], ], [ ['A4',1,2,3,4,5,6], ['B4',1,2,3,4,5,6], ['C4',1,2,3,4,5,6], ['D +4',1,2,3,4,5,6], ], [ ['A5',1,2,3,4,5,6], ['B5',1,2,3,4,5,6], ['C5',1,2,3,4,5,6], ['D +5',1,2,3,4,5,6], ], ); my @new_vertex = ('N1',1,2,3,4,5,6); my $nv_blockn = 2; my $nv_pos = 2; splice @{ $blocks[$nv_blockn] }, $nv_pos, 0, \@new_vertex ; { local $" =','; #" print qq[[ @{[ map{ "[@$_]" } @$_ ]} ],] for @blocks; } __END__ C:\test>252393.pl [ [A1,1,2,3,4,5,6],[B1,1,2,3,4,5,6],[C1,1,2,3,4,5,6],[D1,1,2,3,4,5,6] +], [ [A2,1,2,3,4,5,6],[B2,1,2,3,4,5,6],[C2,1,2,3,4,5,6],[D2,1,2,3,4,5,6] +], [ [A3,1,2,3,4,5,6],[B3,1,2,3,4,5,6],[N1,1,2,3,4,5,6],[C3,1,2,3,4,5,6], +[D3,1,2,3,4,5,6] ], [ [A4,1,2,3,4,5,6],[B4,1,2,3,4,5,6],[C4,1,2,3,4,5,6],[D4,1,2,3,4,5,6] +], [ [A5,1,2,3,4,5,6],[B5,1,2,3,4,5,6],[C5,1,2,3,4,5,6],[D5,1,2,3,4,5,6] +],

When I'm trying to track down bugs and logic errors that I simply cannot seem to find, I often resort to writing a new script that has just the minimum required to demonstrate the effect I am trying to acheive. And I really do tend to code this from scratch rather than trying to cut down the original to its minimum, as this often clarifies the problem in my logic as I do so. With the bonus that if my logic is wrong, I can play with the small script until I get it right, and if I can't get it to work, or if I really have found a bug, it serves as a self contained demonstration when requesting help or reporting the bug.

The small sample above took just a few minutes to generate...actually less time than typing this post:). Maybe it will clarify something for you.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

In reply to Re: inserting a list into an array by BrowserUk
in thread inserting a list into an array by stu96art

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.