<html><body>
<p><font size="2" face="sans-serif">My Perl book (Tom Christiansen, brian d foy & Larry Wall, Programming Perl, 4th ed., O'Reilly, 2012) says on p. 887 that keys returned by the keys function are sorted by the values.</font><br>
<br>
<font size="2" face="sans-serif">There are two options:</font><br>
<br>
<font size="2" face="sans-serif">- On line 20 of Browsers.pm, you change the value from "Apple Safari" to "Safari", so Google Chrome matches first.</font><br>
<font size="2" face="sans-serif">- or on line 54, you change the loop to </font><br>
<br>
<font size="2" face="Menlo-Regular"># foreach( keys %$BROWSERS_SIGNATURES )</font><br>
<font size="2" face="Menlo-Regular"> foreach( sort keys %$BROWSERS_SIGNATURES )</font><br>
<br>
<font size="2" face="sans-serif">which sorts on the keys, so Chrome matches before Safari.</font><br>
<br>
<font size="2" face="sans-serif">The second option is a little less performant, since it involves a sort operation on each processed record. However, I prefer it.</font><br>
<br>
<font size="2" face="sans-serif">Have a nice day,</font><br>
<br>
<font size="2" face="sans-serif">Martin</font><br>
<br>
<font size="2" face="sans-serif">--</font><br>
<font size="2" face="sans-serif">Dr. Martin Brändle</font><br>
<font size="2" face="sans-serif">Zentrale Informatik</font><br>
<font size="2" face="sans-serif">Universität Zürich</font><br>
<font size="2" face="sans-serif">Stampfenbachstr. 73</font><br>
<font size="2" face="sans-serif">CH-8006 Zürich</font><br>
<br>
<br>
<img width="16" height="16" src="cid:1__=4EBBF443DFB3E0518f9e8a93df9@lotus.uzh.ch" border="0" alt="Inactive hide details for "Field A.N." ---24/09/2015 16:02:28---The code you want is here: https://github.com/eprints/irstats2/"><font size="2" color="#424282" face="sans-serif">"Field A.N." ---24/09/2015 16:02:28---The code you want is here: <a href="https://github.com/eprints/irstats2/blob/master/cfg/plugins/EPrints/Plugi">https://github.com/eprints/irstats2/blob/master/cfg/plugins/EPrints/Plugi</a></font><br>
<br>
<font size="1" color="#5F5F5F" face="sans-serif">Von:        </font><font size="1" face="sans-serif">"Field A.N." <af05v@ecs.soton.ac.uk></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">An:        </font><font size="1" face="sans-serif">eprints-tech@ecs.soton.ac.uk</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Datum:        </font><font size="1" face="sans-serif">24/09/2015 16:02</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Betreff:        </font><font size="1" face="sans-serif">[EP-tech] Re: IRStats2. Browsers and Countries</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Gesendet von:        </font><font size="1" face="sans-serif">eprints-tech-bounces@ecs.soton.ac.uk</font><br>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<tt><font size="2">The code you want is here:<br>
<br>
</font></tt><tt><font size="2"><a href="https://github.com/eprints/irstats2/blob/master/cfg/plugins/EPrints/Plugin/Stats/Processor/Access/Browsers.pm#L12">https://github.com/eprints/irstats2/blob/master/cfg/plugins/EPrints/Plugin/Stats/Processor/Access/Browsers.pm#L12</a></font></tt><tt><font size="2"><br>
<br>
...which probably should exist in a configuration file for just this reason.<br>
<br>
The problem is that the Chrome line includes the word 'Safari' -- I'm not sure what the best practice to fix this is. It's quite possible that the problem is broader than you suspect, so fixing it would make it wrong in different ways.<br>
<br>
Part of the problem is also that we're iterating through the keys of a hash, and they order they come out in is undefined, so we can't be sure which browser will get the priority.<br>
<br>
We should probably be using a library for this -- something like </font></tt><tt><font size="2"><a href="http://search.cpan.org/dist/Parse-HTTP-UserAgent/lib/Parse/HTTP/UserAgent.pm">http://search.cpan.org/dist/Parse-HTTP-UserAgent/lib/Parse/HTTP/UserAgent.pm</a></font></tt><tt><font size="2"><br>
<br>
--<br>
Adam Field<br>
Business Relationship Manager and Community Lead<br>
EPrints Services<br>
+44 (0)23 8059 8814<br>
<br>
<br>
<br>
<br>
<br>
On 22 Sep 2015, at 20:45, Robin Sylvestre wrote:<br>
<br>
> This is pretty old, but I haven't seen any response to this.<br>
> <br>
> I noticed that Chrome browser gets identified as Safari in IRStats2. The user agent string from my Chrome browser is :<br>
> <br>
> Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36<br>
> <br>
> I don’t have Safari on my computer, but from what I gather from Google, Safari’s user agent looks like this:<br>
> <br>
> Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3Safari/600.3.18<br>
> <br>
> Anyone here knows how to modify “Browsers.pm” to distinguish the two browsers?<br>
> <br>
> <br>
> Thanks!<br>
> <br>
> <br>
> <br>
> <br>
> Robin Sylvestre<br>
> Technicien en documentation<br>
> Bibliothèque - Services techniques et systèmes informatisés<br>
> École Polytechnique de Montréal<br>
> Tél.: 514-340-4711 poste 3743<br>
> <br>
> <br>
> <br>
> -----Message d'origine-----<br>
> De : Centro de Documentación [</font></tt><tt><font size="2"><a href="mailto:cendocu@gmail.com">mailto:cendocu@gmail.com</a></font></tt><tt><font size="2">] <br>
> Envoyé : 3 mars 2015 09:19<br>
> À : eprints-tech@ecs.soton.ac.uk<br>
> Objet : [EP-tech] IRStats2. Browsers and Countries<br>
> <br>
> Hi,<br>
> <br>
> I think that the IRStats' browser detection isn't working properly. At the very very top of the ranking, I have "Apple Safari" and "MIExplorer", ¿Firefox? in the middle and at the end ¿Chrome?. It's weird ....<br>
> <br>
> Some days ago, when I looked some items with few downloads, I realized that some of them showed more downloads than countries-downloads. I think IRStats2 can't resolve some IPs as countries or unknown-countries, can be?. (I use country.pm with this patch<br>
> </font></tt><tt><font size="2"><a href="https://github.com/eprints/irstats2/commit/cdeb3281694ff1eee3d4f97660560aa4ef3cd30c">https://github.com/eprints/irstats2/commit/cdeb3281694ff1eee3d4f97660560aa4ef3cd30c</a></font></tt><tt><font size="2">)<br>
> I running IRStats1 too and it's works fine.<br>
> <br>
> Regards,<br>
> <br>
> Cristian<br>
> <br>
> <br>
> *** Options: </font></tt><tt><font size="2"><a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a></font></tt><tt><font size="2"><br>
> *** Archive: </font></tt><tt><font size="2"><a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a></font></tt><tt><font size="2"><br>
> *** EPrints community wiki: </font></tt><tt><font size="2"><a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a></font></tt><tt><font size="2"><br>
> *** EPrints developers Forum: </font></tt><tt><font size="2"><a href="http://forum.eprints.org/">http://forum.eprints.org/</a></font></tt><tt><font size="2"><br>
<br>
<br>
*** Options: </font></tt><tt><font size="2"><a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a></font></tt><tt><font size="2"><br>
*** Archive: </font></tt><tt><font size="2"><a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a></font></tt><tt><font size="2"><br>
*** EPrints community wiki: </font></tt><tt><font size="2"><a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a></font></tt><tt><font size="2"><br>
*** EPrints developers Forum: </font></tt><tt><font size="2"><a href="http://forum.eprints.org/">http://forum.eprints.org/</a></font></tt><tt><font size="2"><br>
</font></tt><br>
</body></html>