Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

saif format parsing

by nick_2012 (Initiate)
on Aug 06, 2012 at 10:39 UTC ( [id://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...

Replies are listed 'Best First'.
Re: saif format parsing
by Gangabass (Vicar) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-20 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found