#!/usr/bin/perl use strict; my $fh; my %i; open ( $fh, '<', "t1" ) or die $!; while ( <$fh> ) { chomp; split /\s+/; $i{$_[0]} = $_[-1]; } close $fh; open ( $fh, '<', "t2" ) or die $!; while ( <$fh> ) { chomp; split /\s+/; $_[-1] = $i{$_[0]} if defined ($i{$_[0]}); print join ("\t", @_) , "\n"; } close $fh; |
原帖由 dl0622 于 2008-10-18 09:07 发表
楼上,$line2{$fields1[0]}[$#fields1] = $fields1[-1];
如果我想取$line2{$fields1[0]}的第n个字段是不是这样:$line2{$fields1[0]}[n-1]???
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |