in reply to File parsing

As an aside, you might want to replace
foreach (readline FILE) {
with
while (<FILE>) {
The former reads the whole file into memory before processing it, which may become a problem with large files.

Dave.