Last active
December 19, 2015 12:19
-
-
Save JEEN/5954265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my $file1 = $ARGV[0]; | |
my $file2 = $ARGV[1]; | |
open my $R, "<", $file1 or die ("Could not open $file!"); | |
open my $P, "<", $file2 or die ("Could not open $file!"); | |
my %data = (); | |
while (my $Rline = <$R>) { | |
$Rline =~ s/[\r\n]//g; | |
my @R_data = split (/\t/, $Rline); | |
push @{ $data{$R_data[0]} }, \@R_data; | |
} | |
while (my $Pline = <$P>) { | |
$Pline =~ s/[\r\n]//g; | |
my @P = split(/\t/,$Pline); | |
if (scalar @{ $data{$P[0]} }) { | |
for my $row (@{ $data{$P[0]} }) { | |
print join("\t", @{ $row }, @P)."\n"; | |
} | |
} | |
} | |
close ($P); | |
close ($R); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment