I have a grow.out file showing protein ligand interaction. I converted that file into text file. It looks like:

H P L A 143 TYR 202 OH --> O2 2014 MC9 500 A H P L A 143 TYR 202 OH <-- O2 2014 ASH 500 A H P L A 237 SER 532 OG --> O1 2015 MC9 500 A H P L A 237 SER 532 OG <-- O1 2015 AGM 500 A H P L A 274 ARG 821 NH1 --> O1 2015 MC9 500 A H P L A 278 SER 851 OG --> O2 2014 VIA 500 A

Now what I want is that the program should search for a particular ligand code (Say MC9 here). After searching for MC9 the program should print each line (row) containing MC9 into another output text file. I am a drug design student with biotechnology background. so don't have much knowledge on programming. Please help me. I have a code with me but is not working as the way I wanted.

#!/usr/bin/perl -w use strict; use IO::File; use constant FILE => 'search.txt'; use constant FIND => 'string to find'; IO::File->input_record_separator(FIND); my $fh = IO::File->new(FILE, O_RDONLY) or die 'Could not open file ', FILE, ": $!"; $fh->getline; print IO::File->input_record_separator while $fh->getline; $fh->close;

it is printing MC9 again and again, not the whole row


In reply to reading and working with grow.out files by rmgzsm9

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.