You can get query param in CGI script with this code:
#!C:\Perl64\bin\perl.exe
use CGI;
my $cgi = CGI->new();
my $file = $cgi->param( "file" );
print "Content-Type: text/plain\n\n";
my $text = do {
open(my $f, "<:encoding(UTF-8)", $file)
or die("Can't open \$filename\": $!\n");
local $/;
<$f>
};
print $text;
but this don't work if request is POST, I'm sending this request using fetch API:
await fetch('cgi-bin/script.pl?file=..\foo.php', {
method: 'POST',
body: 'Some Text'
}).then(r => r.text());
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?
$cgi->url_param('file')perldoc.perl.org/CGI.html#MIXING-POST-AND-URL-PARAMETERS