title: Preserve plus signs from CGI input in Perl
body: <p>I'm working on a web application with several forms on which the user is expected to input data often containing spaces and/or plus signs.</p>
  
  <p>The data is generally sent either through <code>GET</code> requests; or through <code>POST</code> requests with a <code>application/x-www-form-urlencoded</code> Content-Type header.</p>
  
  <p>I have tried using either <code>Vars()</code> and <code>param</code> from Perl's <code>CGI</code> module, but both of these methods insist on converting the <code>+</code> signs into spaces.</p>
  
  <p>Does the <code>CGI</code> module provide any mechanism to preserve the <code>+</code> signs; or should I ditch <code>CGI</code> and manually parse the <code>STDIN</code> input?</p>
  
  <p><strong>Note</strong>:<br>
  With the large amount of forms (over the hundred), and having the CGI pre-processing happening in a centralized utility library, I'm quite biased towards a server-side solution rather than a client-side approach (in other words, I'd rather deal with the problem once on the pre-processing code once than adding JS noise on hundreds of places).</p>
  
  <p>Thanks in advance for any help provided.</p>
  
  <p><strong>Example</strong>:<br>
  As requested in the comments, here is a (simplified) sample of some code that triggers the issue.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form action="/cgi-bin/some-script.pl"&gt;
      &lt;input name="some_field" value="1 + 1 is 2"&gt;
      &lt;input name="submit" type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Perl</strong></p>
  
  <pre><code>use CGI;
  my $some_variable = CGI::param('some_field');
  </code></pre>
  
  <p>After submiting the form with the default value and running the server-side code, <code>$some_variable</code>'s value is <code>"1   1 is 2"</code> <em>(there are three spaces between the 1's, either the SO site or the browser may be collapsing them into a single space)</em>; the <strong>desired outcome</strong> would be to get the value <code>"1 + 1 is 2"</code> in that variable.</p>