I'm parsing a config file (dhcpd.conf to be precise), and I'm not sure of a good way to parse it. Basically, it can have lines where there is no reliable line separator. Like this:
option foo bar, baz; option foo bar, baz; subnet 192.68.0.0 netmask 255.255.00 { option foo blat, boff; } subnet 192.68.0.0 netmask 255.255.00 { option foo blat,boff; }
I need to know that the global option 'foo' equals 'bar, baz' and the option 'foo' associated with subnet 168.156.0.0 is 'blat, boff'.
It looks like I can separate my problem into key-value pairs ala option foo bar; and containers ala subnet ... { ... }.
I figure I'm going to have to slurp the whole file into a scalar and then walk through it with some regex magic, but I don't know the regex kung-fu.
Any suggestions?
Thanks -PileofrogsIn reply to Parsing Config File with Multi-line Elements by pileofrogs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |