#!/usr/bin/perl -w

use CGI qw(:standard);
use LWP::UserAgent;

       $ua = new LWP::UserAgent;
       $ua->agent("AgentName/0.1 " . $ua->agent);

       # Create a request
       my $req = new HTTP::Request GET => param('file');
       $req->content_type('application/x-www-form-urlencoded');
       $req->content('match=www&errors=0');

       # Pass request to the user agent and get a response back
       my $res = $ua->request($req);

       # Check the outcome of the response

	print "Content-type: text/html\n\n";
       if ($res->is_success) {

	print '<?xml version="1.0" encoding="ISO-8859-1"?>';
	print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">';
	print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">';
	print '<head>';
	print '<link rel="StyleSheet" href="http://www.mit.jyu.fi/opetus/appro/appro.css" type="text/css" media="screen" />';
	print '<title>' . param('file') . '</title>';
	print '</head>';
	print '<body>';
        print "<h1>" . param('file') . "</h1>";
	print '<pre><code>';

	$foo = $res->content;
	$foo =~ s\&\&amp;\g;
	$foo =~ s\<\&lt;\g;
	$foo =~ s\>\&gt;\g;

        print $foo;
	print '</code></pre>';
	print '</body></html>';
       } else {
           print "Sorry, file not found\n";
       }

