Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Help on multiline regex

by Cristoforo (Deacon)
on Jun 02, 2011 at 00:56 UTC ( #907726=note: print w/ replies, xml ) Need Help??


in reply to Help on multiline regex

Setting the INPUT_RECORD_SEPARATOR to 'object-group'

#!/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
Update: edited line of code. my ($type, $key) = /\A (\S+) (\S+)$/m;


Comment on Re: Help on multiline regex
Select or Download Code
Replies are listed 'Best First'.
Re^2: Help on multiline regex
by Anonymous Monk on Jun 04, 2011 at 03:11 UTC
    I like this method!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (20)
As of 2015-07-31 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls