Did you happen to
search CPAN and see if any of the modules did what you want? That is the first place we would look and it should be that way for you as well.
You could use a module, or you could set up a test of each line and have a variable (lets say $chunk) equal to the section name (ie: [A]) If the next line matches [?], then its a new section, if not, you can feed the next line into an array with the section name (A) or whatever you wanted to call it.
Either way, its up to you, just providing you another way that you could do it.
You could also have a test to check for lines beginning with a # and to ignore them.
Regards,
Jeff