Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I parse user-agent strings in Perl?

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?

like image 889
sfactor Avatar asked Oct 01 '10 12:10

sfactor


1 Answers

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

like image 101
rafl Avatar answered Oct 04 '22 20:10

rafl