find partial matching two files in perl -


I want to write a pell program. The first input file has 2 columns of text. The first column is a label and the second column is the search string. There is also 2 columns in the second input file. The first column is a label and the second column is the text to be searched. For example, according to the second column, John (in File 1) is more than John compared to Joy compared to John.

file1

  john aabccae jam WWQQQQQRTTTT  

file2

  Jami EWQQQQQRTRTTTT Johnny Aaaaabibibisisisiiiiiiiacacacacacac mark WWWCCVVVVVVFFFFFFFTTTTTR ROB ## @@ @ ######## Viviviviviviviviviviu John WWADFRWSSSSDSDDDDDqqqqq  

output

  jami ewwqqqqqQQRRTTTTTTT jam Dbludblukyukyukvi QQQRRTTTTT Johnny Aaaaabibibis Siiiiiiiacacacacac John Aabibibisisiseedii  

I tried the following code, but it's the way I want, it does not work.

  #! Use / user / bin / perl warnings; Strict use; Mary ($ infile1) = $ ARGV [0]; Mary ($ infile2) = $ ARGV [1]; Open (my $ FH1, "& lt; $ infile1"); While (my $ file1 = & lt; $ fh1 & gt;) {my @ file1 = split ("\ t |", $ file1); My $ name_file1 = $ file1 [0]; My $ id_file1 = $ file1 [1]; My @ matchline_file2 = `cat $ infile2 | Grep $ name_file1`; My $ ID_file1 (@ file1) {If ($ grep $ $ i_file2 eq $ ID_file1, @ matchline_file2) {print "found \ n";} other {print "no_found \ n";}}}  

This does not print results in reverse order such as your output. I'm not sure he was deliberately. You can store the results in an array and you can reverse or sort if you want. Your example is very limited and it is only the best guess to try.

  #! Use / usr / bin / perl warnings; Strict use; Mary ($ infile1) = $ ARGV [0]; Mary ($ infile2) = $ ARGV [1]; My $ search_file = ""; Open (my $ FH2, "& lt; $ infile2"); While (my $ line =  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -