SHP/CGI/Perl Example

Look at the address bar. You submitted 2 HTTP parameter(s).

Name Value
a 1
b 3

Source for this SHP file:

#!/home/jdenny/public_html/share/shp/0.14/bin/shp
Content-type: text/html

<?xml version="1.0" encoding="iso-8859-1"?>

<$open_server>perl_server<$/open_server>

<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <title>
    SHP/CGI/Perl Example
  </title>
  <style type="text/css" media="screen">
    table {
      border: ridge gray;
      border-width: 3px 0px 0px 3px;
    }
    table td {
      border: ridge gray;
      border-width: 0px 3px 3px 0px;
      padding: 7px;
    }
    table thead td {
      font-weight: bold;
    }
  </style>
  <$talk>perl_server<$:>
    use CGI;
    $main::r_cgi = new CGI;
    %main::h_params = $main::r_cgi->Vars;
    $main::i_param_count = scalar keys %main::h_params;
  <$/talk>
</head>

<body>

<h1>SHP/CGI/Perl Example</h1>

<p>
  Look at the address bar.
  You submitted
  <$talk>perl_server<$:> 
    print $main::i_param_count;
  <$/talk>
  HTTP parameter(s).
</p>

<table cellspacing="0">
  <thead>
    <tr>
      <td>Name</td>
      <td>Value</td>
    </tr>
  </thead>
  <tbody>
    <$talk>perl_server<$:>
      while ( ( my $s_name, my $s_value ) = each( %main::h_params ) ) {
        $s_name =~ s/&/&amp;/g;
        $s_name =~ s/</&lt;/g;
        $s_name =~ s/>/&gt;/g;
        $s_value =~ s/&/&amp;/g;
        $s_value =~ s/</&lt;/g;
        $s_value =~ s/>/&gt;/g;
        print "    <tr>\n";
        print "      <td>$s_name</td>\n";
        print "      <td>$s_value</td>\n";
        print "    </tr>\n";
      }
    <$/talk>
  </tbody>
</table>

<p>
  Source for this SHP file:
</p>

<pre style="border: ridge grey 3px;"><$"->
  <$talk>perl_server<$:>
    open my $r_file, "example_perl.shp.cgi";
    while( my $s_line = readline $r_file ) {
      $s_line =~ s/&/&amp;/g;
      $s_line =~ s/</&lt;/g;
      $s_line =~ s/>/&gt;/g;
      print $s_line;
    }
  <$/talk><$"->
</pre>

</body>

</html>

<$close_server>perl_server<$/close_server>