in reply to Re: a referencable array slice (so assigning to it modifes the original)
in thread a referencable array slice (so assigning to it modifes the original)
my @a = qw( a b c d e ); make_view( \my @v, \@a, 2, 2 ); # @v -> splice( @a, 2, 2 ); @v = qw( x y z ); print( "@a\n" ); # a b x y z e
similar to
my $a = 'abcde'; substr( $a, 2, 2 ) = 'xyz'; print( "$a\n" ); # abxyze
By the way, tie $view[$idx2], ... should be tie $view->[$idx2], ... in your code.
|
|---|