Hello list, Could someone please explain why this test script:
my @arr1 = qw(one two three); my @arr2 = qw(1 2 3); foreach my $arr1 ( @arr1 ) { print "Arr1: $arr1\n"; foreach my $arr2 ( @arr2 ) { print "Arr2: $arr2\n"; if ( $arr2 eq '2' ) { shift @arr1; } } } produces that result: oracle:/opt/data/magna/wartung/work/nora> ./test.pl Arr1: one Arr2: 1 Arr2: 2 Arr2: 3 Arr1: three Arr2: 1 Arr2: 2 Arr2: 3 whereas I had expected the output to be like this: oracle:/opt/data/magna/wartung/work/nora> ./test.pl Arr1: one Arr2: 1 Arr2: 2 Arr2: 3 Arr1: two # why not? Arr2: 1 # why not? Arr2: 2 # why not? Arr1: three Arr2: 1 Arr2: 2 Arr2: 3 Thanks in advance! Regards, Nora