Array::Splice - Splice aliases into arrays
use Array::Splice qw( splice_aliases push_aliases ); my @a = qw( foo bar ); my $x = 'baz'; splice_aliases @a,1,0,$x; $x = 'zoop'; # Changes $a[1] print "@a\n"; # foo zoop bar sub wrapped_foo { push_aliases my @args => @_; # Copy @_ some_wrapper(sub { foo @args }); # &foo called with orginal arguments }
This module does splicing of arrays for real. That is does exactly the same as the builtin splice function except that the inserted elements are existing scalar values not copies of them.
splice
One possible use of this is to copy the @_ array but I'm sure that there are others.
This module does not export anything by default.
Exactly like the builtin splice except that the scalar values that are the elements of LIST get spliced directly into ARRAY rather being copied. Unlike the builtin splice OFFSET and LENGTH are not optional since if you are not giving LIST then splice_aliases is just exactly the same as splice.
splice_aliases
This is unlikely to be useful for tied arrays but for the sake of uniformity, splice_aliases() tries to call a SPLICE_ALIASES() method on the object to which the array is tied.
A wrapper for splice_aliases that emulates the builtin push except that LIST gets spliced directly into ARRAY rather being copied.
push
A wrapper for splice_aliases that emulates the builtin unshift except that LIST gets spliced directly into ARRAY rather being copied.
unshift
As of Perl 5.8.9 Data::Alias works on all platforms. That largely renders this module obsolescent. On the other hand this module does not employ any of the deep black magic that Data::Alias uses.
The value of $[ is ignored because it works differently in 5.10 from it did previously and since nobody should be using it anyhow there's no point making an effort to support it.
$[
Brian McCauley, <nobull@cpan.org>
"splice" in perlfunc, Data::Alias.
To install Array::Splice, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Array::Splice
CPAN shell
perl -MCPAN -e shell install Array::Splice
For more information on module installation, please visit the detailed CPAN module installation guide.