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

Question about message board making

by SYbeginner (Novice)
on Jun 12, 2000 at 06:04 UTC ( [id://17653]=perlquestion: print w/replies, xml ) Need Help??

SYbeginner has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to perl, and I just learned how to make a simple guestbook. But what if I want to make a message board with threads? I am thinking about arrays, but it seems those arrays are too much to be put into one text file. And I also studied message boards made by other people, but i just don't get it how they store the posts and make them into threads??

Replies are listed 'Best First'.
Re: Question about message board making
by chromatic (Archbishop) on Jun 12, 2000 at 06:13 UTC
    You've discovered why advanced data structures are necessary. (For reference, see perlref and perldsc.)

    No matter how you store your data, you need to keep track of some additional information, namely, the children of the current message. You could set up something like this:

    my %message = ( subject => 'this is a test message', date => '10 June 2000, 10 minutes into the X-Files rerun', author => 'chromatic', id => '001', children => [ 002, 004, 005 ], text = 'Hello, this is just a test message.');
    You could store that in a database or in a flat file somewhere. The important part is that you are keeping track of the threading in your persistent data structure. You'll have to come up with some way to update a parent message when someone replies to it, but getting your data structure right is 80% of the battle.
RE: Question about message board making
by btrott (Parson) on Jun 12, 2000 at 06:19 UTC
    All agree with what chromatic wrote, but I thought I'd add that when I've written message board apps in the past, I've also stored some "parent" data in my data structure, so that I can walk up the board tree as well as down.

    So you can add to your data structure something like:

    $message{parent} = 003;
    To go along w/ chromatic's structure.
Re: Question about message board making
by lhoward (Vicar) on Jun 12, 2000 at 07:07 UTC
    btrott and chromatic both have great suggestions.

    As you are starting to look at storing structured data, there some techniques you shoud consider:

    If you have access to a database, you should use it. Perl has a robust DBI module that provides interfaces to many SQL databases (it even has drivers that allow you to use flat files as if they were SQL databases). You may also want to check out the FreezeThaw, Data::Dumper and Storable modules. All of those modules provide ways to taking an in-memory data-structure and extracting it so it can be stored (on disk or otherwise) for later retrieval. If you have access to Advanced Perl Programming it has an excellent chapter on data-persistance that should really be in-line with what you're working on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://17653]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found