Read binary data from pipe in perl
<p>I want to write a Perl script which captures binary data from a pipe and read the binary data inside Perl and process the received binary content as file handler.</p>

<p>I am able to receive the binary content from pipe and the problem is here that the binary format is not preserved correctly while reading the data from Perl . The NUL character are not preserved and converted this character as newline in Perl environment. Following is the command line arguments and sample </p>

<pre><code>&gt;more D:\Sample_binary.zip| perl readpipe.pl D:\sample_output.txt
</code></pre>

<p><strong>readpipe.pl</strong></p>

<pre><code>local $/;   
my $lines = &lt;STDIN&gt;; # Read the binary data from pipe
open my $IN, "+&lt;", \$lines; # Load the content as file handler
$zip = Archive::Zip-&gt;new;
$zip-&gt;readFromFileHandle ($IN); # Read ZIP file from the received binary data
</code></pre>