Simple subroutine for checking browser using HTML::Embperl. The version below detects if a modern browser is being used and assigns the $browser variable a value of "DOM" or "CRAP".
[# browser detection for search modules #]
[$ sub browserDetection $]
[-
$browser = $ENV{HTTP_USER_AGENT};
if ($browser =~ /MSIE/) { $browser_vers = 'IE' };
if ($browser =~ /Gecko/) { $browser_vers = 'GECKO' };
if (($browser_vers eq 'IE') ||
($browser_vers eq 'GECKO')) {
$browser = 'DOM';
} else {
$browser = 'CRAP';
}
-]
[$ endsub $]