Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Extract Data Between Lines

by wazat (Scribe)
on Apr 04, 2014 at 03:38 UTC ( #1081064=note: print w/ replies, xml ) Need Help??


in reply to Extract Data Between Lines

While the other suggestions are superior, you don't need to use a regex with $/

use strict; use warnings; $/ = "\nobject "; while (<DATA>) { chomp; print "'$_'\n" } __DATA__ object network Microsoft.Lync.Host.3 host 138.108.25.111 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.4 host 138.108.25.112 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.5 host 138.108.25.113 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.6

output

'object network Microsoft.Lync.Host.3 host 138.108.25.111 description Help Desk Ticket #476739' 'network Microsoft.Lync.Host.4 host 138.108.25.112 description Help Desk Ticket #476739' 'network Microsoft.Lync.Host.5 host 138.108.25.113 description Help Desk Ticket #476739' 'network Microsoft.Lync.Host.6 '

The first record needs to be massaged since object isn't preceded by a newline.


Comment on Re: Extract Data Between Lines
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-07-04 21:50 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 (60 votes), past polls