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.
|