Extra tidbits:
If something isn't working as expected, one should start by checking what error occured! open, print and close all indicate if they were successful, and if not, why they weren't.
Declaring variables before they are used just introduces the possibility of errors. Instead of
domy $x; ... $x = ...;
... my $x = ...;
Speaking of declaring variables, don't use global variables for file handles. That hasn't been necessary for 10 years.
open(my $fh, '>', '/tmp/data.txt') or die("Can't create file /tmp/data.txt: $!\n"); print $fh $res->content; close($fh);
my $req = HTTP::Request->new(GET =>'http://SOMEURLHERE'); my $res = $ua->request($req);
can be written as
my $res = $ua->get('http://SOMEURLHERE');
In reply to Re^3: Cannot access HTTP::Response content properly
by ikegami
in thread Cannot access HTTP::Response content properly
by URAvgDeveloper101
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |