 <p>You can use <a href="http://p3rl.org/IPC%3a%3aOpen2" rel="nofollow"><code>IPC::Open2</code></a> to attache two file handles, one to the input and one to the output of a program. It may be closer to what you really want to use <a href="http://p3rl.org/IO%3a%3aSocket%3a%3aSSL" rel="nofollow"><code>IO::Socket::SSL</code></a>, which functions like <code>IO::Socket::INET</code> but encrypted.</p> <p><strong>Update:</strong> My best guess is that your doubling up <code>\r</code> characters. According to the man page for <code>s_client</code> <code>-crlf</code> converts line feeds into carriage return + line feed. An when you print to the <code>$sslwrite</code> handle you are sending <code>"\r\n"</code>. I think the result would be that the server would receive "\r\r\n" at the end of each command. You probably want to drop the <code>-crlf</code> from the <code>openssl</code> command in your program.</p>