http://www.perlmonks.org?node_id=947231

ZWcarp has asked for the wisdom of the Perl Monks concerning the following question:

Hello all. I would like to do something akin to the join command using perl at the command line to make a hash and print lines where a value is in common between two files. The two files might have in common lets say... a gene identifier number or a CG number. These are always numbers and letter delimited somehow. What would the best way to do this at the command line be?

Original content restored above by GrandFather

I would like to accomplish 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"; } } }
From 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.