jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to know if a user has the above toolbar when accessing a particular perl script. I assume that it leaves some kind of footprint as it displays in the browser window. can anyone tell me how I can do this?

Replies are listed 'Best First'.
Re: detecting Alexa toolbar
by lithron (Chaplain) on Oct 04, 2004 at 23:19 UTC
    Check the environment variables set by your web server. The Alexa toolbar changes the browser version string. An example : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)"

    if ($ENV{HTTP_USER_AGENT} =~ /Alexa/) { print "$ENV{HTTP_USER_AGENT}"; }

    The %ENV hash holds all the environment variables. The Apache web server (and I assume others) set the HTTP_USER_AGENT string equal to what the web browser sends, so that you can detect what version of Internet Explorer, Netscape Navigator, or Mozilla Firefox someone is running. In this case, Alexa also changes this string to include itself.
      That worked perfectly, Thank you.