#!/usr/bin/perl -w use strict; my @filenames=glob ("*.*");#收集文件
my @strs;#文件数组 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;
|