I'd like to get a list of the variables that CGI.pm is passing around. I've read How do I get at the parameters in my CGI program?, CGI variables, and the CGI.pm documentation (specifically the section titled "Fetching the Parameter List As A Hash:". Unfortunately, one of my (many) shortcomings as a new programmer is that it's difficult for me to read about an abstract idea and put it into real practice. I hope as time goes on, this won't be so difficult.

I've tried the following code to print out my hash list of CGI variables. I'm expecting to see something about the cartoon/sitcom couples I've listed to show up, but I get nothing returned (other than the line "Begin testing area.")

My greater purpose in understanding this snippet is so that I can potentially use it in my program. I'm using HTML::Template, CGI.pm to generate some web pages. From one of the generated web pages, I'd like to click on one of the cells in a table and launch the next .pl file, but carry along with it some of the variables that help define what that cell is (for instance, income account row intersecting with the current month row).

Below is what I have:

#!/usr/local/bin/perl5_8 use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; my $CGI = new CGI ( { 'fred' => 'ethel', 'ricky' => 'lucy', 'fred' => 'wilma', 'barney' => 'betty' } ); $|=1; print $CGI->header; print "Begin testing area.<br>\n"; my ($params, @foo, %params); $params = $CGI->Vars; print $params->{'address'}; #<--- what is "address"? @foo = split("\0",$params->{'foo'}); %params = $CGI->Vars; print $params->{'address'}; use CGI ':cgi-lib'; $params = Vars;
I don't know what 'address' refers to, but I typed the example almost exactly as I saw it in the CGI.pm docs (I used $CGI instead of $q since that's what I have in my real program). I also often use Data::Dumper to help me see what's actually in my variables but it also shows nothing (I'm just learning D::D as well).

Any ideas on how to get a list of passed variables? Thanks!

Lori


In reply to Getting hash of CGI variables by Lori713

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.