Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: split file on blank lines and match blocks

by BrowserUk (Pope)
on Sep 09, 2012 at 03:29 UTC ( #992554=note: print w/ replies, xml ) Need Help??


in reply to split file on blank lines and match blocks

trying to identify hosts that are members of the CRIT hostgroup, or of the DMZ hostgroup

Ignoring that your text say's that, and your code 'GRID|RMAN', this might set you on your road:

#! perl -slw use strict; $/ = ''; ## para model see perldoc -q paragraphs m[ (?=^.*(DMZ|CRIT)) (?=^.*host_name\s+(\S+)) (?=^.*address\s+(\S+)) ]sx and print "$2 [$3] is a member of $1" while <DATA>; __DATA__ [snip... your sample data here]

Produces:

C:\test>junk denlas02 [146.xxx.xxx.xxx] is a member of DMZ ppplas12 [10.50.33.26] is a member of CRIT

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re: split file on blank lines and match blocks
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-09-19 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (145 votes), past polls