in reply to Re^4: directory tree to hash of arrays
in thread directory tree to hash of arrays
"Here is the current code, which is not doing what I want it to, and am having trouble wrapping my head around how to get to the structure I want to get."
Your "current code" is just a subroutine definition. You don't show how, or in what context, you're calling it. You don't say how it's behaving differently from your expections or whether it's generating error or warning messages. You don't indicate which part, or parts, you're specifically having difficulties with ("wrapping my head around"). I've already provided you with the link to "How do I post a question effectively?" in this thread: here it is again, please read it this time and follow its guidelines in any future postings.
"First, the data structure I want:"
So, you want an array with a single element which is a hashref; that hashref having a single key/value pair, the value being an arrayref; that arrayref having a single element which is a hashref; ... In some places you want a key called 'data' to have a value which is an arrayref and in other places you want a key with same name to have a value which is an hashref. Can you explain why you want a structure like that and how you propose to use it?
I asked you to provide the data structure you'd like to generate from a fairly simple directory structure. You've refused to do that! Why?
What you've posted is not related to any directory structure you've shown and is peppered with meaningless noise. For instance, am I supposed to know what "spriteCssClass" is?
I'm not convinced that you know what data structure you actually want. This would be the reason why you're having difficulties writing code to generate it.
About the only help I can provide you with at this time is to show a possible data structure. This is an example of what I was expecting from you.
{ name => 'dir_A', subs => [ { name => 'file_B', size => 99, }, { name => 'dir_C', subs => [ { name => 'file_D', size => 99, }, { name => 'dir_E', subs => [ { name => 'file_F', size => 99, }, ], }, { name => 'file_G', size => 99, }, ], }, { name => 'file_H', size => 99, }, ], }
Once you get the structure right, you can add whatever other information you want (file types, permissions, modification times, etc.). But, you need to get the structure right first!
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: directory tree to hash of arrays
by mabossert (Scribe) on Mar 14, 2014 at 06:11 UTC |