Building a tree of files

Andy Wardley abw at wardley.org
Wed Mar 1 18:06:13 GMT 2006


Can anyone point me to the right module, appropriate rules for 
File::Find::Rule, or any other clues to achieve the following?

I'm building HTML pages for a set of modules.  I want a nice nested
menu which I can easily generate via TT given the appropriate data 
structure.

Something like this would do me very nicely:

$tree = [
    {  name = 'Foo.pm'
       path = 'Foo.pm'
       type = 'file',
    }
    {  name = 'Foo',
       type = 'directory',
       tree = [
         { name = 'Bar.pm'
           path = 'Foo/Bar.pm'
           type = 'file'
         }
         # ...etc...
       ]
    }
    # ...etc..
]

Ideally I would like the Foo.pm or Foo.pod (or presumably some
other file spec of my choosing) to appear in the tree immediately
before the directory of the same name.  My resulting menu should
look like this:

   Foo.pm
   Foo
     Bar.pm
     Bar
       Baz.pm
       Wiz.pm
       Waz.pm
     # ...etc...

I've got my own hacked-up code built from File::Find::Rule which
nearly works, but it's getting messy and I'm sure I'm missing
some nice elegant solution.  So before I hack it around to
make/break it better/worse I thought I'd ask to see if someone
else has any pointers.

Cheers
A


PS Buffy, Pie, Pony



More information about the london.pm mailing list