I agree that an upgrade of Perl would be the first step. However, in some instances, upgrades and loading of modules may not be allowed. In that case, I have a couple of routines that may help out. The first will simply get the form parameters into a string which you can then manipulate yourself:
sub GetParams { my $webparams; if ($ENV{'QUERY_STRING'} ne '') { $webparams = "$ENV{'QUERY_STRING'}"; } else { read(STDIN, $webparams, $ENV{'CONTENT_LENGTH'}); } return $webparams; }
This one is a bit more complex. It will return a hash where the keys are the names of the inputs on the html form and the values are, of course, the values of the inputs. If you have things like multi-select list boxes, you should choose to return a hash of arrays. The data will then be accessed like:
$hash{input_name}[0] $hash{input_name}[1]
To find out how many items were returned for a given key, use:
my $numitems = $#{$hash{input_name}};
This routine takes one or two parameters which are specified in the code:
sub GetParamsHash { my $type = shift; # type = 0 or not included returns a hash # type = 1 returns a hash of arrays my $webparams = shift; my $webparams2; my %webparams3; if(!$webparams) { if ($ENV{'QUERY_STRING'} ne '') { $webparams = "$ENV{'QUERY_STRING'}"; } else { read(STDIN, $webparams, $ENV{'CONTENT_LENGTH'}); } } if($type == 1) { $webparams2 = $webparams; $webparams2 =~ s/\&/\n/g; $_ = $webparams2; while(/^(.*?)=(.*)$/gm){ push @{$webparams3{$1}}, $2; } } else { $webparams2 = $webparams; $webparams2 =~ s/\&/\n/g; $_ = $webparams2; %webparams3 = /^(.*?)=(.*)$/gm; } return %webparams3; }
One important thing to remember is that the data sent from the html form may be encoded. I have another very simple routine that is quite helpful in decoding this data:
sub DecodeURL { my $text = shift; $text =~ tr/\+/ /; $text =~ s/%([a-f0-9][a-f0-9])/chr(hex($1))/eig; return $text; }

In reply to Re: How do I save the result of POST to a file? by ChrisR
in thread How do I save the result of POST to a file? by Anonymous2003

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.