fork download
  1. #!/usr/bin/perl
  2.  
  3.  
  4. &print_HTTP_header;
  5. &print_head;
  6. &print_body;
  7. &print_tail;
  8.  
  9.  
  10. # print the HTTP Content-type header
  11. sub print_HTTP_header {
  12. print "Content-type: text/html\n\n";
  13. }
  14.  
  15.  
  16. # Print the HTML preamble
  17. sub print_head {
  18. print <<END;
  19. <HTML><HEAD>
  20. <TITLE>Environment Variables</TITLE>
  21. </HEAD>
  22. <BODY>
  23. <H1>Environment Variables:</H1>
  24. END
  25. }
  26.  
  27.  
  28. #Loop through the environment variable
  29. #associative array and print out its values.
  30. sub print_body {
  31. foreach $variable (sort keys %ENV) {
  32. print "<B>$variable:</B> $ENV{$variable}<BR>\n";
  33. }
  34. }
  35.  
  36.  
  37. #Print the end of the document
  38. sub print_tail {
  39. print <<END;
  40. </BODY>
  41. </HTML>
  42. END
  43. }
  44.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Content-type: text/html

<HTML><HEAD>
<TITLE>Environment Variables</TITLE>
</HEAD>
<BODY>
<H1>Environment Variables:</H1>
<B>HOME:</B> /home/xT8IEU<BR>
<B>LANG:</B> en_US.UTF-8<BR>
<B>PATH:</B> /usr/local/bin:/usr/bin:/bin<BR>
<B>PWD:</B> /home/xT8IEU<BR>
<B>SHLVL:</B> 0<BR>
<B>TMPDIR:</B> /tmp/a9mlYr<BR>
<B>TMPDIR_GLOBAL:</B> /tmp/<BR>
<B>WORKSPACE:</B> /tmp/<BR>
</BODY>
</HTML>