我想输出到一个文件,使用来自另一个文件的输入。没有键盘输入。输出到一个文件,使用来自另一个文件的输入
我知道我在正确的轨道上,我的语法只是一点点关闭。
基本上,我从文件“boot.log”中取出记录,使用模式匹配选择某些记录并将它们输出到名为“bootlog.out”的文件中。我还没有得到模式匹配部分。这是我的...
open (BOOTLOG, "boot.log") || die "Can't open file named boot.log: $!";
while ($_ = <BOOTLOG>)
{
print $_;
}
open (LOGOUT, ">bootlog.out") || die "Can't create file named bootlog.out: $!\n";
close (LOGOUT) || die "Can't close file named bootlog.out: $!\n";
close (BOOTLOG) || die "Can't close the file named boot.log: $!";
如何将boot.log的内容打印到bootlog.out?
EDIT1
这似乎采取输入和输出到第二个文件。语法是否正确?
open (BOOTLOG, "boot.log") || die "Can't open file named boot.log: $!";
open (LOGOUT, ">bootlog.txt") || die "Can't create file named bootlog.out: $!\n";
while ($_ = <BOOTLOG>)
{
print $_;
print LOGOUT $_;
}
close (LOGOUT) || die "Can't close file named bootlog.txt: $!\n";
close (BOOTLOG) || die "Can't close the file named boot.log: $!";
始终:'使用严格的;使用警告;'。 – Kenosis