views:

74

answers:

2

I need to parse the user-agents in HTTP-headers from a text file so as to determine the browser, the version, the OS and possibly the device. so few examples of those lines are:

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Update a; AOL 6.0; Windows 98)

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Crazy Browser 2.0.0 Beta 1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-de) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01  [en]

Due to the sheer variety of these strings I figured it would be a better idea to utilize a proven and dependable parser that someone has made available. I did find a few in PHP or java but don't seem to find one for Perl.

Can someone tell me about any such module?

+11  A: 

You might be looking for the HTTP::BrowserDetect module.

rafl
Ha ha lmctfy.org.
mobrule
+1  A: 

Whenever you need something in Perl, try CPAN Search. Searching for user agent shows in just the first page of results several modules that you might use.

brian d foy