in reply to I need to regex multiple lines
use strict;
use warnings;
use File::Slurp;
my $wholefile = read_file('data.txt');
my $capture = qr{(LENGTH|SUBJECT|COMMENT|\Z)};
while ($wholefile =~ m{^$capture:(.*?)(?=$capture)}smgcx) {
my ($type , $data) = ($1 , $2);
print "Type: $type\n";
print "Data: $data\n";
}
|
|---|