in reply to Turning a datafile into a data structure
That sounds like a perfect use for Parse::RecDescent.
Get it (togther with copious amounts of documentation and examples) from CPAN at http://search.cpan.org/search?dist=Parse-RecDescent.