I am somewhat proffecient in LWP but am having difficulty getting the following proxy method to work.

I have based this solution off of Toma's LWP Quick reference guide. If anyone knows a better way to do the proxy please let me know in easy to follow code.

use LWP::Simple; use LWP::Simple qw( $ua get ); use LWP::UserAgent; use HTTP::Request::Common qw(POST); my $ua = new LWP::UserAgent; $proxy = "72.43.50.184:80"; $contentget = "http://search.cpan.org/~gaas/libwww-perl-5.837/lib/LWP/ +UserAgent.pm"; $ua->timeout(3); $ua->proxy(['http'], '$proxy'); my $req = new HTTP::Request GET => '$contentget'; my $res = $ua->request($req); if ($res->is_success) { $content= $res->content; } else { die "Could not get content"; }

Result is:

Could not get content at C:\CC\BUY\ptest.pl line 22.

There is also the

$ua->proxy( 'http', $subproxy );my $content = get( $contentget )

But that doesnt work either. Any help would be appreciated.

POST UPDATE 1

------------------------------------------------------------------

Thank you for responding afoken

but when i tried adding the modifcations i get the following error. I tried escaping the / problem but still cant get it to work.

use LWP::Simple; use LWP::Simple qw( $ua get ); use LWP::UserAgent; use HTTP::Request::Common qw(POST); use HTTP::Request my $ua = new LWP::UserAgent; $proxy='http://72.43.50.184:80/'; $contentget = "http://search.cpan.org/~gaas/libwww-perl-5.837/lib/LWP/ +UserAgent.pm"; $ua->timeout(3); $ua->proxy(['http'], $proxy); my $req = new HTTP::Request GET => '$contentget'; my $res = $ua->request($req); if ($res->is_success) { $content= $res->content; } else { die "Could not get content"; } # ptest.pl
C:\CC\BUY>ptest.pl Backslash found where operator expected at C:\CC\BUY\ptest.pl line 30, + near "CC\" Backslash found where operator expected at C:\CC\BUY\ptest.pl line 30, + near "BUY\" syntax error at C:\CC\BUY\ptest.pl line 30, near "Could not " Execution of C:\CC\BUY\ptest.pl aborted due to compilation errors.

In reply to LWP proxy setup difficulty by Monkomatic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.