Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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...

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://985657]
Approved by marto
[shmem]: I'd be so happy without any money - if it weren't that people randomly wanted money from me

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2018-04-20 17:34 GMT
Find Nodes?
    Voting Booth?