Do use some database such as
DBD::SQLLite. It makes your metadata more searchable and flexible in the long run. Also if you find yourself with many many files per directory consider putting them in a tree structure to avoid long stat()s. Also if there are many files and you find yourself finding in the treee a lot, and are on unix, see if your filesystem supports noatime mount options. That can reduce recursive stat times by a _LOT_.