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.

In reply to Command Line Hash to print things in common between two files by ZWcarp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.