in reply to Updating arrays within hashes

For each iteration, only one of the if/else branches is executed.

If the items shows up in both arrays, the two array references must be references to the same array. Compare:

# two distinct array refs: $ perl -wE 'my $a = [1]; my $b = [1]; push @$a, 2; say for @$b' 1 # same array ref twice: $ perl -wE 'my $a = [1]; my $b = $a; push @$a, 2; say for @$b' 1 2

In the second case, both $a and $b point to the same array reference, so that pushing to one adds the value to the other.