|
An array slice can also be used as an lvalue in an assignment: @a = (10, 5, 9, 6, 17, 1);
@a[3,5,1] = qw(yes no maybe);
print "@a";
>> "10 maybe 9 yes 17 no"
In fact, because the slice can be both an lvalue and an rvalue, this is an easy way to transpose elements in-place. @a = (10, 5, 9, 6, 17, 1);
@a[0,4] = @a[4,0];
print "@a";
>> "17, 5, 9, 6, 10, 1";
|