in reply to I/O here
in thread UPDATED: Recursive function adds data to a hash/array

Since no one else has mentioned this: Why reinvent the bloody wheel? Theres dozens of various templating modules that already do this sort of thing. They're simple, easy and very well tested.

HTML::Template
Mason
Template::Toolkit