读书人

最简单的文件行行比较为什么不行?该

发布时间: 2012-03-30 17:32:09 作者: rapoo

最简单的文件行行比较,为什么不行?
#!/usr/bin/perl


open(FILE1, "1.txt ") or die "i can 't filnd the file1!\n ";
open(FILE2, "2.txt ") or die "i can 't filnd the file2!\n ";


@a1= <FILE1> ;
@a2= <FILE2> ;

# print $#a1;
# print $#a2;

for ($i=0; $i <$#a1; $i++)
{
# $a1[$i]= chomp $a1[$i];
# $a2[$i]= chomp $a2[$i];
print $a1[$i];
print $a2[$i];

if ($a1[$i] eq $a2[$i])
{
print "ok \n ";
}
}

close (FILE1);
close (FILE);

为什么不同行都会打印OK呢。

[解决办法]
没打印成OK啊。

读书人网 >perl python

热点推荐