Hi,

there is something I do not understand.
I reduced the code to a minimal case.

If I do:
    my $a = 23;
    my $b = $a;   # copy
    $a = 42;
    say $b;   # 23
$b is 23,
and if I do:
    my $a = 23;
    my $b := $a;   # reference
    $a = 42;
    say $b;   # 42
$b is 42 because it is just a reference to $a.

But if I do:
    my @arr = (23, 42);
    my $temp = @arr[0];   # copy?
    @arr[0] = @arr[1];
    say $temp;   # 42
$temp is 42 ...
I expected $temp to be 23 here.

Am I missing something?

Regards,
Frederik

Reply via email to