Teen Programmers Unite  
 

 

Return to forum top

Need help on Perl language

Posted by Perl [send private reply] at January 21, 2003, 12:50:01 AM

Thanks taubz and mop for replying!

I got some new questions again..

1) what are the diffs between .cgi and.pl??
Is it .cgi can have HTML codes in it but not .pl??
2) I still got some more questions, cant think of it now..thnks

Thank you

Posted by Perl [send private reply] at January 21, 2003, 12:51:27 AM

i'm so sorry, i have to start a new thread...i cant reply to me previous thread....

Posted by CViper [send private reply] at January 21, 2003, 01:27:03 AM

CGI's can be written in any language, including perl. There is no actuall difference between '.cgi' and '.pl', except the extension. Most people will simply use the extension .cgi.

You don't do any HTML tags directly in either .cgi/.pl; both are in your case simply perl-scripts/applications, which eventually will write a HTML document (or any other data) to stdout (which normally is the console, but the webserver will redirect it to itself). This data is then sent to whoever requested the page.

Posted by buzgub [send private reply] at January 21, 2003, 01:38:21 AM

Perl is just a programming language.

CGI is a method of making almost any program generate website output.

To use perl to generate a web page, you just write a program in perl using the methods to interact with the user of the web page dictated by the CGI system. CGI is not perl-specific, and perl is not specific to CGI.

I would suggest you do the following:
Learn how to write html
Learn how to write programs in python

If html will do everything you need to build your website, just use it. If it won't, but a program written in python will, use python to build your website.

Posted by taubz [send private reply] at January 21, 2003, 09:42:17 AM

Another important difference between .cgi and .pl is that your webserver may be set up to run only .cgi as cgi scripts and .pl files will just be considered text files.

- taubz

Posted by CViper [send private reply] at January 21, 2003, 10:47:19 AM

Isnt "chmod 755" (or 775, dont remember) supposed to tell the server/os that the file should be run (on unix/linux)?

(like 3. time I try to post this. somehow it didn't like me posting :/)

Posted by D_Dave [send private reply] at January 21, 2003, 12:16:12 PM

hmmmmm, not sure, i think you can only CHMOD on *nix. I think the CHMODing is a bit like file permissions, it is sometimes written as RRR (read read read) and is in 3 sections, Owner, Group, Other. A CHMOD of 777 would tell the server that everyone (Owner, Group, Other) can read, write and execute the file...

Get what i mean?

Dave

Posted by CViper [send private reply] at January 21, 2003, 12:51:43 PM

Ok... don't use *nix stuff very often. Just know that if I want my cgi's to run, I'll have to chmod them ;)

Posted by taubz [send private reply] at January 21, 2003, 12:55:27 PM

Perl CGI scripts must be chmod'ed 755 (use: rwx, group: rwx, other: just execute), must have the correct file extension so that the server software knows what to do with it (in Apache and others at least), and in Unix if the CGI is a script of some sort, then the script itself must contain the path to the interpreter. Perl scripts usually begin with the line

#!/usr/bin/perl

to indicate where the perl interpreter is.

While I'm on the subject, the Perl script must send out any HTTP headers before it sends any HTML, so Perl scripts usually do this somewhere at the beginning:
print "Content-type: text/html\n\n";


- taubz
Posted by Perl [send private reply] at January 21, 2003, 06:54:25 PM

Thank you for evryone replies!!!!!

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.