SYbeginner has asked for the wisdom of the Perl Monks concerning the following question:

Is there an environment variabe that displays the URL of the current webpage?

Replies are listed 'Best First'.
Re: The Environment variable for URL...
by lhoward (Vicar) on May 22, 2000 at 06:53 UTC
    This question would probably be more apropriate to a discussion forum related to your webserver. However, in the spirit of Perlmonks I offer you a short perl/CGI script that will show you all the environmental variables that are available so you can see if you can find one that suits your needs.
    #!/usr/bin/perl -w use strict; use CGI qw(:standard); print header, start_html(-title => 'ENV vars', -bgcolor => 'white'); foreach (sort keys %ENV){ print "<b>$_</b> -> \"$ENV{$_}\"\n<br>\n"; } print end_html;
      Or the non-CGI.pm version of the above...
      #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<html><body><pre>\n"; foreach (sort keys %ENV) { print "\$ENV{$_}\t$ENV{$_}\n"; } print "</pre></body></html>\n\n";
Re: The Environment variable for URL...
by httptech (Chaplain) on May 22, 2000 at 15:29 UTC
    Or the non-HTML version of the above...
    #!/usr/bin/perl print "Content-type: text/plain\n\n"; print map { "$_ : $ENV{$_}\n" } sort keys %ENV;
      #!/bin/sh echo content-type: text/plain echo printenv
Re: The Environment variable for URL...
by Maqs (Deacon) on May 22, 2000 at 18:26 UTC
    Or the exact names of some of the variables:
    HTTP_HOST i.e. "some.where.com"
    REQUEST_URI i.e. "/page/file.cgi"

    /Maqs.