title: Perl Script, Web Scraper
body: <p>I am new to Perl language and have this script which scrapes the amazon website for reviews. Everytime I run it I get an error about a compilation error. Was wondering if someone could shed some light as to whats wrong with it.</p>
  
  <pre><code>#!/usr/bin/perl
  # get_reviews.pl
  #
  # A script to scrape Amazon, retrieve reviews, and write to a file
  # Usage: perl get_reviews.pl &lt;asin&gt;
  use strict;
  use warnings;
  use LWP::Simple;
  
  # Take the asin from the command-line
  my $asin = shift @ARGV or die "Usage: perl get_reviews.pl &lt;asin&gt;\n";
  
  # Assemble the URL from the passed asin.
  my $url = "http://amazon.com/o/tg/detail/-/$asin/?vi=customer-reviews";
  
  # Set up unescape-HTML rules. Quicker than URI::Escape.
  my %unescape = ('&amp;quot;'=&gt;'"', '&amp;amp;'=&gt;'&amp;', '&amp;nbsp;'=&gt;' ');
  my $unescape_re = join '|' =&gt; keys %unescape;
  
  # Request the URL.
  my $content = get($url);
  die "Could not retrieve $url" unless $content;
  
  #Remove everything before the reviews
  $content =~ s!.*?Number of Reviews:!!ms;
  
  # Loop through the HTML looking for matches
  while ($content =~ m!&lt;img.*?stars-(\d)-0.gif.*?&gt;.*?&lt;b&gt;(.*?)&lt;/b&gt;, (.*?)[RETURN]
  \n.*?Reviewer:\n&lt;b&gt;\n(.*?)&lt;/b&gt;.*?&lt;/table&gt;\n(.*?)&lt;br&gt;\n&lt;br&gt;!mgis) {
  
  my($rating,$title,$date,$reviewer,$review) = [RETURN] 
  ($1||'',$2||'',$3||'',$4||'',$5||'');
  $reviewer =~ s!&lt;.+?&gt;!!g;   # drop all HTML tags
  $reviewer =~ s!\(.+?\)!!g;   # remove anything in parenthesis
  $reviewer =~ s!\n!!g;      # remove newlines
  $review =~ s!&lt;.+?&gt;!!g;     # drop all HTML tags
  $review =~ s/($unescape_re)/$unescape{$1}/migs; # unescape.
  
  # Print the results
  print "$title\n" . "$date\n" . "by $reviewer\n" .
        "$rating stars.\n\n" . "$review\n\n";
  </code></pre>
  
  <p>}</p>