我试图打印@ arr3范围内的值,它们位于@ arr4(不包括在arr4的范围内)范围之外,但我没有得到所需的输出。请建议我在下面的代码修改,以获得输出1,2,8,13(不重复的值如果有的话)如何匹配超出范围的数字
文件1:导致
1..5
5..10
10..15
文件2:注释
3..7
9..12
14..17
代码:
#!/usr/bin/perl
open($inp1, "<result") or die "not found";
open($inp2, "<annotation") or die "not found";
my @arr3 = <$inp1>;
my @arr4 = <$inp2>;
foreach my $line1 (@arr4) {
foreach my $line2 (@arr3) {
my ($from1, $to1) = split(/\.\./, $line1);
my ($from2, $to2) = split(/\.\./, $line2);
for (my $i = $from1 ; $i <= $to1 ; $i++) {
for (my $j = $from2 ; $j <= $to2 ; $j++) {
$res = grep(/$i/, @result); #to avoid repetition
if ($i != $j && $res == 0) {
print "$i \n";
push(@result, $i);
}
}
}
}
}