Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

saif format parsing

by nick_2012 (Initiate)
on Aug 06, 2012 at 10:39 UTC ( #985657=perlquestion: print w/ replies, xml ) Need Help??
nick_2012 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks, I have an input file of the format: instance A { net1 net2 instance B { net3 net4 instance C { net5 net5 } instance D { net7 net8 } } instance E { net9 net10 } } can you propose a perl script which can parse this and produce an output which looks like: net1 net2 B/net3 B/net4 B/C/net5 B/C/net6 B/D/net7 B/D/net8 E/net9 E/net10 I cant seem to figure an easy way of going up and down the hierarchy in the instance file and printing the same to each of the nets in the file...

Comment on saif format parsing
Re: saif format parsing
by Gangabass (Priest) on Aug 06, 2012 at 12:36 UTC
    The common answer for such questions is:
    Show us what have you tried
      I have been able to figure out a solution using a stack to this problem. I push onto the stack whenever "instance(" and pop from it whenever ")". This way I can keep a tab on level of instance name in an array based on push operations. thanks offering to help.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-07-13 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls