- 论坛徽章:
- 0
|
- #! /usr/bin/perl
- use warnings;
- use strict;
- my %hash;
- my ($b_min,$b_max,$c_min,$c_max);
- open my $fh_a,"<","a.unl" or die "Cannot open file:$!\n";
- open my $fh_b_in,"<","b.unl" or die "Cannot open file:$!\n";
- open my $fh_b_out,">","new1.unl" or die "Cannot write file:$!\n";
- open my $fh_c_in,"<","c.unl" or die "Cannot open file:$!\n";
- open my $fh_c_out,">","new2.unl" or die "Cannot write file:$!\n";
- while (<$fh_a>) {
- chomp;
- $hash{$_} = substr((split /\|/)[0],0,3);
- }
- while(<$fh_b_in>) {
- ($b_min,$b_max) = (split /\|/);
- for (keys %hash) {
- if ( $hash{$_} >= $b_min and $hash{$_} <= $b_max ) {
- print $fh_b_out "$_\n";
- }
- }
- }
- while(<$fh_c_in>) {
- ($c_min,$c_max) = (split /\|/);
- for (keys %hash) {
- if ( $hash{$_} >= $c_min and $hash{$_} <= $c_max ) {
- print $fh_c_out "$_\n";
- }
- }
- }
复制代码 晕了,好像打开的句柄数比较多~~ |
|