hidden value

Posted on 2000-02-24
Last Modified: 2010-03-05
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 "

Question by:paulwhelan

Expert Comment

ID: 2554295
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...

Author Comment

ID: 2554380
im using post

the hidden tag is in there (see original question)


Accepted Solution

mattrope earned 100 total points
ID: 2554399
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.

Expert Comment

ID: 2554402
By the way, if you don't know how to decode the incoming form data, there are libraries that can do it for you (,, etc.)
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.


Author Comment

ID: 2554420
ao if $ENV{QUERY_STRING} is set to the value in post
then what is the variable in get?

Expert Comment

ID: 2554440
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 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(" Unknown request method: $meth\n");

Expert Comment

ID: 2554455
It appears that you are using  If that is the case, you can have all of your CGI variables automatically read into a hash called %in by doing the following:


Then you can access your variables as follows:

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


Expert Comment

ID: 2554667
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 ...
LVL 84

Expert Comment

ID: 2555231
use CGI;
$q = CGI::new;
print $q->param('file');

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
String Substitution 4 65
syslog unix file 20 62
How to search multiple patterms in a file with perl? 4 77
Using Perl DBI to query oracle 3 30
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now