469,357 Members | 1,550 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,357 developers. It's quick & easy.

Passing Variables from One Perlscript to Another

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
1 9325
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.

Similar topics

2 posts views Thread by Sandman | last post: by
4 posts views Thread by Amr Mostafa | last post: by
2 posts views Thread by KaXo | last post: by
3 posts views Thread by domeceo | last post: by
3 posts views Thread by Lee | last post: by
2 posts views Thread by Jim Heavey | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.