in reply to nested reg ex over multiple lines
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' } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: nested reg ex over multiple lines
by tphyahoo (Vicar) on Jun 20, 2005 at 13:40 UTC | |
by holli (Abbot) on Jun 20, 2005 at 13:52 UTC | |
by BUU (Prior) on Jun 20, 2005 at 17:33 UTC |