#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $_= q{<%def .errors> missing_name: You must provide your name. missing_email: You must provide your email address. </%def>}; my %errors; my $start = q{<%def .errors>}; my $end = q{</%def>}; /$start/ .. /$end/ and %errors = ( $_ =~/ (.+) [:] (.+) [.] /gx ); print Dumper \%errors;
Output: $VAR1 = { 'missing_email' => ' You must provide your email address', 'missing_name' => ' You must provide your name' };
hth,
PooLpi
In reply to Re: regex parsing brainteaser
by poolpi
in thread regex parsing brainteaser
by perrin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |