For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > April 2005 > RE: [NOVICE] calling perl program within a cgi script with parameters from html form









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [NOVICE] calling perl program within a cgi script with parameters from html form
Charles K. Clarkson

2005-04-27, 3:55 am

Sean Davis <mailto:sdavis2@mail.nih.gov> wrote:

: suppose my form values are stored in variables
: $a =3D param('name')
: $b =3D param('age')
:=20
: Now I need to call a perl function wth $a, $b as parameters.
: My $string =3D "perl test.pl $a $b"
: system($string)
:=20
: This is wht I am using now. when I try=A0 eg: perl test.pl john =
12=A0=A0=A0
: It works. And the variables are bnided properly in cgi script. I
: cheked to make sure. Can=A0anyone suggest how i should proceed.

First we need to cover some basics. You should refrain from
using $a and $b as variable names. They are used in sort() and it
can get confusing as you progress as a programmer. Use meaningful
variable names, even for small test scripts. It's a good habit.

Avoid naming a script test.pl. It is a common name for scripts
and you may find yourself running some other program than you
intended. Also investgate the use of the "strict" and "warnings"
modules at the beginning of all your scripts.

Do you have access to the test.pl script? Can you change it?
If you can, I would advise not using an external system command
to run another perl script. There are numerous internal perl
methods available.

Without looking at the script I can't tell much. Show us some
example code including the source of test.pl.

HTH,

Charles K. Clarkson
--=20
Mobile Homes Specialist
254 968-8328


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com