B
barjunk
I'm new to ruby and one of the first projects I am trying to tackle is
parsing a file
with this sort of format:
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
or host devicename-1 {
hardware ethernet 00:10:51:61:74:FF;
fixed-address 192.168.0.15;
}
The basic issue I'm working to resolve is how can I treat these
sections as "records".
I know I could read the entire file into memory, but I was looking to
only deal with them
on a record by record basis.
One thought was to read through the file and keep a hash of information
about where the
record starts and ends, then when I want to read a record, use that
reference to get the
data.
Has anyone done something similar to this that I can use to learn how
to manage these
types of file formats?
There won't be an issues with concurrent access at this point.
These formats are found when using dhcp, freeradius, and nagios. I'm
sure there are others.
Mike
parsing a file
with this sort of format:
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
or host devicename-1 {
hardware ethernet 00:10:51:61:74:FF;
fixed-address 192.168.0.15;
}
The basic issue I'm working to resolve is how can I treat these
sections as "records".
I know I could read the entire file into memory, but I was looking to
only deal with them
on a record by record basis.
One thought was to read through the file and keep a hash of information
about where the
record starts and ends, then when I want to read a record, use that
reference to get the
data.
Has anyone done something similar to this that I can use to learn how
to manage these
types of file formats?
There won't be an issues with concurrent access at this point.
These formats are found when using dhcp, freeradius, and nagios. I'm
sure there are others.
Mike