Determining the User Agent and Printing the Appropriate Result
#!/usr/bin/perl -T
use strict;
use CGI qw/:standard/;
my $useragent = $ENV{'HTTP_USER_AGENT'};
print header,
start_html('User Agent Example');
if ($useragent =~ /Firefox/) {
print p("You are visiting with a Firefox browser");
} elsif ($useragent =~ /MSIE/) {
print p("You are visiting with an Internet Explorer browser");
} else {
print p("Could not determine browser: $useragent");
}
print end_html;
exit;
Related examples in the same category