#!/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; } }