Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   What is the best way to make a Tree Data Structure in one text file? (http://www.velocityreviews.com/forums/t887700-what-is-the-best-way-to-make-a-tree-data-structure-in-one-text-file.html)

http://links.i6networks.com 08-19-2004 05:49 PM

What is the best way to make a Tree Data Structure in one text file?
 
I want to write a tree and read the tree from one text file by Perl's
regular expression.

What is the best way to do it in term of speed.

I want to be able to select sub note and search all note and search with a
sub note.

It is really like a Forum, but saves everything in one text file.

Here is some of my ideas:

design 1:

parentname1:childname1:childdata1
parentname1:childname2:childdata2


design2:
parentname
childname1:childdata1
childname2:childdata2

design2 saves space, but design2 also requries everything is in order.
design1 allow me just appent lines to the file.

Any other better designs?



John Bokma 08-19-2004 06:44 PM

Re: What is the best way to make a Tree Data Structure in one text file?
 
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in
news:3L5Vc.832$NRf.30@news04.bloor.is.net.cable.ro gers.com:

> I want to write a tree and read the tree from one text file by Perl's
> regular expression.
>
> What is the best way to do it in term of speed.


dump a hash of hashes to a file and read it back

> I want to be able to select sub note and search all note and search
> with a sub note.


In your file, or after reading the data into memory?

> It is really like a Forum, but saves everything in one text file.


XML? Altough for a Forum I would recommend a database.

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html


All times are GMT. The time now is 12:42 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.