in reply to Parsing a file

I'm not sure of your desired output. Are you trying to catch the last line containing Sbject? If you would post the desired output for the provided example input file, I'll try to find and post a solution.

Anyway, it's very likely that the $_ variable you are parsing contains one line at a time, and searching for multiple \n doesn't work.

Regards,
Luke

Replies are listed 'Best First'.
Re^2: Parsing a file
by cowboyrocks (Novice) on Apr 16, 2009 at 06:51 UTC
    Hi.. I have updated my post with the desired output.Thanks

      If you want to extract Sbjct: lines, and print them out, the following should work fine:

      #!/usr/bin/perl -w use strict; while (<>) { print if /^Sbjct:\s*\d+\D+\d+$/; }
      After running this code for your sample input data i get:
      Sbjct: 38348818 AGGCATAAACCACATCCAGCCACCTCCTTCTGATCAGCAGCAAAGCTGACGTTT +TGATCT 38348759 Sbjct: 38348758 CCATCTGTCTGATTCTTGTGTCTACTTCTCAGTTTACAACTCCAGTGGGAAAGA +AAGAGC 38348699 Sbjct: 38348698 TTTATTTACAGACCCATAAAAATCCCATCAGTGTCGTCCCCTGCTGAGAGGCCA +TGTGAG 38348639 Sbjct: 94217254 CAAGAAACTATATAGGTATACACTTACGACTTCACAAAACCTATACTTAATATA +GTAAAT 94217195 Sbjct: 94217194 CTAAGTAAACATGTATTACTCAAAGTAATATATTTAGAATTATGTATTAGTATA +AGATCA 94217135 Sbjct: 94217134 GAATTGAATTTAAGTTGTTGGTGACATCTGCATCATTTCATAGGATTAGAACTT +ACTCAA 94217075 Sbjct: 94217074 AATAATGTAAATCTTTAAAAATATAAATTAGAATGACAAGTGGGAATCATAAAT +TAAACG 94217015

      Hope that helps,
      Luke