我正在尝试快速更改文件大小并遇到文件从未达到正确大小的问题。下面的代码是否像我认为的那样运行?主要是$|
运营商在选择$fh
还是在选择STDOUT
?
# Open file, hot buffer
open(my $fh, '>>', $file_path) ||
die 'Could not open temp file: '.$!;
$| = TRUE;
# Make file longer (div 2 because
# we print 2 at a time)
print $fh "\r\n" x ($diff / 2);
# Wait for file system to catch
# up, then close file.
sleep 1;
close $fh;