 <p>The Problem has to do with the Perl source itself. Here's a piece of code from the function Perl_do_openn in file doio.c:</p> <pre><code>fd = PerlIO_fileno(IoIFP(io)); if (IoTYPE(io) == IoTYPE_STD) { /* This is a clone of one of STD* handles */ result = 0; } else if (fd &gt;= 0 &amp;&amp; fd &lt;= PL_maxsysfd) { /* This is one of the original STD* handles */ saveifp = IoIFP(io); saveofp = IoOFP(io); savetype = IoTYPE(io); savefd = fd; result = 0; } </code></pre> <p>if you open an existing filehandle, the filehandle will be closed and reopened by open(), This doesn't happen with STD* handles, as you can see from the code above. So perl takes the next free handle for opening and the older one remains open.</p>