Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Data structure question: Directory-in-memory ?

by stephen (Priest)
on Jun 20, 2001 at 04:36 UTC ( #89878=note: print w/replies, xml ) Need Help??


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 ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89878]
help
Chatterbox?
[Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history
LanX damns the cult of CB ;-)
LanX WTF WTF WTF
[LanX]: please forget my last 3 posts
[LanX]: Yeah option a doesn't go into history
[LanX]: probably I need to teach the app to restart after C-c Kill
[Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO
[Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute
[LanX]: will try infinite loop ...
[Corion]: :START ... goto START

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-03-27 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.