下面的代码尝试更改24小时,但它失败了,执行后的原始文件变为空...并且out文件没有得到24,仍然保持小时
rename($file, $file . '.bak');
open(IN, '<' . $file . '.bak') or die $!;
open(OUT, '>' . $file) or die $!;
while ( <IN> ) {
s/nhours/24/g;
print OUT $_;
@args = ("$rundir/upp/run_unipost.bak");
escriu(@args);
system(@args) == 0 or die "system @args failed: $?";
}
close(IN);
close(OUT);
sub escriu {
my @missatge = @_;
chomp (my $hora = `date |awk '{print \$4}'`);
print "-----> $hora @missatge\n";
}
和run_unipost.bak
执行一个过程。
我能够测试的代码完全符合预期。所以看起来问题出在我无法测试的位中。
escriu()
做了什么。run_unipost.bak
做了什么。