home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 August / Chip_2000-08_cd1.bin / sharewar / dzperl / Setup.exe / {app} / Samples / envvars.pl next >
Encoding:
Perl Script  |  2000-06-15  |  4.1 KB  |  81 lines

  1. #!/usr/bin/perl
  2.  
  3. # This example demonstrates how to use environment variables in Perl CGI scripts
  4. #             Copyright (c) 2000 Alexander Dzyubenko, DzSoft Ltd.
  5. #                           All rights reserved.
  6. # May be distributed only as a part of DzSoft Perl Editor, http://www.dzsoft.com
  7.  
  8. # Send the MIME HTTP header
  9. print "Content-type: text/html\n\n";   # \n means the line break, send two
  10.                                        # line breaks after the HTTP header
  11.  
  12. print "<html>\n";
  13.  
  14. print "<head>\n";
  15. print "<title>Environment Variables Demo</title>\n";
  16. print "</head>\n";
  17.  
  18. print "<style>\n";                                 # Stylesheet. Not required,
  19. print " {font-family : arial}\n";                  # but helps to control the
  20. print " a {text-decoration: none}\n";              # page style. To find out
  21. print " a:hover {text-decoration: underline}\n";   # more about CSS, search the
  22. print "</style>\n";                                # web for "CSS Tutorial"
  23.  
  24. print "<body bgcolor=\"#495578\" \n";   # Full body tag with DzSoft colors.
  25. print "      text=\"#FFFFCC\"    \n";   # Note that if you need to print
  26. print "      link=\"#FFFF00\"    \n";   # " character, write \" instead in
  27. print "      vlink=\"#FFFFCC\"   \n";   # the scriot source. Quick Insert ->
  28. print "      alink=\"#FFFFFF\">  \n";   # Print Function in DzSoft Perl Editor
  29.                                         # does this automatically.
  30.  
  31. print "<p align=\"center\"><big>Environment Variables</big></p>\n";
  32. print "<pre>\n";
  33.  
  34. print "Request method: <b>$ENV{'REQUEST_METHOD'}</b>\n"; # Request method.
  35.                                                          # When you run the
  36.                                                          # script from DzSoft
  37.                                                          # Perl Editor it will
  38.                                                          # be always GET.
  39.  
  40. print "Script name: <b>$ENV{'SCRIPT_NAME'}</b>\n"; # Server path to the script
  41.  
  42. print "Server software: <b>$ENV{'SERVER_SOFTWARE'}</b>\n"; # Server software
  43.                                                            # (name/version)
  44.  
  45. print "Gateway interface: <b>$ENV{'GATEWAY_INTERFACE'}</b>\n"; # Gateway
  46.                                                                # interface.
  47.                                                                # DzSoft Perl
  48.                                                                # Editor emulates
  49.                                                                # CGI gateway
  50.                                                                # interface.
  51.  
  52. print "Query string: <b>$ENV{'QUERY_STRING'}</b>\n"; # Query string. Part of URL
  53.                                                      # (everything after "?").
  54.                                                      # In DzSoft Perl Editor you
  55.                                                      # can edit query string
  56.                                                      # in Environment Variables
  57.                                                      # dialog box.
  58.  
  59. # NOTE: The following variables present in DzSoft Perl Editor only if they are
  60. #       set in "Environment Variables Editor" dialog box. To ensure that they
  61. #       are, click <reset to defaults> in Environment Variables Editor.
  62.  
  63. print "HTTP user agent: <b>$ENV{'HTTP_USER_AGENT'}</b>\n"; # HTTP user agent.
  64.                                                            # Shows web browser
  65.                                                            # used by visitor.
  66.  
  67. print "HTTP referer: <b>$ENV{'HTTP_REFERER'}</b>\n"; # HTTP referer. URL of the
  68.                                                      # web page from which the
  69.                                                      # visitor came.
  70.  
  71. print "Remote host: <b>$ENV{'REMOTE_HOST'}</b>\n";   # Visitor's host name.
  72.  
  73. print "Remote IP: <b>$ENV{'REMOTE_ADDR'}</b>\n";     # Visitor's IP address.
  74.  
  75. print "Server name: <b>$ENV{'SERVER_NAME'}</b>\n";   # Server name, for example
  76.                                                      # www.dzsoft.com
  77.  
  78. print "</pre>\n";
  79. print "</body>\n";
  80. print "</html>\n";
  81.