Browser Detection by PERL

June 14, 2007 § 4 Comments

I am enjoying PERL a lot. I am seeing everything new in PERL. I want to share interesting and important PERL stuffs through my blog.

Here is a PERL subroutine that detects whether the browser is Firefox or NOT.

sub is_firefox {
my $agent = ‘’;
$agent = $ENV{”HTTP_USER_AGENT”} || ‘’;
if (length($agent) && $agent =~ m/firefox/si) {
return 1;
return 0;

Enjoy PERL, the scripting pioneer.



§ 4 Responses to Browser Detection by PERL

  • Anirban says:

    The language is Perl not PERL!

  • Rupom says:

    PERL is short for ” Practical Extraction and Report Language”.
    If I write “Perl”, it does not highlight that it’s abbreviated from something. Well, it’s my way. Many ones write “perl” or “Perl” or “PERL”.


  • M.S. Babaei says:

    thanks for your code…

    but I have a little problem

    if you browse my website using firefox and then use another browser on same computer to visit my website then perl script detect the browser as firefox until you vist the page once and then press F5

    this works on localhost but on remote computer not works…

    any help appreciated

  • Gaurav says:

    How we can open firefox browser by perl and then browse certain URL in mutiple tabs of that browser.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

What’s this?

You are currently reading Browser Detection by PERL at Rupom Here.


%d bloggers like this: