Thanks for your answers. I would like to thank Daveorg for his explanation and highlighting my problem. I'm still having some problem in solving my problem. I have sent the structure of the file am dealing with and the code I have so far come up with using a REGEX that captures only the first line in the file.

The structure of the text file is as follows:

FT CDS complement(7216..17805) FT /locus_tag="TP01_0003" FT /codon_start=1 FT /protein_id="XP_765530.1" FT /db_xref="GI:71031777" FT /db_xref="GeneID:3502673" FT gene complement(<7216..>17805) FT /locus_tag="TP01_0003" FT /db_xref="GeneID:3502673" FT mRNA complement(<7216..>17805) FT /locus_tag="TP01_0003" FT /product="hypothetical telomeric SfiI fragment 20 protein FT 3" FT /transcript_id="XM_760437.1" FT /db_xref="GI:71031776" FT /db_xref="GeneID:3502673" FT CDS complement(join(18028..18116,19351..20668)) FT /locus_tag="TP01_0004" FT /note="go_function: nutrient reservoir activity [goid FT 0045735]" FT /codon_start=1 FT /protein_id="XP_765531.1" FT /db_xref="GI:71031779" FT /db_xref="GeneID:3503550" FT gene complement(<18028..>20668) FT /locus_tag="TP01_0004" FT /db_xref="GeneID:3503550" FT mRNA complement(join(<18028..18116,19351..>20668)) FT /locus_tag="TP01_0004" FT /product="hypothetical protein" FT /transcript_id="XM_760438.1" FT /db_xref="GI:71031778" FT /db_xref="GeneID:3503550" FT CDS complement(20951..21967) FT /locus_tag="TP01_0005" FT /codon_start=1 FT /protein_id="XP_765532.1" FT /db_xref="GI:71031781" FT /db_xref="GeneID:3503551" FT gene complement(<20951..>21967) FT /locus_tag="TP01_0005" FT /db_xref="GeneID:3503551" FT mRNA complement(<20951..>21967) FT /locus_tag="TP01_0005" FT /product="hypothetical protein" FT /transcript_id="XM_760439.1" FT /db_xref="GI:71031780" FT /db_xref="GeneID:3503551"

This is my code

#!/usr/bin/perl $file = 'Muguga.embl '; open (F, $file) || die ("Could not open $file!"); while ($line = <F>) { ($field1,$field2,$field3,$field4) = split( "\t" , $line); print "$field1 $field2 $field3 $field4 \n"; my $string = (FT CDS complement(join(18028..18116,19351..20668))); # s +tring to be searched if ($string = ~ m/^FT \s+ CDS \s+ complement\(join\([0-9]+\)\)$/) #search for the first line highlighted in bold { print 'match' } else{ print 'no match'; } } close (F);

My wish is to able to search for the lines that are in bold and print them out.

I will be grateful if you are able to help my code though am still a perl newbie.

Thanks in advance.

20090716 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips


In reply to REGEX malfunction by rayken

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.