title: How to get query string parameters from POST request in CGI Perl script?
body: <p>You can get query param in CGI script with this code:</p>
  
  <pre><code>#!C:\Perl64\bin\perl.exe
  
  use CGI;
  
  my $cgi = CGI-&gt;new();
  
  my $file = $cgi-&gt;param( "file" );
  print "Content-Type: text/plain\n\n";
  
  my $text = do {
      open(my $f, "&lt;:encoding(UTF-8)", $file)
        or die("Can't open \$filename\": $!\n");
      local $/;
      &lt;$f&gt;
  };
  
  print $text;
  </code></pre>
  
  <p>but this don't work if request is POST, I'm sending this request using fetch API:</p>
  
  <pre><code>await fetch('cgi-bin/script.pl?file=..\foo.php', {
     method: 'POST',
     body: 'Some Text'
  }).then(r =&gt; r.text());
  </code></pre>
  
  <p>if I open the script in Browser I get content of the file. Is there a way to tell CGI module to get params from QueryString instead of POST data? or any other raw way to parse Query String without CGI module in Perl?</p>