What's the Perl equivalent for the following PHP calls?
$_SERVER["HTTP_HOST"]
$_SERVER["REQUEST_URI"]
Any help would be much appreciated.
What's the Perl equivalent for the following PHP calls?
$_SERVER["HTTP_HOST"]
$_SERVER["REQUEST_URI"]
Any help would be much appreciated.
What's the environment you're working in? If it's CGI script try:
use Data::Dumper;
print Dumper \%ENV;
Environment variables are a series of hidden values that the web server sends to every CGI you run. Your CGI can parse them, and use the data they send. Environment variables are stored in a hash called %ENV.
like $ENV{'HTTP_HOST'}
will give the The hostname of your server.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
EndOfHTML
foreach $key (sort(keys %ENV)) {
print "$key = $ENV{$key}<br>\n";
}
print "</body></html>";
For more details see CGI Environmental variables
Another way, than variable environement, is to use CGI :
use strict;
use warnings;
use CGI ;
print CGI->new->url();
Moreover, it also offers a lot of CGI manipulation such as accessing params send to your cgi, cookies etc...