title: How to capture the result of a command sent using Expect
body: <p>I have to capture output of the send command when using Perl <a href="https://metacpan.org/pod/Expect" rel="nofollow"><code>Expect</code></a> module.</p>
  
  <p>I know that in shell or Tcl I can use <code>puts $expect_out(buffer);</code> to capture the previously run command.</p>
  
  <p>How can I do the same thing in Perl?</p>
  
  <p>I am sending below command on remote machine:</p>
  
  <pre><code>$expect-&gt;send("stats\n");
  </code></pre>
  
  <p>I need to capture the <code>stats</code> output in some variable.</p>