in reply to Re^3: directory tree to hash of arrays
in thread directory tree to hash of arrays

I am fairly well familiar with how a hash and an array work...as well as a hash or arrays or vice-versa. I simply copied a snippet of your response. What I am looking for is a structure that will lend itself well to translation to JSON for display within a web application directory tree:

$VAR1 = { '/tmp/dir1' => { 'innerdir1' => [{'name' => 'file1', 'size' => 12345}, {'name' +=> 'file2', 'size' => 1223}] } };

Replies are listed 'Best First'.
Re^5: directory tree to hash of arrays
by hippo (Archbishop) on Mar 08, 2014 at 10:29 UTC

    That's a little inconsistent. Your outer dir is a hashref while your inner dir is an arrayref. Furthermore in some places (directories) you use the name as a key and in other places (files) as a value.

    I agree with kcott - it's always better to plan your data structure in detail first before considering the minutiae of how to construct it.