in reply to multiline in while loop and regular expression
Like that (very briefly tested, seems to work):
use strict; use warnings; use feature 'say'; my $headers = qr{ \A \s* (?: LOCUS | DEFINITION | ACCESSION | VERSION | KEYWORDS | SOURCE | + ORGANISM | CDS ) }x; my $skip = qr{ \A \s* (?: Data\s+file: | \/\/ | \z ) }x; my @lines; while (<>) { next if /$skip/; s/\R//; if (/$headers/ and @lines) { say @lines; @lines = (); } push @lines, $_; } say @lines if @lines;
|
|---|