|

楼主 |
发表于 2012-4-6 21:20:25
|
显示全部楼层
回复 1# daiyijun
合并两个文件夹中的内容至一个文件夹#!/usr/bin/perl
use strict;
use warnings;
open a,"a.txt" or die "cannot open the file $!";
open b,"b.txt" or die "cannot open the file $!";
open c,"c.txt" or die "cannot open the file $!";
my @b_1;
while(<b>){
push @b_1, $_;
}
my @a_1;
my $line;
while ($line=<a>){
$line=~/\n/ /g;
push @a_1,$line;
}
my $len;
$len=@a_1>@b_1?@a_1 b_1;
for(my $i=0;$i<$len;$i++){
if (defined $a_1[$i] && defined $b_1[$i]){
$a_1[$i]=$a_1[$i].$b_1[$i];
}
}
print c @a_1; |
|