title: Why does Perl's URI complain "Can't locate object method "host" via package "URI::_generic"'?
body: <p>HI, im trying to get the host from a url.</p>
  
  <pre><code>sub scrape {
  my @m_error_array;
  my @m_href_array;
  my @href_array;
  my ( $self, $DBhost, $DBuser, $DBpass, $DBname ) = @_;
  my ($dbh, $query, $result, $array);
  my $DNS = "dbi:mysql:$DBname:$DBhost:3306";
  $dbh = DBI-&gt;connect($DNS, $DBuser, $DBpass ) or die $DBI::errstr;
  if( defined( $self-&gt;{_process_image} ) &amp;&amp; ( -e 'href_w_' . $self-&gt;{_process_image} . ".txt" ) ) {
      open  ERROR_W, "error_w_" . $self-&gt;{_process_image} . ".txt";
      open  M_HREF_W, "m_href_w_" . $self-&gt;{_process_image} . ".txt";
      open  HREF_W, "href_w_" . $self-&gt;{_process_image} . ".txt";
      @m_error_array = ( split( '|||', &lt;ERROR_W&gt; ) );
      @m_href_array = ( split( '|||', &lt;M_HREF_W&gt; ) );
      @href_array = ( split( '|||', &lt;HREF_W&gt; ) );
      close ( ERROR_W );
      close ( M_HREF_W );
      close ( HREF_W );
  }else{
      @href_array = ( $self-&gt;{_url} );
  }
  my $z = 0;
  while( @href_array ){
      if( defined( $self-&gt;{_x_more} ) &amp;&amp; $z == $self-&gt;{_x_more} ) {
          last;
      }
      if( defined( $self-&gt;{_process_image} ) ) {
          $self-&gt;write( 'm_href_w', @m_href_array );
          $self-&gt;write( 'href_w', @href_array );
          $self-&gt;write( 'error_w', @m_error_array );
      }
      $self-&gt;{_link_count} = scalar @m_href_array;
      my $href = shift( @href_array );
      my $info = URI-&gt;new($href);
      my $host = $info-&gt;host;
      $host =~ s/^www\.//;
      $result = $dbh-&gt;prepare("INSERT INTO `". $host ."` (URL) VALUES ('$href')");
      if( ! $result-&gt;execute() ){
          $result = $dbh-&gt;prepare("CREATE TABLE `" . $host . "` ( `ID` INT( 255 ) NOT NULL AUTO_INCREMENT , `URL` VARCHAR( 255 ) NOT NULL , PRIMARY KEY ( `ID` )) ENGINE = MYISAM ;");
          $result-&gt;execute()
      }
      $self-&gt;{_current_page} = $href;
      my $response = $ua-&gt;get($href);
      my $responseCode = $response-&gt;code;
      print $responseCode;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Towards te end the line <code>my $host = $info-&gt;host;</code> is throwing <code>Can't locate object method "host" via package "URI::_generic"</code></p>
  
  <p>Can anyone explain this?</p>
  
  <p>Regards,</p>
  
  <p>Phil</p>