linseyr has asked for the wisdom of the Perl Monks concerning the following question:
Could somebody help me do this on a faster way? Thanks!my $file1 = $ARGV[0]; my $file2 = $ARGV[1]; open(first_file,'<', $file1) or die $!; my @FILE1 = <first_file>; close(first_file); open(sec_file,'<', $file2) or die $!; my @FILE2 = <sec_file>; close(sec_file); @RESULTS; for my $line(@FILE1){ my($ID, @values) = split("\t", $line); for my $sec_line(@FILE2){ my($ID2, @values2) = split("\t", $sec_line); if($ID eq $ID2){ push (@RESULTS, "$ID @values @values2"); } } } open(RESULTS,'>','results.txt') or die $!; foreach(@results){ print RESULTS "$_\n"; } close(RESULTS);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Join files using perl
by AnomalousMonk (Archbishop) on Jan 11, 2013 at 20:03 UTC | |
|
Re: Join files using perl
by Cristoforo (Curate) on Jan 11, 2013 at 20:17 UTC | |
|
Re: Join files using perl
by johngg (Canon) on Jan 11, 2013 at 18:50 UTC | |
|
Re: Join files using perl
by blue_cowdawg (Monsignor) on Jan 11, 2013 at 19:23 UTC | |
by linseyr (Acolyte) on Jan 11, 2013 at 19:42 UTC | |
by blue_cowdawg (Monsignor) on Jan 11, 2013 at 20:58 UTC | |
by Marshall (Canon) on Jan 12, 2013 at 22:28 UTC | |
by linseyr (Acolyte) on Jan 11, 2013 at 19:46 UTC | |
by linseyr (Acolyte) on Jan 11, 2013 at 19:51 UTC | |
by ww (Archbishop) on Jan 11, 2013 at 20:19 UTC | |
|
Re: Join files using perl
by choroba (Cardinal) on Jan 11, 2013 at 23:15 UTC | |
|
Re: Join files using perl
by Anonymous Monk on Jan 12, 2013 at 03:01 UTC |