title: Relative Record Separator in Perl
body: <p>I have a data that looks like this:</p>
  
  <pre><code>id:40108689 --
  chr22_scrambled_bysegments:10762459:F : chr22:17852459:F (1.0),
  id:40108116 --
  chr22_scrambled_bysegments:25375481:F : chr22_scrambled_bysegments:25375481:F (1.0),
  chr22_scrambled_bysegments:25375481:F : chr22:19380919:F (1.0),
  id:1 --
  chr22:21133765:F : chr22:21133765:F (0.0),
  </code></pre>
  
  <p>So each record is separated by <code>id:[somenumber] --</code></p>
  
  <p>What's the way to access the data so that we can have a hash of array:</p>
  
  <pre><code>$VAR = { 'id:40108689' =&gt; [' chr22_scrambled_bysegments:10762459:F : chr22:17852459:F (1.0),'], 
  
           'id:40108116' =&gt; ['chr22_scrambled_bysegments:25375481:F :chr22_scrambled_bysegments:25375481:F (1.0)',
  'chr22_scrambled_bysegments:25375481:F : chr22:19380919:F (1.0),'
           #...etc
         }
  </code></pre>
  
  <p>I tried to approach this using record separator. But not sure how to generalize it?</p>
  
  <pre><code>{
      local $/ = " --\n";  # How to include variable content id:[number] ?
  
      while ($content = &lt;INFILE&gt;) {
        chomp $content;
        print "$content\n" if $content; # Skip empty records
      }
  }
  </code></pre>