电竞比分网-中国电竞赛事及体育赛事平台

分享

寫入多個(gè)文件perl腳本

 ddlld345 2015-02-12

#!/usr/bin/perl -w
use strict;
my @filenames=glob ("*.*");#收集文件

my @strs;#文件數(shù)組
sub pushfile { #push文件子程序
   my $filename=shift;
   my @file;
   open(IFH,$filename) or die "Cann\'t open the file:$!";
   while (@file=<IFH>) {
      push @strs,"$filename\n\n";#push文件名
      push @strs,"@file\n\n";
   }
   close IFH;
}
foreach (@filenames){#push文件
   &pushfile($_);
}
open(OFH,"> a.txt") or die "Cann\'t open the file:$!";
foreach (@strs){
   print OFH $_;
}
close OFH; 

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多