in reply to Array looping
Are you working in a sub? my ($array1ref, $array2ref) = @_; indicate that yes you are in a sub.
You do not need to copy your array as in my @array1 = @$array1ref; .. you can simply use @$array1ref
Finally to loop over two arrays you simply foreach my $el ( @arr1, @arr2) { ... so foreach my $element (@$array1ref, @$array2ref) {
or using the ref passed into the sub directly foreach my $element (@$_[0], @$_[1]) { will suffice if you as asked need to loop over two arrays simoultanely.
But you code seems to loop over the first array1 element AND foreach element of array2 to check they are equal. So you just do not need the else block.
If arrays are of the same lenght you can loop indexes instead (or use Data::Compare as yet suggested elsewhere)
foreach my $in (0..$#array2) { $count++ if $array1[$in] eq $array2[$in +]
L*
|
---|