in reply to Perl Parser, need help
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Parser, need help
by Ovid (Cardinal) on May 14, 2005 at 04:27 UTC | |
by QM (Parson) on May 15, 2005 at 03:12 UTC | |
|
Re^2: Perl Parser, need help
by joomanji (Acolyte) on May 19, 2005 at 03:06 UTC | |
by QM (Parson) on May 19, 2005 at 22:37 UTC | |
by joomanji (Acolyte) on Jun 02, 2005 at 07:26 UTC | |
by QM (Parson) on Jun 02, 2005 at 12:46 UTC |