http://www.perlmonks.org?node_id=599423

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

Hello,

I'm on Windows running IIS using Active State Perl

Since I'm not on apache, does this mean I can't use certain environmental variables?

I'm trying to receive the url the end user is currently requestion, so a little snippet of my code that prints nothing:
my $url = $ENV{REQUEST_URI}; print "$url"; #prints nada!

Ty

Replies are listed 'Best First'.
Re: Request URI
by Joost (Canon) on Feb 11, 2007 at 04:30 UTC
      I have seen a few tutorials on Environment Variables in Perl that show REQUEST_URI as a perl Environment Variable.
      They dont say anything about apache providing it and IIS not.

      I'm not saying Joost is wrong, but there may be some tutorials out there that are.

Re: Request URI
by Khen1950fx (Canon) on Feb 11, 2007 at 14:48 UTC
    Try this:

    my $url = $ENV{'REQUEST_URI'}; print "$url";

    Update: Oops.. I'm sorry, I was thinking in terms of Linux. Maybe Win32::Env could help.

Re: Request URI
by EvanK (Chaplain) on Feb 12, 2007 at 16:23 UTC
    As Joost suggested, you may have to build it from other environment vars. To get a list of all the environment vars your install of IIS provides to perl, you could dump the %ENV hash to a file like so:
    #!c:/perl/bin/perl -w use strict; use Data::Dumper; open my $ENV_DUMP, '>', 'c:/iis_env.txt' or die $!; print {$ENV_DUMP} Dumper(\%ENV); close $ENV_DUMP; print "Content-Type: text/plain\n\nSuccess!";
    Of course, you want to run this through IIS, not the Windows command line.

    __________
    Systems development is like banging your head against a wall...
    It's usually very painful, but if you're persistent, you'll get through it.