my $x; ... $x = ...; #### ... my $x = ...; #### 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); #### my $res = $ua->get('http://SOMEURLHERE');