A slight correction: the above code is going to print
animal=pet. If you want to not use CGI.pm (bad, evil, you've been warned, etc.), then $pet is going to contain:
variable1=value1&variable2=value2...
Some fairly rudimentary parsing can get you what you need. However, then you might need to worry about how HTML encodes special characters (what if the user enters "<lephant" or something else silly?) which isn't too bad but you're quickly seeing why CGI.pm is probably a better choice.
Cheers,
Ardenstone
Update:
Here is some ugly not use strict-able code (it creates variables on the fly) that can parse out the environment string:
$myTmp = $ENV{'QUERY_STRING'};
@words = split '&',$myTmp;
my $counter = 0;
while ($words[$counter]) {
my @tmpWords = split '=',$words[$counter];
$tmpWords[1] =~ tr/+/ /;
$tmpWords[1] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
my $tmpName = $tmpWords[0];
$$tmpName = $tmpWords[1];
$counter++;
}
Now that's ugly. But it should work.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.