i am trying to compare values of range from @arr3 with values of range from @arr4 but i am not getting the desired output. please suggest me the modifications in the following c
Use a hash:
my @arr3 = (1..5, 5..10, 10..15); my @arr4=(3..7, 9..12, 14..17); my (%nums1, %nums2); $nums1{$_} = 1 foreach(@arr3); $nums2{$_} = 1 foreach(@arr4); foreach (sort { abs $a <=> abs $b} keys %nums1){ print "$_\n" if exists $nums2{$_} }