#!/usr/bin/perl
print "Content-type: text/html", "\n\n";
#first i identify the no graphical browsers
$nongraphic_browsers = 'Lynx|CERN-LineMode';
#then i identify the browser being used pulling from HTTP_USER_AGENT environment variable
$client_browser = $ENV{'HTTP_USER_AGENT'};
#identify the redirection depending on the browser being used
#use the below for graphic browsers
$graphic_document = "graphic_browsers.html";
#use the below for text based browsers
$text_document = "text_browsers.html";
#next i test for the condition that the browser is a non-graphical version and if not
#i shuttle the viewer to the graphical site instead
if ($client_browser =~ /$nongraphic_browsers/){
#don't forget your scalars on the left side of = sign
$html_document = $text_document;
} else {
#don't forget the scalars on the left side of = sign
$html_document = $graphic_document;
}
#first i determine the DOCUMENT_ROOT parsed from my Server
$document_root = $ENV{'DOCUMENT_ROOT'};
#this i join with a / to obtain where i will send the viewer
$html_document = join ("/", "$document_root", "$html_document");
#if my $html_document is openable my "<" reads the $html_document with the while scanning
#thru the document and displaying it for all to see. As the while reads thru the HTML handle
#it places each line that it reads in the default variable $_ which is then printed to STDOUT
if (open (HTML, "<" . $html_document)) {
while () {
print;
}
#after no more to be read from $_ the file closes
close (HTML);
#error in opening the webpage is caught here with a stock comment to apologize
}else {
print "Sorry But There Must Be a Problem with the Internal Configuration of my System.","\n";
print "Please email dreamwvr\@dreamwvr.com","\n";
}
exit(0);