Don Doucette wrote:
hello everyone.
my name is don doucette and I am 38 years old and have been involved with computers since the Timex Sinclair.



Ok. Please use a more informative subject line.

I have recently set up a server and am hosting a web site and forum for my community association.

I am running the YaBB forum (http://www.yabbforum.com/) and I would like to do the following...

I would like to use perl to look in a directory of numerical named .txt files (as in 0123456789.txt), find the file name with the largest number (as in 1234567890.txt is greater numerically than 0123456789.txt) then open the file and extract data from that file so it can be posted into a web page?

For instance...
I have a directory named Messages, in this directory there are the following files...


1108577587.txt
1108519222.txt
1108490078.txt
1108489912.txt

Obviously 1108577587.txt is greater numerically than the rest, this also happens to signify that this is the newest message. In this file is the following information...

Title of Post|Author|[EMAIL PROTECTED]|02/16/05 at 12:13:07|Group|xx|0|192.168.1.1|Message||

As you can see this file is delimited by | and ends with ||
I would like to parse out the Message field first then the Author field and assign their value to a variable then insert the variable into html on a page.


Something like...
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<p>Here is the newest post to the forum<BR><BR>
$Message <BR><br>
Posted by $author </p>
</body>
</html>

The idea is when the main web page loads it always shows the newest post to the forum and who posted it.

My question REALLY is do you think this can be easily done or is this a huge programming effort for someone just trying to figure out perl... I have been thumbing through my Perl book (The Complete Reference Perl Second Edition) but it hasn't really been helpful so far.

Thanks for your advice.



Clearly you have a good spec which is about the best start. In general this is a forum for specific questions about CGI, which sort of fits, but you might be better off with just the beginners@perl.org for non-cgi related questions, as yours are more general. Though they are also forums for learning, rather than getting free code so we usually like to see what you have tried first. Having said that....


To get to your actual question, what you are talking about doing is pretty simple in Perl. I am not familar with that particular book, if you are interested in learning Perl you should check out the Llama from O'Reilly, aka Learning Perl. Having read that you should be able to solve the above problem. If you don't want more books and can read tech docs, then you should start with,

perldoc perlopentut
perldoc -f opendir
perldoc -f readdir
perldoc -f open
perldoc -f sort
perldoc -f split
perldoc -f print
perldoc CGI

Very little is a HUGE programming effort in Perl, that is why it is so loved by its users...

Good luck,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to