搜 索
您现在的位置: 凯世软件学院 >> 技术开发 >> CGI 学院 >> 文章正文
  最新热门
  业界新闻
  业界新闻
 
 

怎样一次打印多个文件

作者:佚名    文章来源:网络    点击数:    更新时间:2006-8-18


如果你仅仅想一次打印多个文件,你可以这样做:
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写的,它提供了更强大的功能。
(出处:风闪网路学院)

  • 上一个文章: