for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }
連接一個到多個文件句柄的最簡單的方法是使用tee(1)程序(如果你有的話),讓它來處理復雜的事情。
open (FH, "| tee file1 file2 file3");
甚至這樣寫:
# make STDOUT go to three files, plus original STDOUT
open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
print "whatever\n" or die "Writing: $!\n";
close(STDOUT) or die "Closing: $!\n";
否則,你就只有自己寫個多行打印的程序了(你自己的tee程序)。你也可以使用Tom Christiansen 的程序,http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz 。這個程序是用perl寫的,它提供了更強大的功能。
文章來源于領測軟件測試網 http://www.kjueaiud.com/