5 my $body_filename = $ARGV[0];
6 my @command = @ARGV[1 .. $#ARGV];
9 my $body_size = -s
$body_filename;
10 $ENV{"CONTENT_LENGTH"} = $body_size;
11 open(my $body_fh, "<", $body_filename) or die "Cannot open $body_filename: $!";
13 defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!";
17 my $pid = open(my $out, "|-", @command);
19 # disable buffering at $out
20 my $old_selected = select;
25 print $out $body_data or die "Cannot write data: $!";
29 die "Command did not exit after reading whole body";
33 my $ret = waitpid($pid, 0);
35 die "confusing return from waitpid: $ret";