By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Passing Variables from One Perlscript to Another

P: n/a
Joe
I am trying to write a Perlscript to be used with some HTML pages. Here is
how it works:

1.. The first HTML page has a form which requests for user input. Then it
passes the QUERY_STRING to a Perl script.
2.. The Perl script will then validate the data. If input validation
fails, it returns to the previous screen and asks the user to retry. If the
validation passes, it display the user input and asks for confirmation.
3.. If the user chooses okay to proceed, it will pass the validated data
to another Perl script to execute some queries from a database.
I can manage to go from step 1 to step 2. But I don't know how to pass the
variables from one Perl script to another. I am not sure if I should use
the POST or GET method. I think there should be some better ways.


Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <ek*****************@news20.bellglobal.com>, Joe
<pa****@netzero.com> wrote:
I am trying to write a Perlscript to be used with some HTML pages. Here is
how it works:

1.. The first HTML page has a form which requests for user input. Then it
passes the QUERY_STRING to a Perl script.
2.. The Perl script will then validate the data. If input validation
fails, it returns to the previous screen and asks the user to retry. If the
validation passes, it display the user input and asks for confirmation.
3.. If the user chooses okay to proceed, it will pass the validated data
to another Perl script to execute some queries from a database.
I can manage to go from step 1 to step 2. But I don't know how to pass the
variables from one Perl script to another. I am not sure if I should use
the POST or GET method. I think there should be some better ways.


This really isn't a perl question, but one about CGI programming. You
might get better results in another newsgroup, such as
comp.infosystems.www.authoring.cgi. This newsgroup (comp.land.perl) is
actually defunct, and you should try comp.lang.perl.misc for perl
questions in the future.

You pass variables from one perl script to another pretty much like any
other language: as command line arguments, subroutine variables,
environment variables, or something more complicated, depending upon
your platform and whether or not the two scripts are running within the
same process or not.

From your description, it sounds like the two scripts are called
separately at different times by two different web browser requests.
The methods for getting information from the first script to the second
are not language specific, but your general choices are: query
parameters, form data, or cookies.

I am assuming that the first script generates the page that invokes the
second script. Then you can: 1) add the data to the link that invokes
the second script, if it is a link, or, if it is a form, put the data
in a form and then process the form data in the second script. If you
don't want the user to see or be able to edit the data, put the data in
hidden form elements. Your second script will receive them anyway.

You can also send the user a cookie in the response to the first form.
Then, if the user does not have cookies disabled, you will receive the
cookie with the request for the second form.

You should consider using the CGI.pm module if you are not already
doing so.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.