http://www.perlmonks.org?node_id=805913


in reply to How do I insert an element into an arbitrary (in range) array index?

#!/usr/bin/perl -w use warnings; use strict; use 5.10.0; my @in_array = qw(A B C E F G); my @out_array; my $insert = 'D'; push @out_array, @in_array[0..2], $insert, @in_array[3..5]; say join (', ', @in_array); say join (', ', @out_array); exit;
I think this approach is the most human-readable. By the way, it doesn't use splice with its performance issues.