If you could show some more sample input and especially the expected output (Update: root node has been edited to include that), that would be helpful, for example I'm not sure if you want "Warning bad news here" to appear in the output.
Based on what you've provided, here's one way, using a negative lookahead to prevent the "keywords" from being interpreted as continuations.
use strict; use warnings; use Data::Dumper; local $/ = "\n\n\n"; while (<DATA>) { next unless m/Dumpdata example/; my %row = m/ ^ \s* (\w+:) \s+ ( (?: (?!^\s*\w+:) . )+ ) /xmsg; print Dumper(\%row); } __DATA__ Dumpdata example ----------------- Warning bad news here Detail: Some really nice infos these are Info: This is a problem but there is a solution
Output:
$VAR1 = { 'Detail:' => 'Some really nice infos these are ', 'Info:' => 'This is a problem but there is a solution ' };
In reply to Re: Joining multiple lines together while parsing
by haukex
in thread Joining multiple lines together while parsing
by Arengin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |