This may be a silly question... The following code outputs the contents of @arrayref
and @arraycont
respectively. Note the difference between them
This creates a shallow copy of the array:
$arraycont[0] = [@array];
Whereas this just creates a reference to it:
$arrayref[0] = \@array;
Since you later modify the array:
@array = qw(5 6 7 8);
arrayref
still points to the same array location in memory, and so when dereferenced in the print statements it prints the current array values 5 6 7 8
.