Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Extract Data Between Lines

by LanX (Canon)
on Apr 04, 2014 at 03:19 UTC ( #1081063=note: print w/ replies, xml ) Need Help??


in reply to Extract Data Between Lines

maybe easier to read: :)

use Data::Dump; my $h; my @a; while(<DATA>) { if (/^object (.*)/) { $h = {}; push @a,$h; $h->{object} = $1; } $h->{$1} = $2 if /^\s+(\w+) (.*)/; } dd \@a; __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

[ { description => "Help Desk Ticket #476739", host => "138.108.25.111", object => "network Microsoft.Lync.Host.3", }, { description => "Help Desk Ticket #476739", host => "138.108.25.112", object => "network Microsoft.Lync.Host.4", }, { description => "Help Desk Ticket #476739", host => "138.108.25.113", object => "network Microsoft.Lync.Host.5", }, { object => "network Microsoft.Lync.Host.6" }, ]

Cheers Rolf

( addicted to the Perl Programming Language)


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://1081063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2015-07-02 22:20 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 (46 votes), past polls