Adding "is a step in the right direction, but you don’t think it $datamight contain ", $etc. You can use String :: ShellQuote to solve this problem.
use String::ShellQuote qw( shell_quote );
my $cmd = shell_quote(
curl => (
'-sS',
'-X' => 'POST',
'-H' => 'Content-Type: application/gzip',
'--data-binary' => $data,
$url,
),
);
my $output = `$cmd`;
Or you can completely abandon the shell.
my @cmd = (
curl => (
'-sS',
'-X' => 'POST',
'-H' => 'Content-Type: application/gzip',
'--data-binary' => $data,
$url,
),
);
open(my $pipe, '-|', @cmd) or die $!;
my $output = do { local $/; <$pipe> };
close($pipe);
Or, if you really don't need to write output, the following also completely excludes the shell:
system(
curl => (
'-sS',
'-X' => 'POST',
'-H' => 'Content-Type: application/gzip',
'--data-binary' => $data,
$url,
),
);
, , , NUL-, gzipped. , .
, libcurl ( curl) Net:: Curl:: Easy?