http://www.perlmonks.org?node_id=985657

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.