Passing Variables from One Perlscript to Another

Discussion in 'Perl' started by Joe, Sep 30, 2003.

  1. Joe

    Joe Guest

    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.
    Joe, Sep 30, 2003
    #1
    1. Advertising

  2. Joe

    Jim Gibson Guest

    In article <ekneb.2343$>, Joe
    <> 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.
    Jim Gibson, Oct 1, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve C. Orr, MCSD
    Replies:
    0
    Views:
    494
    Steve C. Orr, MCSD
    Aug 8, 2003
  2. Prakash R.
    Replies:
    1
    Views:
    296
    Child
    Aug 8, 2003
  3. Robert Cohen
    Replies:
    3
    Views:
    270
    Andrew Durstewitz
    Jul 15, 2003
  4. Joe
    Replies:
    7
    Views:
    208
    David McDivitt
    Oct 1, 2003
  5. Guest
    Replies:
    6
    Views:
    135
    Joe Smith
    Jul 25, 2004
Loading...

Share This Page