while(1) { my $url="https://cucxnpub/vmrest/users?rowsPerPage=2000\&pageNumber=$page"; $ua = LWP::UserAgent->new(ssl_opts => { SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, verify_hostname => 0, }); #<<<< $url is OUT of scope $header = HTTP::Headers->new; $req = HTTP::Request->new(GET => $url); #IF you had "use strict", this would show an error.