in reply to Getting contents of URL

use LWP::UserAgent; sub get_url( $ ) { my ( $url ) = @_; my $ua = LWP::UserAgent->new(); # $ua->proxy('http','http://proxy.company.com:8080/'); $ua->timeout( 10 ); my $resp = $ua->get($url); if ( $resp->is_success ) { return( $resp->content ); } else { die( "LWP error: " . $resp->status_line . "\n" ); } } print( get_url( 'http://www.perl.com/' ) );

Replies are listed 'Best First'.
Re^2: Getting contents of URL
by perl_devel (Friar) on Jul 28, 2005 at 04:56 UTC
    I AM GETTING AN ERROR LIKE Can't locate object method "get" via package "LWP::UserAgent" at - line 11
      monarch's script works fine for me (it's basically the same as the example at LWP::UserAgent

      perhaps you forgot to make the new ua object?
      my $ua = LWP::UserAgent->new();

      "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.