in reply to Array references inside a subroutine

The lines
my @arr1 = @{$r1}; my @arr2 = @{$r2};
are derefencing the array references, and making copies of them. You are then in turn modifying the local copy of the array.
Modifying it using
$r2->[1] = "q";
should do the trick.

Update: $$r2[1] = "q"; will also work. It is your preference.