In the following C# code:
int[] X = new int[2];
X[0] = 1;
X[1] = 2;
int[] Y = X;
X[1] = 3;
After this executes, Y[1] will also be 3 since the operation Y = X does not do a clone but rather assigns the reference or pointer of what X is pointing at to Y.
If the same operation is tried under Perl 5:
my @X = (1, 2);
my @Y = @X;
$X[1] = 3;
Unlike C#, Y[1] is not 3, but still 2, which indicates that Perl makes a copy of the array after the @Y = @X operation.
So, my question is - is there any way to assign or initialize a Perl 5 array with the reference of another Perl array so that they both point to the same data? I already know about references and have tried dereferencing a reference to an array, but that too makes a copy. I'm also aware that using a reference to an array will solve most of what I'm trying to do, so I don't need any answers showing how to work with references.