I don't know what your spec is for line breaks, or whether blank lines have meaning, or what to do for lines that don't begin with Parameter or Sequence keywords.#!/your/perl/here use strict; use warnings; my $sequence; while (my $line = <>) { # Sequence keyword if ($line =~ /^Sequence:\s+(contig\d+)/) { $sequence = $1; # save the sequence next; } # Parameter keyword next if ($line =~ /^Parameters:\s+(.*)$/); # print any other non-blank lines if ($line != /^\s*$/) { print "$sequence $line"; next; } }
Please use <code> tags to show code and output, otherwise we have to check the page source to see the actual format. (And I still might have got the input format wrong.)
Update: Corrected Parameters: error as pointed out by Ovid. The Parameters: line is just skipped.
Update 2: Adding missing semicolon to Parameter line.
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re: Perl Parser, need help
by QM
in thread Perl Parser, need help
by joomanji
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |