in reply to Re^3: 400 error
in thread 400 error
my $response = HTTP::Tiny->new->get($url); my $response = $ua->request($request);
Unfortunately, the code isn't perfect. You've declared and assigned to $response twice on subsequent lines and therefore the effect of the former line is nil. If you had used warnings this would have been clear.
This isn't an SSCCE because you are referring to $ARGV[0] without indication of what it might be and you have not used either of the modules. Here is an SSCCE for contrast.
#!/usr/bin/env perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new (agent => 'myagent'); my $url = 'https://www.perlmonks.org/'; my $request = HTTP::Request->new ('GET', $url); my $response = $ua->request ($request); print $response->status_line . "\n";
|
|---|