- 论坛徽章:
- 0
|
1.txt的内容:
1320238
1320239
1320239
1320238
1320238
1320238
1320235
1320237
txt.2的内容:
102 5709072117805887 4001 1301854
102 5709072117807510 4001 1320292
102 5709072117838653 4001 1301857
102 5709072117814280 4001 1305832
102 5709072117839397 4001 1310673
102 5709072117839335 4001 1311270
我想先把文件1的内容读取出来,然后读取文件二的内容,在读取文件2的内容的时候,文件2的最后一列需要包含在上文件1内。
我的代码是这样:
#/usr/bin/perl
use strict;
use warnings;
my @line;
my $column4;
my %hash;
open (TWO,"$ARGV[1]") || die $!;
while (<TWO>)
{
chomp;
@line=split;
$column4=$line[3];
$hash{$column4}=$_;
}
open (ONE,">>$ARGV[0]") || die $!;
while (<ONE>)
{
chomp;
print $hash{$_} if defined $hash{$_};
print "/n";
}
但是运行之后, 1.txt什么反应也没有。什么地方有错吗? |
|