Since this is science related, I want to help, but help from you would be good. First, I would recommend listing the code you used to solve your first problem. Second, I would more clearly state the steps necessary to transform your input to your output.

I took a wild swing at solving your problem, but here are the assumptions I made (and they could be erroneous).

My stab at it:

#!/usr/bin/perl -w use strict; use warnings; my $expected = <<'END_RESULT'; contig00000001 506 540 7 5.0 7 100 0 70 42 42 0 14 1.45 AAACCCT AAACCC +TAAACCCTAAACCCTAAACCCTAAACCCT contig00000001 664 691 3 9.3 3 100 0 56 32 35 32 0 1.58 CAG CAGCAGCAGC +AGCAGCAGCAGCAGCAGC contig00000002 128 188 3 20.3 3 80 6 70 34 29 31 4 1.79 GCA GCAGCAGCAG +CAATAGCAGCAGCAGCAGATGCAACTGCAGCAGCAGCAGCAGCAGCAGCAG contig00000002 313 357 3 15.0 3 81 9 56 35 33 28 2 1.70 AGC AGCAGCAACA +GCACAAGCAGCAGCAGCAGCAGCAGCTGCAGCAGC END_RESULT my @lines = grep { /\S/ && ! /^Parameters/ } <DATA>; my $result = ''; my $contig; foreach my $line (@lines) { # skip data untill we have a $contig or a line that can give # us $contig next unless $contig || $line =~ /^Sequence/; if ($line =~ /^Sequence: (contig\d+)/) { $contig = $1; next; } $result .= "$contig $line"; } if ($result eq $expected) { print "Good\n"; } else { print "Bad\n"; } __DATA__ Sequence: contig00000001 Parameters: 2 7 7 80 10 50 50 506 540 7 5.0 7 100 0 70 42 42 0 14 1.45 AAACCCT AAACCCTAAACCCTAAACCCT +AAACCCTAAACCCT 664 691 3 9.3 3 100 0 56 32 35 32 0 1.58 CAG CAGCAGCAGCAGCAGCAGCAGCAGC +AGC Sequence: contig00000002 Parameters: 2 7 7 80 10 50 50 128 188 3 20.3 3 80 6 70 34 29 31 4 1.79 GCA GCAGCAGCAGCAATAGCAGCAGCAG +CAGATGCAACTGCAGCAGCAGCAGCAGCAGCAGCAG 313 357 3 15.0 3 81 9 56 35 33 28 2 1.70 AGC AGCAGCAACAGCACAAGCAGCAGCA +GCAGCAGCAGCTGCAGCAGC

Cheers,
Ovid

New address of my CGI Course.


In reply to Re: Perl Parser, need help by Ovid
in thread Perl Parser, need help by joomanji

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.