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";
                }
        }
}  
    原文作者:夏秋之萌
    原文地址: https://www.jianshu.com/p/1505f38e34af
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞