ZWcarp has asked for the wisdom of the Perl Monks concerning the following question:
Original content restored above by GrandFather
I would like to accomplish thisFrom the command line using maybe a hash or something so that its faster. Does anyone know how to do this sort of operation in a nice compact form? Basically just a way to see if a value in a column in one file appears in some form somewhere in a second file and printing the lines that are satisfy this.use strict; open (FILEHANDLE, "$ARGV[0]") || die("Could not open file 1 input file +"); my @file1 = <FILEHANDLE> ; close (FILEHANDLE); open (FILE2, "$ARGV[1]") || die ("Could not open file 2 input file +"); my @SAVI = <FILE2>; close (FILE2); foreach my $line1 (@file1) { chomp ($line1); (my $var1, my $var2) = split(/\t/,$line1); foreach my $line2 (@file2) { chomp($line2); (my $Var1, my $Var2)= split(/\t/,$line2); if ($var1=~m/$Var1/) { print $line1 ."\t" . $line2 . "\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Command Line Hash to print things in common between two files
by umasuresh (Hermit) on Jan 10, 2012 at 20:34 UTC | |
by ZWcarp (Beadle) on Jan 10, 2012 at 20:41 UTC | |
by CountZero (Bishop) on Jan 10, 2012 at 21:22 UTC | |
by ww (Archbishop) on Jan 10, 2012 at 22:28 UTC | |
by ZWcarp (Beadle) on Jan 10, 2012 at 23:27 UTC | |
by graff (Chancellor) on Jan 11, 2012 at 06:51 UTC | |
by Marshall (Canon) on Jan 11, 2012 at 16:41 UTC | |
|
Re: Command Line Hash to print things in common between two files
by tobyink (Canon) on Jan 11, 2012 at 16:59 UTC |