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 = test

to show up as follows:

output1 = test
output2 = test
output3 = test

I 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;

In reply to Manipulating key/value output by coding_new

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.