title: Parsing a latex file in Perl
body: <p>Apologies for the very basic question!</p>
  
  <p>I just want to read in a latex file (so text basically) and output all the (say) theorems, which are always in the format</p>
  
  <pre><code>\begin{theorem}
  some lines of latex
  \end{theorem}
  </code></pre>
  
  <p>I always kind of figured Perl was the right language for this!</p>
  
  <p>Of course, I only know very basic programming in C++ and Java, and virtually no Perl.</p>
  
  <p>Nonetheless I can currently read in a text file, and process it line by line.</p>
  
  <p>It seems the most basic way to do this is:</p>
  
  <pre><code>($string =~ /pattern/) 
  </code></pre>
  
  <p>I started getting confused by then reading about control codes like ?,*+,$, etc. </p>
  
  <p>Any simple references or links to get me started?</p>
  
  <p>(I put this on here and not the Tex site, as it could be useful generally for reading text files, and not just LaTeX!)</p>