top
Loading...
怎樣一次打印多個文件
如果你僅僅想一次打印多個文件,你可以這樣做:
for $fh (FH1, FH2, FH3) { print $fh "whatever" }
連接一個到多個文件句柄的最簡單的方法是使用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: $!";
    print "whatever"            or die "Writing: $!";
    close(STDOUT)              or die "Closing: $!";
否則,你就只有自己寫個多行打印的程序了(你自己的tee程序)。你也可以使用Tom Christiansen 的程序,http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz 。這個程序是用perl寫的,它提供了更強大的功能。
北斗有巢氏 有巢氏北斗