- my %hash;
- my @arr;
- my $j;
- foreach ( &loadf("1.txt") ) {
- $hash{$1}=$2 if /(.*)\|(.*)\n/;
- }
-
- open WRT,">:raw:crlf","3.txt" or warn "$!";
- foreach ( &loadf("2.txt") ) {
- foreach $j (keys %hash) {
- if (/^$j/) {
- s/\n?$/\|$hash{$j}\n/;
- print WRT $_;
- }
- }
- }
- close WRT;
-
- sub loadf {
- open READ,"<:raw:crlf", shift or warn "$!";
- @all=<READ>;
- close READ;
- return @all;
- }
复制代码
|