title: Perl - Parse blocks from text file
body: <p>First, I apologize if you feel this is a duplicate.  I looked around and found some very similar questions, but I either got lost or it wasn't quite what I think I need and therefore couldn't come up with a proper implementation.</p>
  
  <p>QUESTION:</p>
  
  <p>So I have a txt file that contains entries made by another script (I can edit the format for how these entries are generated if you can suggest a better way to format them):</p>
  
  <pre><code>SR4 Pool2
  11/5/2012 13:45
  ----------
  Beginning Wifi_Main().
  
  SR4 Pool2
  11/8/2012 8:45
  ----------
  This message is a
  multiline message.
  
  SR4 Pool4
  11/5/2012 14:45
  ----------
  Beginning Wifi_Main().
  
  SR5 Pool2
  11/5/2012 13:48
  ----------
  Beginning Wifi_Main().
  </code></pre>
  
  <p>And I made a perl script to parse the file:</p>
  
  <pre><code>#!C:\xampp-portable\perl\bin\perl.exe
  
  use strict;
  use warnings;
  #use Dumper;
  
  use CGI 'param','header';
  use Template;
  #use Config::Simple;
  
  #Config::Simple-&gt;import_from('config.ini', \%cfg);
  
  my $cgh = CGI-&gt;new;
  my $logs = {};
  my $key;
  
  print "Content-type: text/html\n\n"; 
  
  open LOG, "logs/Pool2.txt" or die $!;
  
  
  while ( my $line = &lt;LOG&gt; ) {
      chomp($line);
  
  }
  
  print $logs;
  
  close LOG;
  </code></pre>
  
  <p>My goal is to have a hash in the end that looks like this:</p>
  
  <pre><code>$logs = {
      SR4 =&gt; {
             Pool2 =&gt; {
                  {
                      time =&gt; '11/5/2012 13:45',
                      msg  =&gt; 'Beginning Wifi_NDIS_Main().',
                  },
                  {
                      time =&gt; '11/8/2012 8:45',
                      msg  =&gt; 'This message is a multiline message.',
                  },
             },
             Pool4 =&gt; {
                  {
                      time =&gt; '11/5/2012 13:45',
                      msg  =&gt; 'Beginning Wifi_NDIS_Main().',
                  },
             },
      },
      SR5 =&gt; {
             Pool2 =&gt; {
                  {
                      time =&gt; '11/5/2012 13:45',
                      msg  =&gt; 'Beginning Wifi_NDIS_Main().',
                  },
             },
      },
  </code></pre>
  
  <p>};</p>
  
  <p>What would be the best way of going about this?  Should I change the formatting of the generated logs to make it easier on myself?  If you need anymore info, just ask.  Thank you in advanced. :)</p>