note
Cristoforo
Setting the INPUT_RECORD_SEPARATOR to 'object-group'<p>
<c>#!/usr/bin/perl
use strict;
use warnings;
use 5.012;
use Data::Dumper;
my %data;
{
local $/ = 'object-group';
while (<DATA>) {
chomp;
next unless $_;
my ($type, $key) = /\A (\S+) (\S+)$/m;
my @data = /^ $type-object (.+)$/mg;
$data{ $key } = {type => $type, array_of_entries => \@data};
}
}
print Dumper \%data;
__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
</c>
<b>Update:</b> edited line of code.
<c>my ($type, $key) = /\A (\S+) (\S+)$/m;</c>
907669
907669