Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I need a little help here
How to parse this bit of multi-line data.
object-group service DM_SERVICE_7 service-object tcp eq 1433 service-object tcp eq 49160 service-object tcp eq 8086 object-group network Employees description Employees network-object 10.10.12.0 255.255.255.0 network-object 10.11.12.0 255.255.255.0
Should parse into a hash like
'DM_SERVICE_7' => { 'type' => 'service ', 'array_of_entries' => ["tcp eq 1433", "tcp eq 49160", "tcp eq 8086 +" ] }, 'Employees' => { 'type' => 'network', 'array_of_entries' => ["10.10.12.0 255.255.255.0", "10.11.12.0 255 +.255.255.0"] }
I have got as far as here, but not sure how to proceed
undef $/; while (<>) { @array = split /object-group/; #array of all interesting data }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help on multiline regex
by ikegami (Patriarch) on Jun 01, 2011 at 17:50 UTC | |
by LanX (Saint) on Jun 01, 2011 at 18:05 UTC | |
by ikegami (Patriarch) on Jun 01, 2011 at 18:40 UTC | |
by LanX (Saint) on Jun 01, 2011 at 18:50 UTC | |
by ikegami (Patriarch) on Jun 01, 2011 at 19:17 UTC | |
| |
|
Re: Help on multiline regex
by wind (Priest) on Jun 01, 2011 at 20:38 UTC | |
by Anonymous Monk on Jun 02, 2011 at 00:31 UTC | |
|
Re: Help on multiline regex
by LanX (Saint) on Jun 01, 2011 at 17:29 UTC | |
|
Re: Help on multiline regex
by Cristoforo (Curate) on Jun 02, 2011 at 00:56 UTC | |
by Anonymous Monk on Jun 04, 2011 at 03:11 UTC |