coding_new has asked for the wisdom of the Perl Monks concerning the following question:
First of this is my first real attempt into data manipulation so please bear with me. I have a script that so far takes some data from a form using get and manipulates it to produce the output of the data in the way that I want so far.
What I want to do next is take one of they key/values and merge it to the other key/values that I have outputing. Basically I want the following output
output1 = on output2 = on output3 = on announcement = testto show up as follows:
output1 = test output2 = test output3 = testI know how to manipuate the date to remove =on, but my issue is what is the best way and how do I take the announcement = test and then merge it to the output1 key. Below is my script so far. Thanks in advance for your help.
#!/usr/bin/perl # Read in text $method = $ENV{'REQUEST_METHOD'}; if ($method eq "GET") { $buffer= $ENV{'QUERY_STRING'}; }else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } # Split information into name/value pairs my @pairs = split (/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; $FORM{$name} = $value; } print "Content-type:text/html\r\n\r\n"; print "<html>"; print "<head>"; print "<title>CGI Program</title>"; print "</head>"; print "<body>"; foreach $name (sort keys(%FORM)) { print "$name = $FORM{$name}<BR>\n"; } print "</body>"; print "</html>"; 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Manipulating key/value output
by eff_i_g (Curate) on Jan 21, 2011 at 18:16 UTC | |
by coding_new (Sexton) on Jan 21, 2011 at 22:07 UTC | |
|
Re: Manipulating key/value output
by Anonyrnous Monk (Hermit) on Jan 21, 2011 at 18:31 UTC |