hidden value

in one perl script i try to send
a variable to another script
like this

        print "</table>";
                         print $q->submit;
                         print $q->reset;
                    print hidden(-name=> 'file', -value => $bestfile);
         print "<br>";

                         print $q->endform;        

and then in the next script i try to get that value by doing

print "QS is $ENV{QUERY_STRING}<br>";      

but it just prints out "QS is "

thanks
   
paulwhelanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mattropeCommented:
Are you submitting your form using the GET or POST method?  (GET is the default)

Also check the actual HTML source code to make sure the proper HTML is getting generated (there should be an <INPUT TYPE=hidden> field in there after the submit and reset button...
0
paulwhelanAuthor Commented:
im using post

the hidden tag is in there (see original question)

0
mattropeCommented:
Okay, when you use POST, the variables come into your script through STDIN rather than through an environment variable.  You can either switch your program to use GET, or you can read the data from STDIN.  Be aware that either way, you'll still have to decode and separate the values for the variables.

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

mattropeCommented:
By the way, if you don't know how to decode the incoming form data, there are libraries that can do it for you (cgi.pm, cgi-lib.pl, etc.)
0
paulwhelanAuthor Commented:
ao if $ENV{QUERY_STRING} is set to the value in post
then what is the variable in get?
$stdin????
0
mattropeCommented:
In GET, the variable that contains the encoded data is $ENV{QUERY_STRING}.

In PUT, the data is not in a variable yet, but rather in the STDIN filestream (so you read it into a variable and decode it yourself).


Here is a snippet of code from cgi-lib.pl that deals with this.  Note that for the POST case, the data is read from STDIN:

    if (!defined $meth || $meth eq '') {
      $in = $ENV{'QUERY_STRING'};
      $cmdflag = 1;  # also use command-line options
    } elsif($meth eq 'GET' || $meth eq 'HEAD') {
      $in = $ENV{'QUERY_STRING'};
    } elsif ($meth eq 'POST') {
        if (read(STDIN, $in, $len) != $len) {$errflag="Short Read\n";};
    } else {
      &CgiDie("cgi-lib.pl: Unknown request method: $meth\n");
    }
0
mattropeCommented:
It appears that you are using CGI.pm.  If that is the case, you can have all of your CGI variables automatically read into a hash called %in by doing the following:

  CGI::ReadParse();

Then you can access your variables as follows:

  print "QS is $in{file}<BR>";



0
mrachowCommented:
I do not know exactly whats going on here, but there is one thing you should be aware of.
If you define (maybe implicitly) something in the environment it will be lost after a script had finished. When another script starts working it do so with a (re)fresh(ed) environment.
If things in the environment should live longer as for the lifetime of a called script you have to do special things depending on the operating system you are using.
But as I said at the beginning ...
0
ozoCommented:
use CGI;
$q = CGI::new;
print $q->param('file');
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.