Perl 脚本记录2

add_left2right.pl

#!/usr/bin/perl

open my $left,"<",$ARGV[0];
open my $right,"<",$ARGV[1];
open(OUT,">./aaa");

my @right_list = ();
while (<$right>) {
        ($a,$b,$c,$d) = split(/,/,$_);
        push @right_list,"$c,$d \n";
        }

while (<$left>) {
        ($aa,$bb,$cc,$dd) = split(/,/,$_);
        chomp($aa,$bb,$cc,$dd);
        foreach my $r (@right_list) {
                chomp($r);
                ($e,$f) = split(/,/,$r);
                if($e == $cc && $f == $dd) {
                        print OUT "$aa,$bb,$cc,$dd \n";
                }
        }
}  

你可能感兴趣的:(Perl 脚本记录2)