Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Help on multiline regex

by wind (Priest)
on Jun 01, 2011 at 20:38 UTC ( [id://907708]=note: print w/replies, xml ) Need Help??


in reply to Help on multiline regex

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

Replies are listed 'Best First'.
Re^2: Help on multiline regex
by Anonymous Monk on Jun 02, 2011 at 00:31 UTC
    Thanks for the complete code!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://907708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-19 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found