#!/perl

print "Hello, World...\n";
##push(@INC, "/cgi-bin");
##require("cgi-lib.pl");
##print &PrintHeader;
my $outfil = 'tempenv.htm';
my ($OF);
my $var;
my $sepitems = 1;

open $OF, ">$outfil" or die "Can not create $outfil!\n";

prt( "<html>\n" );
prt( "<head><title>Local Environment Variables</title></head>\n" );
prt( "<body>\n" );

print $OF <<"EOF";
<center>
<table border=0 cellpadding=0 cellspacing=0>
<th align=left><h3>Environment Variable</h3></th>
<th align=left><h3>Contents </h3></th><tr>
EOF

foreach $var (sort keys(%ENV))
{
	my $val = $ENV{$var};
	if ($sepitems) {
		$val =~ s/;/;\<br\>/g;
	}
	###prt( "<tr>\n <td>$var</td>\n <td>$ENV{$var}</td>\n</tr>\n" );
	prt( "<tr>\n <td valign='top'>$var</td>\n <td>$val</td>\n</tr>\n" );
}

prt_tail();

close($OF);
system($outfil);

sub prt_tail {
print $OF <<"EOF"
</table>
</center>
</body>
</html>
EOF
}

sub prt {
	my ($txt) = @_;
	print $txt;
	print $OF $txt;
}

#eof

