Hi, as hippo pointed out, this is not an SSCCE, and you are declaring $response twice. Additionally:

You need to stop throwing in snippets from various sources and settle on one tool, and take the time to learn it. That involves spending time with the documentation. The example I originally showed was copied almost verbatim from the HTTP::Tiny documentation. I suggest that you start with the SYNOPSIS of the module that you choose, and once you have that running in your environment, you can make changes to it, one line at a time, so you can see immediately if you made a mistake.

This is an SSCCE that should be copied into a file (eg 'foo.pl') and run with $ perl foo.pl http://example.com

use strict; use warnings; use HTTP::Tiny; my $url = shift; my $response = HTTP::Tiny->new->get($url); if ( $response->{success} ) { print "OK: $response->{content}\n"; } else { print "Failed: $response->{status} $response->{reason}\n"; } __END__
... or this ...
use strict; use warnings; use LWP::UserAgent; my $ua = new LWP::UserAgent; # possibly add advanced user agent options here my $url = shift; # possibly construct a request object here my $response = $ua->get($url); # if not using a request object if ($response->is_success) { print $response->decoded_content, "\n"; } else { die $response->status_line; } __END__

Hope this helps! There are no shortcuts to learning, not if you want to understand.


The way forward always starts with a minimal test.

In reply to Re^4: 400 error by 1nickt
in thread 400 error by futureman

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.