in reply to Re^2: Cannot access HTTP::Response content properly
in thread Cannot access HTTP::Response content properly
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');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Cannot access HTTP::Response content properly
by Anonymous Monk on Nov 03, 2009 at 13:42 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 15:14 UTC | |
|
Re^4: Cannot access HTTP::Response content properly
by Anonymous Monk on Nov 03, 2009 at 15:17 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 15:34 UTC | |
by Anonymous Monk on Nov 03, 2009 at 16:21 UTC | |
by ikegami (Patriarch) on Nov 03, 2009 at 17:57 UTC | |
by URAvgDeveloper101 (Novice) on Nov 03, 2009 at 19:48 UTC | |
|