如何测试用于从命令行上传文件的 Perl CGI 脚本?

How to test Perl CGI script for file upload from the command line?

我有一个调用 my $file_handle = $cgi->upload('uploaded_file') 的 Perl 脚本。有没有办法在部署到 Web 服务器之前从命令行测试这个脚本?我查看了 (How can I send POST and GET data to a Perl CGI script via the command line?) 和其他问题,但找不到任何有关通过命令行上传文件的信息。在此先感谢您的帮助。

文件上传只是另一个 POST 请求!参见 DEBUGGING in CGI.pm。程序为index.pl,要上传的文件为somefile.bin,表单域名称为uploaded_file:

REQUEST_METHOD=POST \
CONTENT_TYPE='multipart/form-data; boundary=xYzZY' \
perl index.pl < <(
    perl -MHTTP::Request::Common=POST -e'
        print POST(
            undef,
            Content_Type => "form-data",
            Content => [ uploaded_file => [ "somefile.bin" ]]
        )->content
    '
)