CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
it said beginner so......



Jun 17, 2000, 5:51 AM

Post #1 of 6 (1188 views)
it said beginner so...... Can't Post

Hello. I am VERY new to perl and I wantt o make a script but i don't know the best way to go about it.... aswell as not kowing how to do it.

I want to write a newsscript that will use SSI to call the news to the mainpage. My script will be two textboxes (one for the subject which will be written in red text and bigger and one for the message which will be normal black), and when it is subkitted will write to a html document. I need to know how to write what is written in the text box to this document and how to, when there is already something written there, overwrite it.

i am doing this so i dont have to always modify the webpage manually and then upload it. So I will place the SSI tag on the mainpage. Obviously this will point to one page so I need to make the script use the same page to write the new news to but it has to delte the old lot first.

i hope you all understand and please reply as I REALLy need help.


User / Moderator

Jun 17, 2000, 2:29 PM

Post #2 of 6 (1188 views)
Re: it said beginner so...... [In reply to] Can't Post


Your post is a little bit vague, but if I'm reading what I think you meant -- and I'm really not sure -- then you want to create a CGI form with processing logic along the following lines ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use CGI;
if ( defined param('subject') ) {
open SUBJ, "> /path/to/" )
or die "Cannot open /path/to/ $!";
print SUBJ param('subject');
close SUBJ;

... and then repeat the if ( ... ) loop for the message.

Then you can slap an <font color="#ff0000"><!--#include file="/path/to/" --></font> into your HTML to include the data.


Jun 17, 2000, 2:44 PM

Post #3 of 6 (1188 views)
Re: it said beginner so...... [In reply to] Can't Post

Hello, thanks for your reply.

Basically, all I do want is a way of taking what is entered into a text box and putting it into a html document.

I am going to be writing this in Perl, not CGI as I haven't got to the chapter on programming CGi yet Smile

I don';t really understand your code. What is the

So thr things I need help on are these....

A way to take what is written in the sujefct and message boxes and display on screen.

The other thing is this. I want to write it to a html document but it has to be the sme html document each time so that it will automatically update the main page (this is because the html pasge created by the script is begin called in vai SSI). The script will always create a page called P1.html. I would like to know how to make it so that if there is already a page there called P1.shtml then it will automartically be renamed to something else so that the new news will now be P1.shtml.

I hope this has helped it become more clear . My describing is quite poor though.

Please help me. Thanks alot (the most important thing is being able to take the contents of a text box and ut it in a html doc)


Jun 18, 2000, 11:46 PM

Post #4 of 6 (1188 views)
Re: it said beginner so...... [In reply to] Can't Post

FYI, a perl program (or any other program) that generates HTML for a web page _is_ a CGI.

The term helps distinguish a perl program that's intended for a web browser vs. a program thats intended to be run from a prompt.

That's the basics of it, at least.

Dr. Zed

User / Moderator

Jun 19, 2000, 3:27 AM

Post #5 of 6 (1188 views)
Re: it said beginner so...... [In reply to] Can't Post

Tom-- would be a file that contains the subject to be included. Then you could include that file into your HTML via SSI (<font color="#ff0000"><!--#include file="" --></font>) to get the effect you're looking for.

Anyhoo, I think I'm getting too lost in your description to be of any real help, and I suspect you're a tad confused about what you need.

What is this 'text box' you keep referring to if it's not part of a form? Can you perhaps show us the components you already have? Can you show us what you've already tried?

Anything to help us better understand what it is you're trying to do as articulation of the problem is half the battle. :-)

As for renaming existing files, you could do something like ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

my $file = "P1.shtml";
my $new = "";
my $old = "P1.shtml.old";

if ( -e $file ) {
or die "Can't rename($file,$old): $!";
or die "Can't rename($new,$file): $!";
} else {
open FILE, "> $file"
or die "Can't open($file): $!";
print FILE "...";
close FILE;


Jun 19, 2000, 6:34 AM

Post #6 of 6 (1188 views)
Re: it said beginner so...... [In reply to] Can't Post

Hello, I se how you can be confused. This is what I am aiming to do:

I am making a script which will work like a bulletin board but it is in fact a way of typing up the latest news. In the admin area there will be a Message text box and a subject textbox. When submit is hit I want the text from the subject text box and the message box to be written to a webpage.

As for the renaming part. The whole point of the script is to stop me having to update the htm,l page (downloading, modifying uploading etc) so the SSI tag needs to stay the same (pointing to ther same page). So when the latest news is inputted I either want to know how to rename the current file and make a new one with the new news on (so it will be shown on the pages with the SSI in) or I want to know how to mke it so that it will overwrite all the text already on that page.

i have the password protection of the script in place but I don;'t know how to take what is in the twop textboxes and display it on the page. That is what I need help with.

I hope you now understand anmd thanks for your help Smile

errrr, what?


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives