in reply to Re: ENV variable
in thread ENV variable

My program follows, sub is_firefox { my $agent = ''; $agent = $ENV{"HTTP_USER_AGENT"} || ''; if (length($agent) && $agent =~ m/firefox/si) { return 1; } return 0; } I have printed all the keys and values of %ENV using while and each. I have checked this in Debian Linux, and Apache server.

Replies are listed 'Best First'.
Re^3: ENV variable
by Corion (Patriarch) on Feb 02, 2009 at 08:04 UTC

    It's quite possible that your browser does not send its user agent.

    Also, what code you've shown is not a complete program, hence I cannot tell whether there is some other error. You should consider starting using CGI or CGI::Mini, which have the ->user_agent() method, which caters for other ways of passing the user agent around. For example, mod_perl likely doesn't set $ENV{HTTP_USER_AGENT}, because %ENV is process global and mod_perl can run in system threads.