in reply to regex parsing brainteaser
#!/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
|
|---|