I'm all for simplicity, so I'd split this into two steps:
my $data = '<%def .errors> missing_name: You must provide your name. missing_email: You must provide your email address. </%def>'; my ( $errors ) = $data =~ m[\Q<%def .errors>\E\n (.*\n) \Q</%def>\E ]sx; my %errors = $errors =~ m{(\w+):\s*(.*?)\n}g; print Dumper \%errors;
Output:
$VAR1 = { 'missing_email' => 'You must provide your email address.', 'missing_name' => 'You must provide your name.' };
In reply to Re: regex parsing brainteaser
by FunkyMonk
in thread regex parsing brainteaser
by perrin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |