2008-11-17

Examples of Perl : envdump.pl

Examples of Perl Program: envdump.pl



This is simple code to get environment settings.

#!/usr/bin/perl
# envdump.pl
#####################################################
# Get environment settings
foreach $key (keys %ENV) {
print "$key --> $ENV{$key} \n" ;
}

This is CGI, show a html page of all environment settings.

#!/usr/bin/perl
# envdump.pl
# Show a html page of all environment settings
#####################################################
use strict;
use warnings;

print "Content-type: text/html\n\n";

print "<html><head><title>Environment Dumper</title></head><body>";
print "<center><table border=1>";

print "<tr><td>"."Your Operating System is:"."</td><td>";
foreach ($^O) {
print "$_";
}
print "</td></tr>";

foreach (sort keys %ENV) {
print "<tr><td>$_</td><td>$ENV{$_}</td></tr>"
}
print "</table></center>";


print "</body></html>";

No comments:

Post a Comment