programming-examples/perl/CGI/Determining the User Agent and Printing the Appropriate Result.pl

19 lines
440 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/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;