#!/bin/perl -w -T

# All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#


use CGI qw( :standard);
use URI::Escape;
use Text::Wrap;

$Text::Wrap::columns= 40;

my $version= param( 'version'); # not used right now
my $var_file= "./pgc_vars";

my $code='';

open( VAR_LIST, "<$var_file") or die "cannot open $var_file: $!";
while(<VAR_LIST>)
  { chomp;
    my $val= param($_) || '';
    $code .= $val; 
  }

my $html_code= uri_escape( $code);
$html_code=~ s/\+/%2B/g;
my $url= "http://www.xmltwig.com/cgi-bin/pgc/pgc_decode?code=$html_code&version=$version";

print header,
      start_html('You own Personal Perl Geek Code'),
      h1( 'You own Personal Perl Geek Code'),
      h3( "Text Version"),
      p( pre("-----BEGIN PERL GEEK CODE BLOCK-----\n".
             "Version: $version\n".
             wrap( '', '', $code).
             "\n------END PERL GEEK CODE BLOCK------\n")),
      hr(),
      h3( "HTML version"),
      p( a( {href => $url}, "decode it")),
      hr(),
      p( {align => "center"},
         a( {href=>"http://www.xmltwig.com/pgc/"},"The Perl Geek Code Home")
       ),
      end_html;


