Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Request URI

by Anonymous Monk
on Feb 11, 2007 at 04:24 UTC ( #599423=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


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!


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://599423]
Approved by Joost
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2018-06-21 11:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.