该程序不会打印字符串是否相等,但是当它们打印时,它们似乎是相同的......请有人解释一下
#!/usr/bin/perl
$str = "print \"I want this to work\\n\";";
print $str."\n";
open FILE, "<", "check2.doc" or die "buhuhuhu";
my $str2;
while (<FILE>) {
$str2 = $_;
}
close FILE;
print "$str2\n";
if ( $str eq $str2) {
print "they are equal\n";
但是当输出出现时,由于第二个字符串 $str2 在底部有这条额外的行
print "I want this to work\n";
print "I want this to work\n";
-----empty line-----
这是文件 check2.doc
print "I want this to work\n";
有谁知道他们为什么不相等???