title: Perl Regex not finding pattern within script
body: <p>I'm reading the contents of a log file, performing a regex on the lines and putting the results in an array, but for some reason there is no output.</p>
  
  <pre><code>use strict;
  use warnings;
  
  my $LOGFILE = "log.file";
  my $OUTFILE = "out.file";
  
  open(LOG, "$LOGFILE") or die ("Could not open $LOGFILE: $!\n");
  open(TMP, "&gt;", "$OUTFILE") or die ("Could not open $OUTFILE: $!\n");
  
  my @data = (&lt;LOG&gt; =~ /&lt;messageBody&gt;(.*?)&lt;\/messageBody&gt;/sg);
  
  print TMP "This is a test line. \n";
  
  foreach (@data){
     print "@data\n";
     print "\n=======================\n";
  }
  
  close TMP;
  close LOG;
  </code></pre>
  
  <p>My output is a file (out.file) and the only content is "This is a test line."  I know the regex works because I tried it at the prompt with:
   -lne 'BEGIN{undef $/} while (/(.*?)&lt;/messageBody>/sg) {print $1} log.file > test.file</p>
  
  <p>What am I doing wrong?</p>