Advice about cgi programming

N

newbiegalore

Hello everyone :) ,
I am a newbie to Perl, but have
experience with other scripting languages. I am putting up this post
to ask for advice regarding what skills I would need to get a task
done. This might not be the most appropriate group, but since Perl is
used a lot for server back-end scripts, I guess a lot of people have
experience with using it for building web applications.

My task: I have bought a domain and now want to set up a website on
it.

What will the site do: Accept a string from the user, like Google does
(A very simple design). Then the site will check this string for the
presence of a substring. The output will be displayed in a simple text
box on the main page (to begin with).

If I have a script that will do this operation, I need to link the
input string to this script in the background and return the result.
Is CGI programming used to make this "glue" ? I could ask someone to
access the script directly on my site like

http://www.mysite.com/myscript<params> .. but I want to separate the
interface from my programs. Any advice would be greatly appreciated. I
know how to code in C, C++,Awk, Bash and some more languages. Sorry if
my questions seems overly naive :D.

Thanks in advance,
-A
 
X

xhoster

newbiegalore said:
Hello everyone :) ,
I am a newbie to Perl, but have
experience with other scripting languages. I am putting up this post
to ask for advice regarding what skills I would need to get a task
done. This might not be the most appropriate group, but since Perl is
used a lot for server back-end scripts, I guess a lot of people have
experience with using it for building web applications.

Isn't that kind of like parking illegally, then turning on your four-way
flashers to advertise "yes, I know it is illegal, but I am doing it
anyway"? To be generous, I'll assume you have at least some vaguely
good-faith intention of considering Perl for your task.
My task: I have bought a domain and now want to set up a website on
it.

What will the site do: Accept a string from the user, like Google does
(A very simple design). Then the site will check this string for the
presence of a substring. The output will be displayed in a simple text
box on the main page (to begin with).

Every sting will have a substring present in it (the null string if
nothing else). There is no need to check--it will be there. Are you
looking for a *specific* substring?
If I have a script that will do this operation, I need to link the
input string to this script in the background and return the result.

What do you mean by "in the background"
Is CGI programming used to make this "glue" ?

It certainly can be.
I could ask someone to
access the script directly on my site like

http://www.mysite.com/myscript<params> .. but I want to separate the
interface from my programs.

Your task is so simple I see no benefit to be had from such separation.
Of course, your task could evolve to be non-simple, but then it would
depend on what what way it becomes non-simple. It is kind of like saying
"I want to drive to the capital of some state, but without knowing
which state it is can you tell me which direction to start driving?"
Any advice would be greatly appreciated. I
know how to code in C, C++,Awk, Bash and some more languages. Sorry if
my questions seems overly naive :D.

If you know many other languages but not Perl, then you might want to
consider using one of them and learning only CGI, rather than learning
both Perl and CGI simultaneously. I know of some Perl modules (CGI.pm,
mostly) that help do CGI from Perl. I'm sure at least some of those other
languages have such helper libraries as well, but this being a Perl group
and all, I don't know of any specifically to recommend for those other
languages.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
N

newbiegalore

Isn't that kind of like parking illegally, then turning on your four-way
flashers to advertise "yes, I know it is illegal, but I am doing it
anyway"? To be generous, I'll assume you have at least some vaguely
good-faith intention of considering Perl for your task.





Every sting will have a substring present in it (the null string if
nothing else). There is no need to check--it will be there. Are you
looking for a *specific* substring?


What do you mean by "in the background"


It certainly can be.



Your task is so simple I see no benefit to be had from such separation.
Of course, your task could evolve to be non-simple, but then it would
depend on what what way it becomes non-simple. It is kind of like saying
"I want to drive to the capital of some state, but without knowing
which state it is can you tell me which direction to start driving?"


If you know many other languages but not Perl, then you might want to
consider using one of them and learning only CGI, rather than learning
both Perl and CGI simultaneously. I know of some Perl modules (CGI.pm,
mostly) that help do CGI from Perl. I'm sure at least some of those other
languages have such helper libraries as well, but this being a Perl group
and all, I don't know of any specifically to recommend for those other
languages.

Xho

--
--------------------http://NewsReader.Com/--------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

I got hold of a nice resource http://hoohoo.ncsa.uiuc.edu/cgi/ ...
don't really see the need for an illegal car parking analogy
though :D.. anyway thanks for the comments.
 
N

newbiegalore

newbiegalore said:
Hello everyone :) ,
I am a newbie to Perl, but have
experience with other scripting languages. I am putting up this post
to ask for advice regarding what skills I would need to get a task
done. This might not be the most appropriate group, but since Perl is
used a lot for server back-end scripts, I guess a lot of people have
experience with using it for building web applications.
My task: I have bought a domain and now want to set up a website on
it.
What will the site do: Accept a string from the user, like Google does
(A very simple design). Then the site will check this string for the
presence of a substring. The output will be displayed in a simple text
box on the main page (to begin with).
If I have a script that will do this operation, I need to link the
input string to this script in the background and return the result.
Is CGI programming used to make this "glue" ? I could ask someone to
access the script directly on my site like
http://www.mysite.com/myscript<params> .. but I want to separate the
interface from my programs. Any advice would be greatly appreciated. I
know how to code in C, C++,Awk, Bash and some more languages. Sorry if
my questions seems overly naive :D.

Perl is an excellent choice for writing CGI programs. You can't do the
newer "Web 2.0" with CGI, but you can still do a lot. Even if you are
planning to do the fancy stuff later, it is good to have a good
grounding in CGI.

Consider using the Perl CGI module. It has lots of methods for
generating HTML and also for handling form data. It also has two
different types of interfaces: function calls and object-oriented
methods.

Do 'perldoc CGI' at a command-line prompt to read the documentation on
CGI. It should be installed with most Perls. If not, you can get it
from CPAN <http://www.cpan.org>

My recommendation is to use the object-oriented methods of CGI instead
of the functions. It provides a cleaner interface and is a good
introduction to OO in Perl. For generating HTML, I usually use plain
old print statements rather than the CGI routines, and check out "here"
documents. If you want to generate complex HTML pages, consider using a
templating system (there are several on CPAN) or a content-management
system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top