in reply to Graph File Parsing

A decent starting point might be looking at Config::General. Its a module which parses Apache conf style config files, and I think could get you off on the right start.

Example file and how Config::General parses it.
# File blah.conf <graph> <node> title = node1 <loc> x = 10 y = 20 </loc> </node> <node> title = node2 <loc> x = 10 y - 29 </loc> </node> <edge> sourcename = node1 targetname = node2 </edge> </graph> # After parsing file and placing into %conf you will have %conf = ( node = { title = { node1 = { loc = { x => 10, y => 20, }, }, node2 = { loc = { x => 10, y => 20, }, }, }, }, edge = { sourcename => node1, targetname => node2, }, ) # You can then reference pieces thereof via $conf->{node}->{title}->{node1}->{loc}->{x};
I might have messed up the indentation, as to how it builds the hashes, but I think the point is clear. Also if you do something like x = 10 20 30 40, when you reference conf->{x} it will return an array ref, the contents of which is 10, 20, 30, 40.. you can alter the delimiter, which is whitespace by default to something else, so on and so forth with all the perl yummy goodness.

So my suggestion would be to grab the module, look over its parser and building routines, and then abstract it out as you see fit. It should be a reasonable exercise to port the hash of hash structure, to say a C struct.

Best of luck and happy hacking

/* And the Creator, against his better judgement, wrote man.c */