The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


StanzaFile::Grub - read, parse, and write Grand Unified Bootloader configuration files.


There are no interface changes between this and the parent class, StanzaFile. This is included, partly, as an example of the ease with which additional different stanza file formats can be supported using the StanzaFile class and, mostly, because I used the StanzaFile::Grub class in a kernel build and installation management package I wrote (check it out, kif at


The grub configuration file format differs in a couple of ways from the WINDOWS.INI format. It has a "global" section that appears before any of the stanzas actually start. This global section is stored in a dummy stanza accessable via the header method defined in StanzaFile.

The format of entries in the global section also differs from entries in the stanzas.

All this is dealt with by overriding 5 methods.

$theObject->addHeader($leftHandSide, $rightHandSide)

addHeader puts a new global header item into the Grub StanzaFile object. The value of the new header item is the value of the $rightHandSide variable and is optional for those header items without values.


Produce a string suitable for printing that represents the contents of the header portion of the Grub stanza file object.


A predicate which tests the line to see if it is the beginning of a new stanza. If it is, the value of the predicate is the name of the new stanza. Otherwise the value of the predicate is undefined.


A predicate which tests the line to see if it contains a name/value pair and returns that pair as the value of the prediate. Otherwise it returns and undefined.


Produce a string suitable for printing that represents a Grub file stanza other than the header.



None known.


No comments or whitespace are preserved in the configuration file when it is read and/or written.


Dick Munroe (munroe@csworks). I'm looking for work. If you hear of anything that might be of interest to a VERY senior engineer/architect drop me a note. See for details.


The Kernel Installation Facility uses these classes extensively. For more details see