We have two files

One file

ALDH1A1

ITGA7

CHRNA1

PPP1R9A

ACTG1

SRGN

CD44

GRB7

and Second file

ALDH1A1 00001 NP_000680.2 ALDH1A1 00001 NP_000680.2 in vivo;yeast 2-hybrid 12081471,16189514

ITGA7 02761 NP_002197.1 CHRNA1 00007 NP_001034612.1 in vivo 10910772

PPP1R9A 16000 NP_060120.2 ACTG1 00017 NP_001605.1 in vitro;in vivo 9362513,12052877

SRGN 01513 NP_002718.2 CD44 00115 NP_000601.3 in vivo 9334256

GRB7 03311 NP_005301.2 ERBB2 01281 NP_004439.2 in vitro;in vivo 9079677

PAK1 03995 AAC24716.1 ERBB2 01281 NP_004439.2 in

And output shud be

ALDH1A1 NP_000680.2

ITGA7 NP_002197.1

CHRNA1 NP_001034612.1

PPP1R9A NP_060120.2

ACTG1 NP_001605.1

SRGN NP_002718.2

CD44 NP_000601.3

GRB7 NP_005301.2

#!/usr/bin/perl -w $j=1; open (FILE,"$ARGV[0]") or die; my @temp =<FILE>; close FILE; foreach $x(@temp) { chomp($x); $line = $1; $flag = 1; } open (FILE,"$ARGV[1]") or die; my @parse=<FILE>; close FILE; open(WRITE,">output.txt"); { if($flag==1){ if ($x==$parse[$0]) { print WRITE "$x $j\n $line\n";$j++;} } }

In reply to matching twof files and print the output by vis1982

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.