http://www.perlmonks.org?node_id=89878


in reply to Data structure question: Directory-in-memory ?

You could do the standard tree-thing and use a more standard linked_list solution. Something like:
my $dir = { name => '.', contents => [ { name => 'subdir 1', contents => [...] }, { name => 'subdir 2', contents => [...] } ], };

Note: untested

Then you'd have a real tree-structure, which you could iterate recursively. You don't get the ease of the quick solution, but you get some robustness and flexibility. Plus, you can wrap this in a class structure and write accessor methods.

Best of all, you could use Class::Tree, which provides a premade OO interface to treelike structures of this kind... Haven't used it myself, but the docs list methods for reading directory trees directly from the filesystem.

stephen

Replies are listed 'Best First'.
Re: Re: Data structure question: Directory-in-memory ?
by mr.nick (Chaplain) on Jun 20, 2001 at 04:47 UTC
    That's sort of the direction I was going with the anonymous array. I was trying to accomplish this using Perl internals; only relying on it's own hashing and array functions. Using a btree would be too easy :)

    mr.nick ...