<?xml version="1.0" encoding="windows-1252"?>
<node id="1003666" title="How to concatenate N binary buffers?" created="2012-11-13 11:59:38" updated="2012-11-13 11:59:38">
<type id="115">
perlquestion</type>
<author id="947751">
mantager</author>
<data>
<field name="doctext">
&lt;p&gt;Hi monks,&lt;br /&gt;
I'm really seeking for your wisdom, since I can't get up with an aswer from the net to this question: how do I concatenate two buffers I got from a couple of sysread()? &lt;/p&gt;

&lt;p&gt;Here is my pseudocode:&lt;br /&gt;
&lt;code&gt;
my $bufsize = 256 * 1024;
sysopen my $in1, 'somefile', O_RDONLY;
sysopen my $in2, 'someother', O_RDONLY;
sysopen my $out, 'outputfile', O_WRONLY|O_CREAT|O_TRUNC;

binmode($in1);  # Is this necessary?
binmode($in2);
binmode($out);

while (sysread($in1, my $buf1, $bufsize) &amp;&amp; 
    sysread($in2, my $buf2, $bufsize)) {

        my $data = &lt;CONCAT $buf1 &amp; $buf2&gt;; # HOW?
        syswrite $out, $data, 2 * $bufsize;
}
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Anyone can help me, please?&lt;br /&gt;
Thanks in advance.&lt;/p&gt;</field>
</data>
</node>
