Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: multi-line (string doc) parsing

by Trinary (Pilgrim)
on Jan 27, 2001 at 23:31 UTC ( [id://54773]=note: print w/replies, xml ) Need Help??


in reply to multi-line (string doc) parsing

Would help to know if (hopefully) the columns are separated by something other than a bunch of spaces...tab would be convenient. Otherwise I guess you could just split on more than two spaces, but I don't know exactly what the data looks like there.

Anyway, a simple approach: pseudo-codish

foreach (@lines) { next if (/-+/ || /^Sharename/); last if (/^Server/); my @vals = split /\s{2,}/; $hash{"$vals[0]"}{'Type'} = $vals[1]; $hash{"$vals[0]"}{'Comment'} = $vals[2]; }
As usual, untested and mostly not proofread. =) Point out errors as you see fit, of course this is a totally simple method of solving the problem...much cooler solutions abound.

Enjoy

Trinary

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found