Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)

by CountZero (Bishop)
on Oct 16, 2004 at 20:02 UTC ( #399803=note: print w/ replies, xml ) Need Help??


in reply to Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)

It looks a bit like a tree, with all nodes not starting with ':' being terminal nodes and the other (those with a ':') being non-terminal branches.

I don't think the number of tabs is significant as you have the same information in the '(' and ')'.

I would have a look into CPAN modules which deal with trees.

Another solution might be to transform this structure into XML and then deal with it through all XML-related modules and tools.

A hand crafted XML of (part of) the above structure might read:

<rip> <bind_interface>false</bind_interface> <enable>false</enable> <poison_split_horizon>enable <enable> <poison>false</poison> </enable> <disable>null</disable> </poison_split_horizon> <metric>1</metric> .... </rip>
The trick will be to maintain a stack with the name of the tags you need to close.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


Comment on Re: Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)
Select or Download Code
Re^2: Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)
by idnopheq (Chaplain) on Oct 16, 2004 at 20:34 UTC
    XML was another approach I tried (sequentially with LDAP). It seems to come back to my inability to properly parse the nested data.

    Anticipating I ignore the tabs and focus on the related parenthesis, I could handle it. But how do I count the relative number of nested open/close parenthetical pairs while within such a pair?

    Perhaps there is a math-related module that can help me!

    THX!!!
    --
    idnopheq
    Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-08-29 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls