in reply to Recursive Class:Struct syntax error?

The man page states the valid ways to create such a struct. They all involve an ELEMENT_LIST which has the form NAME => TYPE, ...

Your mistake is that instead of TYPE, you give data. Instead of '*%' you give {}. So, for the non-recursive elements do something like this bin => '*%'

Now, for the recusrive parts. The obvious would be to use a hash-of-hashes - my above suggestion suffices ... But I get the impression you would like to use Class::Struct so that your toolbelt looks tres chic, so to speak. I can't help with that without my mind constantly drifting to either a simple hash-of-hashes-of-hashes-of-hashes... OR creating a class yourself.

bw, bliako

Replies are listed 'Best First'.
Re^2: Recursive Class:Struct syntax error?
by ibm1620 (Hermit) on Dec 03, 2018 at 18:44 UTC
    Agreed. I eventually just built a hash of hashes. This was certainly not a good application for Struct.

      markong's suggestion to use Tree-Simple (instead of h-o-h) looks like a very good idea to me because it will easily allow you to traverse your file-system backwards - from the children back to the parent - (and forwards of course). Plus you can do all sorts of sorting and searching on filenames. Lastly, keys %hash returns keys in random order. So each run will not be consistent unless you always do sort keys %hash or use arrays. So, yes hash-of-hashes is a basic idea, but Tree-Simple will make it easier for you and it is a good thing to have in one's toolbelt.