Output:use strict; use warnings; use Data::Dumper; my $key; my %data; while (<DATA>) { $key = $1, next if /^CALCON\((\w+)\)/; $data{$key}->{$1} = $2 if /^\s+(\w+)\(([\w\d\s]+)\)/; } print Dumper (\%data); __DATA__ CALCON(test1) { TYPE(U8) FEATURE(DCOM) NAM(stmin) LABEL(Min seperation time between CFs) MIN(0) MAX(127) UNITS(ms) } CALCON(test2) { TYPE(U16) FEATURE(DCOM) NAM(dcomc_sestmr_timeout) LABEL(DCOM Session Timer Timeout) MIN(0) MAX(65535) UNITS(ms) }
$VAR1 = { 'test1' => { 'MIN' => '0', 'UNITS' => 'ms', 'FEATURE' => 'DCOM', 'NAM' => 'stmin', 'MAX' => '127', 'TYPE' => 'U8' }, 'test2' => { 'MIN' => '0', 'UNITS' => 'ms', 'FEATURE' => 'DCOM', 'NAM' => 'dcomc_sestmr_timeout', 'MAX' => '65535', 'TYPE' => 'U16' } };
In reply to Re: nested reg ex over multiple lines
by holli
in thread nested reg ex over multiple lines
by eg8rds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |