in reply to Writing PDF binary file from stream yields malformed PDF

Use the three argument open and set the the files' layer to raw

binmode STDIN, ':raw'; my $output_file = shift @ARGV; open my $out_fh, '>:raw', $output_file or die "could not open $output_ +file: $!\n"; while( my $line = <STDIN> ){ print {$out_fh} $line or die "could not print to $output_file: $!\ +n"; } close $out_fh or die "could not close $output_file: $!\n";
</code>

Replies are listed 'Best First'.
Re^2: Writing PDF binary file from stream yields malformed PDF
by another_monkey (Initiate) on Jun 27, 2013 at 07:34 UTC
    Thanks! I've tried it, but it still doesn't work on the special PDF (works for others, not for the problematic one). I've also applied Anonymous's corrections (thanks!).
Re^2: Writing PDF binary file from stream yields malformed PDF
by Anonymous Monk on Jun 27, 2013 at 00:03 UTC

    Use the three argument open and set the the files' layer to raw

    three argument good, with :raw good, while good, binmode is :raw