Hi,
Using the file and the expected output you showed. Something like this could help:

use warnings; use strict; my $line_required; while (<DATA>) { $line_required = $_ if /^LOC/; if (/tAaAt/i) { print $line_required, $_; } } __DATA__ LOC_Os01g01320.1 : PS00022 EGF_1 EGF-like domain signature 1. 390 - 401 CaCtgCatGTgC + L=(-1) 1013 - 1024 CcCaaGgtGTtC + L=(-1) LOC_Os01g01320.1 : PS00099 THIOLASE_3 Thiolases active site. 976 - 989 AAGTACCAgAaAgA + L=(-1) 1269 - 1282 AAAGACGGtAaAtG + L=(-1) 1390 - 1403 GAAGACCAtAgAcA + L=(-1) LOC_Os01g01320.1 : PS00197 2FE2S_FER_1 2Fe-2S ferredoxin-type iron-sul +fur binding region signature. 1052 - 1060 CTGAACTTC + L=(-1) LOC_Os01g01320.1 : PS00269 DEFENSIN Mammalian defensins signature. 868 - 896 CaCgctg.CtgaccttGtCcaactacgaCC + L=(-1) LOC_Os01g01320.1 : PS00956 HYDROPHOBIN Fungal hydrophobins signature. 2248 - 2259 GAgCATTTaCCT + L=(-1) LOC_Os01g01320.1 : PS01177 ANAPHYLATOXIN_1 Anaphylatoxin domain signat +ure. 462 - 494 CCttGaacgcat.TCAaggaga...TatCtatggc.CC + L=(-1) 1786 - 1817 CCtgGcgttgattTCAacg......AaaCttactctCC + L=(-1) 2428 - 2461 CCatAtcttagt.GCTattggc...GcaCttatgtaCC + L=(-1) LOC_Os01g01320.1 : PS50214 DISINTEGRIN_2 Disintegrin domain profile. 340 - 425 GGTCATCATTTGATCACTGACAAATTTCCCaAATCCTCCGATTTCGtatgCACTG +CATGT L=-1 GCTACTGGGAaACTGATTTTGAGACC-------- 868 - 964 --------------CACGCTGctgaCCTTGTCCAactacgacCAACTGCATATCA +TGaaa L=-1 ctTCCCcaatGCAGTTAGTACGTGGAaatcttccaaATATTTCCCATTTGC-------- LOC_Os01g01320.1 : PS50842 EXPANSIN_EG45 Expansin, family-45 endogluca +nase-like domain profile. 1422 - 1494 CGATGAGTcTATaAGGGTTGATGAAATTGCCATCAACTACTCTGAAACTGGagaA +TCTTT L=-1 TGATAGaaGAGCT--------------------------------------------- 2712 - 2793 TGCCGCTTgTGTtgttcAGatggaAACTGGTTATATTAAGAGCAACATCACTaag +catat L=-1 tGCTCCTAAaTTATTTTATC-----CT--------------------------------- ------------ LOC_Os01g01320.1 : PS50868 POST_SET Post-SET domain profile. 1961 - 1977 ACATCCCGAATCAGAAG + L=-1 LOC_Os01g01320.1 : PS51173 CBM2 CBM2 (Carbohydrate-binding type-2) dom +ain signature and profile. 2593 - 2703 ATAATTGCATTATATGAGGCATCATGTGAATGTGTATGGCTTCGCAgaatGGTTA +ACCAC L=-1 ATATTAACATCTTGT--------GGTATTGGTTcATTGGAATcacCTACCATTATCTAT LOC_Os01g01320.1 : PS51364 TB TGF-beta binding (TB) domain profile.

OR even a one-liner like so:
perl -wne '$l = $_ if/^LOC/; print $l,$_ if/tAaAt/i' log_file_you_use. +txt
OUTPUT
LOC_Os01g01320.1 : PS00099 THIOLASE_3 Thiolases active site. 1269 - 1282 AAAGACGGtAaAtG + L=(-1) LOC_Os01g01320.1 : PS50842 EXPANSIN_EG45 Expansin, family-45 endogluca +nase-like domain profile. tGCTCCTAAaTTATTTTATC-----CT---------------------------------
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

In reply to Re: pattern and loop by 2teez
in thread pattern and loop by Anonymous Monk

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.