Skip to content

Instantly share code, notes, and snippets.

@JEEN
Last active December 19, 2015 12:19
Show Gist options
  • Save JEEN/5954179 to your computer and use it in GitHub Desktop.
Save JEEN/5954179 to your computer and use it in GitHub Desktop.
usage: perl ascendoly3.pl file1 file2
#!/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 $Pline = <$P>) {
$Pline =~ s/[\r\n]//g;
my @P = split(/\t/,$Pline);
$data{$P[0]} = \@P;
}
while (my $Rline = <$R>) {
$Rline =~ s/[\r\n]//g;
my @R_data = split (/\t/, $Rline);
if ($data{$R_data[0]}) {
print join("\t", @R_data, @{ $data{$P[0]} })."\n";
}
}
close ($P);
close ($R);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment