title: Show output from Perl script in Matlab in real time
body: <p>I have matlab function that calls a Perl script which converts a large text file to binary for use in Matlab. See here for Perl script details: <a href="https://stackoverflow.com/questions/8567774/parsing-unsorted-data-from-large-fixed-width-text">Parsing unsorted data from large fixed width text</a></p>
  
  <p>My Matlab function looks something like this</p>
  
  <pre><code>function convertMyData(dataFileName)
  
  %Do some checks on the data
  disp('Done Checking Stuff!');
  
  %Process data file with Perl
  perl('myPerlScript.pl',dataFileName)
  
  % More Processing on the Binary output from Perl
  disp('All Done!');
  </code></pre>
  
  <p>In the perl script are some print statements showing the progress of the script since it can take several minutes to convert. Something like this:</p>
  
  <pre><code>while ($line = &lt;INFILE&gt;) {
      if ($lineCount % 100000 == 0){ #Display Progress every 100,000 lines
          print "On Line: ".$lineCount."\n";
      }
      #PROCESS LINE DATA HERE 
      $lineCount ++; 
  } # END WHILE &lt;INFILE&gt;
  print "Finished Reading: ".$lineCount." Lines\n";
  </code></pre>
  
  <p>The problem is that in Matlab all of my "On Line: XXXXX" <code>print</code> statements just get dumped to Matlab's default <code>ans</code> variable once the script completes instead of actually displayed at the prompt like Matlab's <code>disp()</code> function.</p>
  
  <p>So how (if possible) do you get an external program's output to show up at the Matlab prompt while it is running?</p>