title: How to use HTML::TokeParser to extract data
body: <p>I want to write a code to extract specific information from the imdb.com Awards Section. With the below snippet I can print the text as a whole</p>
  
  <pre><code>use strict; 
  use warnings;
  use autodie;
  use utf8;
  use WWW::Mechanize;
  use HTML::TokeParser;
  
  #Example
  my $url = 'http://www.imdb.com/title/tt1375666/awards';
  
  my $mech = WWW::Mechanize-&gt;new;
  $mech-&gt;agent_alias( 'Windows Mozilla' );
  $mech-&gt;get( $url );
  
  if ($mech-&gt;find_link(text_regex =&gt; qr/(?:Academy Awards|Golden Globes)/i)) {
  
      my $tp = HTML::TokeParser-&gt;new(\$mech-&gt;content);
  
      while (my $token = $tp-&gt;get_tag('big')) {
          $token = $tp-&gt;get_trimmed_text('big');
          if ( $token =~ /(?:Academy Awards|Golden Globes)/ ) {
  
              print "$token\n";
  
          }
      }
  
  }
  </code></pre>
  
  <p>but I don't know how to separate the different tokens because most of them have the same tags and also how to define the loop for each 'category/recipient' and print on new line if present.</p>
  
  <pre><code>my $year = $tp-&gt;get_trimmed_text();
  my $result = $tp-&gt;get_trimmed_text();
  my $award = $tp-&gt;get_trimmed_text();
  my $category = $tp-&gt;get_trimmed_text();
  my $recipient = $tp-&gt;get_trimmed_text();
  </code></pre>
  
  <p>print "$year $result $award $category $recipient\n"</p>
  
  <ol>
  <li>$year Won Oscar $category $recipient1..n</li>
  <li>etc.</li>
  <li>$year Nominated Oscar $category $recipient1..n</li>
  <li>etc.</li>
  <li>$year Won Golden Globe $category $recipient1..n</li>
  <li>etc</li>
  <li>$year Nominated Golden Globe $category $recipient1..n</li>
  <li>etc.</li>
  </ol>
  
  <p>I'm not sure if this is the most efficient approach but I also tried HTML::TableExtract with much less success.</p>
  
  <p>Thanks.</p>