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";
}
In reply to The requested "slurp-solution"
by rminner
in thread I need to regex multiple lines
by legend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |