in reply to get page URL

Use CGI to do it:
my $q = CGI->new(); my $url = $q->url(-absolute => 1);

That should be as portable as CGI.pm, which is about as portable as you can get.