use strict; use warnings; my %hash; my $key; while (<DATA>) { if (/object-group\s+(\w+)\s+(.*)/) { $key = $2; $hash{$key}{type} = $1; } elsif (/\Q$hash{$key}{type}\E-object\s+(.*)/) { push @{$hash{$key}{array_of_entries}}, $1; } } use Data::Dumper; print Dumper(\%hash); __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
In reply to Re: Help on multiline regex
by wind
in thread Help on multiline regex
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |